Class AbstractEOptimizer
java.lang.Object
com.pnfsoftware.jeb.core.AbstractPlugin
com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.AbstractOptimizer<IERoutineContext>
com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.opt.AbstractEOptimizer
- All Implemented Interfaces:
IPlugin,IEOptimizer,IOptimizer<IERoutineContext>
- Direct Known Subclasses:
AbstractEBlockOptimizer,AbstractEExpressionOptimizer,AbstractEPatternOptimizer,AbstractEStatementOptimizer
public abstract class AbstractEOptimizer
extends AbstractOptimizer<IERoutineContext>
implements IEOptimizer
Base class for IR optimizers.
The no-arg constructor is for standard optimizers, with DFA updates
handled internally.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CFG<IEStatement> CFG currently being optimized.protected IERoutineContextRoutine context currently being optimized.Fields inherited from class com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.AbstractOptimizer
loggerFields inherited from interface com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.IOptimizer
DEAD_CODE_REMOVER, DEOBFUSCATOR, PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_STANDARD -
Constructor Summary
ConstructorsConstructorDescriptionStandardoptimizer, DFA updates handledinternally.AbstractEOptimizer(DataChainsUpdatePolicy dataChainsUpdatePolicy) Standardoptimizer.AbstractEOptimizer(DataChainsUpdatePolicy dataChainsUpdatePolicy, OptimizerType type) Create an IR optimizer. -
Method Summary
Modifier and TypeMethodDescriptionprotected intcleanCfg()Clean the CFG.protected booleanDelete an unreachable trampoline block.protected voidDump the CFG.Get the data chains update policy after the optimization was performed.Retrieve the optional master optimizer that manages this optimizer.protected IEMasterOptimizerSafely retrieve a master optimizer.protected abstract intperform()Perform the optimization pass.performOnExpression(IEGeneric exp, IERoutineContext ectx) The default implementation does nothing and returns null.final intSame asperform(true).protected final intpostPerform(int totalOptimizationCount) Optimizers havingDataChainsUpdatePolicy.UPDATE_IF_OPTIMIZEDpolicy should return using this method.protected final intpostPerform(int totalOptimizationCount, boolean requestDFA) Optimizers havingDataChainsUpdatePolicy.UPDATE_IF_OPTIMIZEDorDataChainsUpdatePolicy.UPDATE_IF_REQUIREDpolicy should return using this method.protected voidsetDataChainsUpdatePolicy(DataChainsUpdatePolicy dataChainsUpdatePolicy) This method should rarely be called; data-chains update policy is set up in the constructor, and should not change under normal circumstances.protected voidVerify the CFG.Methods inherited from class com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.AbstractOptimizer
addTag, getName, getPluginInformation, getPreferredExecutionStage, getPriority, getRequiredModeThreshold, getTags, getType, removeTag, setMasterOptimizer, setName, setPreferredExecutionStage, setPriority, setRequiredModeThreshold, setTypeMethods inherited from class com.pnfsoftware.jeb.core.AbstractPlugin
dispose, getData, setDataMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.IOptimizer
getPreferredExecutionStage, getPriority, getRequiredModeThreshold, getTags, getType, setMasterOptimizerMethods inherited from interface com.pnfsoftware.jeb.core.IPlugin
dispose, getData, getPluginInformation, setData
-
Field Details
-
ectx
Routine context currently being optimized. -
cfg
CFG currently being optimized.
-
-
Constructor Details
-
AbstractEOptimizer
public AbstractEOptimizer()Standardoptimizer, DFA updates handledinternally. -
AbstractEOptimizer
Standardoptimizer.- Parameters:
dataChainsUpdatePolicy- data chains update policy
-
AbstractEOptimizer
Create an IR optimizer.- Parameters:
dataChainsUpdatePolicy- data chains update policytype- optimizer type
-
-
Method Details
-
getMasterOptimizer
Description copied from interface:IOptimizerRetrieve the optional master optimizer that manages this optimizer.- Specified by:
getMasterOptimizerin interfaceIOptimizer<IERoutineContext>- Overrides:
getMasterOptimizerin classAbstractOptimizer<IERoutineContext>- Returns:
- optional reference
-
getMasterOptimizerSafe
Safely retrieve a master optimizer. IfgetMasterOptimizer()provides one, it is returned. Else, an empty immutable generic MO is provided.- Returns:
- never null
-
getDataChainsUpdatePolicy
Description copied from interface:IEOptimizerGet the data chains update policy after the optimization was performed.- Specified by:
getDataChainsUpdatePolicyin interfaceIEOptimizer- Returns:
- the data chains update policy
-
setDataChainsUpdatePolicy
This method should rarely be called; data-chains update policy is set up in the constructor, and should not change under normal circumstances.- Parameters:
dataChainsUpdatePolicy- null means DFA is handled internally, by the optimizer
-
performOnExpression
The default implementation does nothing and returns null.- Specified by:
performOnExpressionin interfaceIEOptimizer- Parameters:
exp- IR expression to optimizeectx- helper routine context- Returns:
- non-null if the expression was optimized; null otherwise
-
performOnTarget
Same asperform(true). Data chains will be updated according to the optimizer's DFA policy.The above means that data chains after running this method may be modified, but must be in a consistent state with the CFG.
- Specified by:
performOnTargetin interfaceIOptimizer<IERoutineContext>- Parameters:
ctx- target to optimize- Returns:
- the number of optimizations performed; if negative, an error has occurred and the optimizing process should be aborted
-
perform
protected abstract int perform()Perform the optimization pass. The caller may request that data chains not be updated, whenever possible. (They may be updated internally by the optimizer, which has the final say as to how and when DFA calculations should be run.)The above means that data chains after running this method may or may not have been modified, and may or may not be in a consistent state with the optimized CFG.
- Returns:
- the result of a call to one of
postPerform(...)or a negative number indicating an error has occurred and the optimizing process should be aborted
-
postPerform
protected final int postPerform(int totalOptimizationCount) Optimizers havingDataChainsUpdatePolicy.UPDATE_IF_OPTIMIZEDpolicy should return using this method.- Parameters:
totalOptimizationCount- count of optimizations- Returns:
- the count of optimizations
-
postPerform
protected final int postPerform(int totalOptimizationCount, boolean requestDFA) Optimizers havingDataChainsUpdatePolicy.UPDATE_IF_OPTIMIZEDorDataChainsUpdatePolicy.UPDATE_IF_REQUIREDpolicy should return using this method.- Parameters:
totalOptimizationCount- count of optimizationsrequestDFA- true if data-flow analysis should be invalidated even when the policy isDataChainsUpdatePolicy.UPDATE_IF_REQUIRED- Returns:
- the count of optimizations
-
deleteUnreachableTrampoline
Delete an unreachable trampoline block.- Parameters:
b- basic block- Returns:
- true if a trampoline was deleted
-
cleanCfg
protected int cleanCfg()Clean the CFG.- Returns:
- the number of graph updates performed
-
verifyCfg
protected void verifyCfg()Verify the CFG. Convenience method callingEUtil.verify(CFG). -
dumpCfg
Dump the CFG. Convenience method callingEUtil.dump(CFG, String).- Parameters:
filename- filename (the file will be created in the temp folder)
-