Search in sources :

Example 91 with Constant

use of com.android.dx.rop.cst.Constant in project J2ME-Loader by nikita36078.

the class SCCP method simulatePhi.

/**
 * Simulates a PHI node and set the lattice for the result
 * to the appropriate value.
 * Meet values:
 * TOP x anything = TOP
 * VARYING x anything = VARYING
 * CONSTANT x CONSTANT = CONSTANT if equal constants, VARYING otherwise
 * @param insn PHI to simulate.
 */
private void simulatePhi(PhiInsn insn) {
    int phiResultReg = insn.getResult().getReg();
    if (latticeValues[phiResultReg] == VARYING) {
        return;
    }
    RegisterSpecList sources = insn.getSources();
    int phiResultValue = TOP;
    Constant phiConstant = null;
    int sourceSize = sources.size();
    for (int i = 0; i < sourceSize; i++) {
        int predBlockIndex = insn.predBlockIndexForSourcesIndex(i);
        int sourceReg = sources.get(i).getReg();
        int sourceRegValue = latticeValues[sourceReg];
        if (!executableBlocks.get(predBlockIndex)) {
            continue;
        }
        if (sourceRegValue == CONSTANT) {
            if (phiConstant == null) {
                phiConstant = latticeConstants[sourceReg];
                phiResultValue = CONSTANT;
            } else if (!latticeConstants[sourceReg].equals(phiConstant)) {
                phiResultValue = VARYING;
                break;
            }
        } else {
            phiResultValue = sourceRegValue;
            break;
        }
    }
    if (setLatticeValueTo(phiResultReg, phiResultValue, phiConstant)) {
        addUsersToWorklist(phiResultReg, phiResultValue);
    }
}
Also used : Constant(com.android.dx.rop.cst.Constant) TypedConstant(com.android.dx.rop.cst.TypedConstant) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList)

Aggregations

Constant (com.android.dx.rop.cst.Constant)91 RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)36 CstType (com.android.dx.rop.cst.CstType)30 CstString (com.android.dx.rop.cst.CstString)27 CstInsn (com.android.dx.dex.code.CstInsn)24 RegisterSpec (com.android.dx.rop.code.RegisterSpec)20 TypedConstant (com.android.dx.rop.cst.TypedConstant)20 CstLiteralBits (com.android.dx.rop.cst.CstLiteralBits)18 CstFieldRef (com.android.dx.rop.cst.CstFieldRef)17 CstMethodRef (com.android.dx.rop.cst.CstMethodRef)14 CstInteger (com.android.dx.rop.cst.CstInteger)12 NameValuePair (com.android.dx.rop.annotation.NameValuePair)8 Insn (com.android.dx.rop.code.Insn)8 PlainInsn (com.android.dx.rop.code.PlainInsn)8 Type (com.android.dx.rop.type.Type)8 TypeBearer (com.android.dx.rop.type.TypeBearer)8 Rop (com.android.dx.rop.code.Rop)6 ThrowingCstInsn (com.android.dx.rop.code.ThrowingCstInsn)6 ArrayList (java.util.ArrayList)6 ParseException (com.android.dx.cf.iface.ParseException)4