Top Description Inners Fields Constructors Methods
org.droidparts.dexmaker.dx.ssa

public Class Optimizer

extends Object
Class Inheritance
Imports
org.droidparts.dexmaker.dx.rop.code.RopMethod, .TranslationAdvice, org.droidparts.dexmaker.dx.ssa.back.LivenessAnalyzer, .SsaToRop, java.util.EnumSet

Runs a method through the SSA form conversion, any optimization algorithms, and returns it to rop form.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Optimizer.OptionalStep

optional optimizer steps

Field Summary

Modifier and TypeField and Description
private static TranslationAdvice
private static boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static SsaMethod
debugDeadCodeRemover(RopMethod rmeth, int paramWidth, boolean isStatic, boolean inPreserveLocals, TranslationAdvice inAdvice)

public static SsaMethod
debugEdgeSplit(RopMethod rmeth, int paramWidth, boolean isStatic, boolean inPreserveLocals, TranslationAdvice inAdvice)

public static SsaMethod
debugNoRegisterAllocation(RopMethod rmeth, int paramWidth, boolean isStatic, boolean inPreserveLocals, TranslationAdvice inAdvice, EnumSet<Optimizer.OptionalStep> steps)

public static SsaMethod
debugPhiPlacement(RopMethod rmeth, int paramWidth, boolean isStatic, boolean inPreserveLocals, TranslationAdvice inAdvice)

public static SsaMethod
debugRenaming(RopMethod rmeth, int paramWidth, boolean isStatic, boolean inPreserveLocals, TranslationAdvice inAdvice)

public static TranslationAdvice

Returns:

non-null; translation advice
getAdvice
()

public static boolean

Returns:

true if local variable information should be preserved, even at code size/register size cost
getPreserveLocals
()

public static RopMethod

Returns:

optimized method
optimize
(RopMethod
method to process
rmeth
,
int
the total width, in register-units, of this method's parameters
paramWidth
,
boolean
true if this method has no 'this' pointer argument.
isStatic
,
boolean
true if local variable info should be preserved, at the cost of some registers and insns
inPreserveLocals
,
TranslationAdvice
non-null; translation advice
inAdvice
)

Runs optimization algorthims over this method, and returns a new instance of RopMethod with the changes.

public static RopMethod

Returns:

optimized method
optimize
(RopMethod
method to process
rmeth
,
int
the total width, in register-units, of this method's parameters
paramWidth
,
boolean
true if this method has no 'this' pointer argument.
isStatic
,
boolean
true if local variable info should be preserved, at the cost of some registers and insns
inPreserveLocals
,
TranslationAdvice
non-null; translation advice
inAdvice
,
EnumSet<Optimizer.OptionalStep>
set of optional optimization steps to run
steps
)

Runs optimization algorthims over this method, and returns a new instance of RopMethod with the changes.

private static RopMethod

Returns:

optimized method
optimizeMinimizeRegisters
(RopMethod
method to process
rmeth
,
int
the total width, in register-units, of this method's parameters
paramWidth
,
boolean
true if this method has no 'this' pointer argument.
isStatic
,
EnumSet<Optimizer.OptionalStep>
set of optional optimization steps to run
steps
)

Runs the optimizer with a strategy to minimize the number of rop-form registers used by the end result.

private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

adviceback to summary
private static TranslationAdvice advice
preserveLocalsback to summary
private static boolean preserveLocals

Constructor Detail

Optimizerback to summary
public Optimizer()

Method Detail

debugDeadCodeRemoverback to summary
public static SsaMethod debugDeadCodeRemover(RopMethod rmeth, int paramWidth, boolean isStatic, boolean inPreserveLocals, TranslationAdvice inAdvice)
debugEdgeSplitback to summary
public static SsaMethod debugEdgeSplit(RopMethod rmeth, int paramWidth, boolean isStatic, boolean inPreserveLocals, TranslationAdvice inAdvice)
debugNoRegisterAllocationback to summary
public static SsaMethod debugNoRegisterAllocation(RopMethod rmeth, int paramWidth, boolean isStatic, boolean inPreserveLocals, TranslationAdvice inAdvice, EnumSet<Optimizer.OptionalStep> steps)
debugPhiPlacementback to summary
public static SsaMethod debugPhiPlacement(RopMethod rmeth, int paramWidth, boolean isStatic, boolean inPreserveLocals, TranslationAdvice inAdvice)
debugRenamingback to summary
public static SsaMethod debugRenaming(RopMethod rmeth, int paramWidth, boolean isStatic, boolean inPreserveLocals, TranslationAdvice inAdvice)
getAdviceback to summary
public static TranslationAdvice getAdvice()
Returns:TranslationAdvice

non-null; translation advice

getPreserveLocalsback to summary
public static boolean getPreserveLocals()
Returns:boolean

true if local variable information should be preserved, even at code size/register size cost

optimizeback to summary
public static RopMethod optimize(RopMethod rmeth, int paramWidth, boolean isStatic, boolean inPreserveLocals, TranslationAdvice inAdvice)

Runs optimization algorthims over this method, and returns a new instance of RopMethod with the changes.

Parameters
rmeth:RopMethod

method to process

paramWidth:int

the total width, in register-units, of this method's parameters

isStatic:boolean

true if this method has no 'this' pointer argument.

inPreserveLocals:boolean

true if local variable info should be preserved, at the cost of some registers and insns

inAdvice:TranslationAdvice

non-null; translation advice

Returns:RopMethod

optimized method

optimizeback to summary
public static RopMethod optimize(RopMethod rmeth, int paramWidth, boolean isStatic, boolean inPreserveLocals, TranslationAdvice inAdvice, EnumSet<Optimizer.OptionalStep> steps)

Runs optimization algorthims over this method, and returns a new instance of RopMethod with the changes.

Parameters
rmeth:RopMethod

method to process

paramWidth:int

the total width, in register-units, of this method's parameters

isStatic:boolean

true if this method has no 'this' pointer argument.

inPreserveLocals:boolean

true if local variable info should be preserved, at the cost of some registers and insns

inAdvice:TranslationAdvice

non-null; translation advice

steps:EnumSet<Optimizer.OptionalStep>

set of optional optimization steps to run

Returns:RopMethod

optimized method

optimizeMinimizeRegistersback to summary
private static RopMethod optimizeMinimizeRegisters(RopMethod rmeth, int paramWidth, boolean isStatic, EnumSet<Optimizer.OptionalStep> steps)

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.

Parameters
rmeth:RopMethod

method to process

paramWidth:int

the total width, in register-units, of this method's parameters

isStatic:boolean

true if this method has no 'this' pointer argument.

steps:EnumSet<Optimizer.OptionalStep>

set of optional optimization steps to run

Returns:RopMethod

optimized method

runSsaFormStepsback to summary
private static void runSsaFormSteps(SsaMethod ssaMeth, EnumSet<Optimizer.OptionalStep> steps)
org.droidparts.dexmaker.dx.ssa back to summary

public final Enum Optimizer.OptionalStep

extends Enum<Optimizer.OptionalStep>
Class Inheritance

optional optimizer steps

Field Summary

Modifier and TypeField and Description
public static final Optimizer.OptionalStep
public static final Optimizer.OptionalStep
public static final Optimizer.OptionalStep
public static final Optimizer.OptionalStep
public static final Optimizer.OptionalStep

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Optimizer.OptionalStep
public static Optimizer.OptionalStep[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CONST_COLLECTORback to summary
public static final Optimizer.OptionalStep CONST_COLLECTOR
ESCAPE_ANALYSISback to summary
public static final Optimizer.OptionalStep ESCAPE_ANALYSIS
LITERAL_UPGRADEback to summary
public static final Optimizer.OptionalStep LITERAL_UPGRADE
MOVE_PARAM_COMBINERback to summary
public static final Optimizer.OptionalStep MOVE_PARAM_COMBINER
SCCPback to summary
public static final Optimizer.OptionalStep SCCP

Constructor Detail

OptionalStepback to summary
private OptionalStep()

Method Detail

valueOfback to summary
public static Optimizer.OptionalStep valueOf(String name)
valuesback to summary
public static Optimizer.OptionalStep[] values()