use of com.android.dx.rop.code.RopMethod in project J2ME-Loader by nikita36078.
the class Optimizer method optimize.
/**
* Runs optimization algorthims over this method, and returns a new
* instance of RopMethod with the changes.
*
* @param rmeth method to process
* @param paramWidth the total width, in register-units, of this method's
* parameters
* @param isStatic true if this method has no 'this' pointer argument.
* @param inPreserveLocals true if local variable info should be preserved,
* at the cost of some registers and insns
* @param inAdvice {@code non-null;} translation advice
* @param steps set of optional optimization steps to run
* @return optimized method
*/
public static RopMethod optimize(RopMethod rmeth, int paramWidth, boolean isStatic, boolean inPreserveLocals, TranslationAdvice inAdvice, EnumSet<OptionalStep> steps) {
SsaMethod ssaMeth = null;
preserveLocals = inPreserveLocals;
advice = inAdvice;
ssaMeth = SsaConverter.convertToSsaMethod(rmeth, paramWidth, isStatic);
runSsaFormSteps(ssaMeth, steps);
RopMethod resultMeth = SsaToRop.convertToRopMethod(ssaMeth, false);
if (resultMeth.getBlocks().getRegCount() > advice.getMaxOptimalRegisterCount()) {
// Try to see if we can squeeze it under the register count bar
resultMeth = optimizeMinimizeRegisters(rmeth, paramWidth, isStatic, steps);
}
return resultMeth;
}
use of com.android.dx.rop.code.RopMethod in project J2ME-Loader by nikita36078.
the class Optimizer method optimizeMinimizeRegisters.
/**
* Runs the optimizer with a strategy to minimize the number of rop-form
* registers used by the end result. Dex bytecode does not have instruction
* forms that take register numbers larger than 15 for all instructions.
* If we've produced a method that uses more than 16 registers, try again
* with a different strategy to see if we can get under the bar. The end
* result will be much more efficient.
*
* @param rmeth method to process
* @param paramWidth the total width, in register-units, of this method's
* parameters
* @param isStatic true if this method has no 'this' pointer argument.
* @param steps set of optional optimization steps to run
* @return optimized method
*/
private static RopMethod optimizeMinimizeRegisters(RopMethod rmeth, int paramWidth, boolean isStatic, EnumSet<OptionalStep> steps) {
SsaMethod ssaMeth;
RopMethod resultMeth;
ssaMeth = SsaConverter.convertToSsaMethod(rmeth, paramWidth, isStatic);
EnumSet<OptionalStep> newSteps = steps.clone();
/*
* CONST_COLLECTOR trades insns for registers, which is not an
* appropriate strategy here.
*/
newSteps.remove(OptionalStep.CONST_COLLECTOR);
runSsaFormSteps(ssaMeth, newSteps);
resultMeth = SsaToRop.convertToRopMethod(ssaMeth, true);
return resultMeth;
}
Aggregations