DexTranslationAdvicepublic final class DexTranslationAdvice extends Object implements TranslationAdviceImplementation of {@link TranslationAdvice} which represents what
the dex format will be able to represent. |
Fields Summary |
---|
public static final DexTranslationAdvice | THE_ONE{@code non-null;} standard instance of this class | public static final DexTranslationAdvice | NO_SOURCES_IN_ORDERdebug advice for disabling invoke-range optimization | private static final int | MIN_INVOKE_IN_ORDERThe minimum source width, in register units, for an invoke
instruction that requires its sources to be in order and contiguous. | private final boolean | disableSourcesInOrderwhen true: always returns false for requiresSourcesInOrder |
Constructors Summary |
---|
private DexTranslationAdvice()This class is not publicly instantiable. Use {@link #THE_ONE}.
disableSourcesInOrder = false;
| private DexTranslationAdvice(boolean disableInvokeRange)
this.disableSourcesInOrder = disableInvokeRange;
|
Methods Summary |
---|
public int | getMaxOptimalRegisterCount(){@inheritDoc}
return 16;
| public boolean | hasConstantOperation(Rop opcode, RegisterSpec sourceA, RegisterSpec sourceB){@inheritDoc}
if (sourceA.getType() != Type.INT) {
return false;
}
// Return false if second source isn't a constant
if (! (sourceB.getTypeBearer() instanceof CstInteger)) {
// Except for rsub-int (reverse sub) where first source is constant
if (sourceA.getTypeBearer() instanceof CstInteger &&
opcode.getOpcode() == RegOps.SUB) {
CstInteger cst = (CstInteger) sourceA.getTypeBearer();
return cst.fitsIn16Bits();
} else {
return false;
}
}
CstInteger cst = (CstInteger) sourceB.getTypeBearer();
switch (opcode.getOpcode()) {
// These have 8 and 16 bit cst representations
case RegOps.REM:
case RegOps.ADD:
case RegOps.MUL:
case RegOps.DIV:
case RegOps.AND:
case RegOps.OR:
case RegOps.XOR:
return cst.fitsIn16Bits();
// These only have 8 bit cst reps
case RegOps.SHL:
case RegOps.SHR:
case RegOps.USHR:
return cst.fitsIn8Bits();
// No sub-const insn, so check if equivalent add-const fits
case RegOps.SUB:
CstInteger cst2 = CstInteger.make(-cst.getValue());
return cst2.fitsIn16Bits();
default:
return false;
}
| public boolean | requiresSourcesInOrder(Rop opcode, RegisterSpecList sources){@inheritDoc}
return !disableSourcesInOrder && opcode.isCallLike()
&& totalRopWidth(sources) >= MIN_INVOKE_IN_ORDER;
| private int | totalRopWidth(RegisterSpecList sources)Calculates the total rop width of the list of SSA registers
int sz = sources.size();
int total = 0;
for (int i = 0; i < sz; i++) {
total += sources.get(i).getCategory();
}
return total;
|
|