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;
}
if (! (sourceB.getTypeBearer() instanceof CstInteger)) {
return false;
}
CstInteger cst = (CstInteger) sourceB.getTypeBearer();
// TODO handle rsub
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();
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;
|
|