Ejemplo n.º 1
0
PeepHoleOpt::Changed PeepHoleOpt::handleInst_Call(Inst* inst)
{
    assert(inst->getMnemonic() == Mnemonic_CALL);
    CallInst* callInst = (CallInst*)inst;
    unsigned targetOpndIndex = callInst->getTargetOpndIndex();
    Opnd* targetOpnd = callInst->getOpnd(targetOpndIndex);
    Opnd::RuntimeInfo* ri = targetOpnd->getRuntimeInfo();
    Opnd::RuntimeInfo::Kind rt_kind = Opnd::RuntimeInfo::Kind_Null;
    if (ri != NULL) {
        rt_kind = ri->getKind();
    }

    if (Opnd::RuntimeInfo::Kind_InternalHelperAddress == rt_kind) {
        return handleInst_InternalHelperCall(inst, ri);
    }
    return Changed_Nothing;
}
Ejemplo n.º 2
0
const void* OpndUtils::extractAddrOfConst(const Opnd* op)
{
    if (op->getMemOpndKind() != MemOpndKind_ConstantArea) {
        return NULL;
    }
    // Actually, it's currently only works for IA-32 - I expect 
    // the address of constant completely in the displacement.
    // On Intel64, the address already get loaded into a register, 
    // so more complicated analysis needed to find the proper constant
    Opnd* disp = op->getMemOpndSubOpnd(MemOpndSubOpndKind_Displacement);
    if (disp == NULL) {
        // Perhaps, it's IA-32?
        return NULL;
    }
    
    Opnd::RuntimeInfo* rtInfo = disp->getRuntimeInfo();
    assert(rtInfo != NULL);
    assert(rtInfo->getKind() == Opnd::RuntimeInfo::Kind_ConstantAreaItem);
    ConstantAreaItem* item = (ConstantAreaItem*)rtInfo->getValue(0);
    // At this point we must have the address...
    assert(item->getValue()!= NULL);
    return item->getValue();
}
Ejemplo n.º 3
0
//All CALL insts except some special helpers that never cause stacktrace printing
bool InstUtils::instMustHaveBCMapping(Inst* inst) {
    if (!inst->hasKind(Inst::Kind_CallInst)) {
        return false;
    }
    CallInst* callInst = (CallInst*)inst;
    Opnd * targetOpnd=callInst->getOpnd(callInst->getTargetOpndIndex());
    Opnd* immOpnd = OpndUtils::findImmediateSource(targetOpnd);
    Opnd::RuntimeInfo * ri = immOpnd ? immOpnd->getRuntimeInfo() : NULL;
    if(!ri) {
        return true;
    } else if (ri->getKind() == Opnd::RuntimeInfo::Kind_InternalHelperAddress) { 
        return false;
    } else if (ri->getKind() == Opnd::RuntimeInfo::Kind_HelperAddress) { 
        VM_RT_SUPPORT helperId = (VM_RT_SUPPORT)(POINTER_SIZE_INT)ri->getValue(0);
        switch (helperId) {
            case VM_RT_GC_GET_TLS_BASE:
            case VM_RT_GC_SAFE_POINT:
                return false;
            default:
                break;
        }
    }
    return true;
}