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);
}
}
Aggregations