Esempio n. 1
0
void SCCP::analyzeSSA(Instr* instr) {
    if (numDefs(instr) == 0) {
        if (isBlockEnd(instr))
            analyzeBranch((BlockEndInstr*)instr);
        return;
    }
    // dev: save current types for later check
    int i = 0;
    for (ArrayRange<Def> d = defRange(instr); !d.empty(); d.popFront(), ++i)
        old_types[i] = type(d.front());
    // compute types
    eval_counts[instr->id]++;
    analyzer.computeTypes(instr);
    // dev: check computation result
    bool changed2 = false;
    i = 0;
    for (ArrayRange<Def> d = defRange(instr); !d.empty(); d.popFront(), ++i) {
        AvmAssert(subtypeof(old_types[i], type(d.front())) && "illegal type narrowing");
        changed2 |= *type(d.front()) != *old_types[i];
    }
    if (changed2) {
        if (enable_typecheck) {
            printInstr(instr);
        }
        addInstrUsers(instr);
    }
}
Esempio n. 2
0
void SCCP::analyzeBranch(BlockEndInstr* end) {
    switch (kind(end)) {
    case HR_goto:
        addBlock(cast<GotoInstr>(end)->target);
        break;
    case HR_if:
    case HR_switch: {
        CondInstr* cond = (CondInstr*)end;
        ArmInstr* arm = getConstArm(cond);
        if (arm)
            addBlock(arm);
        else
            for (ArrayRange<ArmInstr*> a = armRange(cond); !a.empty();)
                addBlock(a.popFront());
        break;
    }
    }
    if (end->catch_blocks != NULL) {
        for (CatchBlockRange r(end); !r.empty();)
            addBlock(r.popFront());
    }
}