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
FieldsFields inherited from class com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.AbstractOptimizer
logger
Fields 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
ConstructorsConstructorDescriptionStandard
optimizer, DFA updates handledinternally
.AbstractEOptimizer
(DataChainsUpdatePolicy dataChainsUpdatePolicy) Standard
optimizer.AbstractEOptimizer
(DataChainsUpdatePolicy dataChainsUpdatePolicy, OptimizerType type) -
Method Summary
Modifier and TypeMethodDescriptionprotected int
cleanCfg()
protected boolean
protected void
Dump the CFG.Get the data chains update policy after the optimization was performed.Retrieve the optional master optimizer that manages this optimizer.protected IEMasterOptimizer
Safely retrieve a master optimizer.protected abstract int
perform()
Perform the optimization pass.performOnExpression
(IEGeneric exp, IERoutineContext ectx) The default implementation does nothing and returns null.final int
Same asperform(true)
.protected final int
postPerform
(int totalOptimizationCount) Optimizers havingDataChainsUpdatePolicy.UPDATE_IF_OPTIMIZED
policy should return using this method.protected final int
postPerform
(int totalOptimizationCount, boolean requestDFA) Optimizers havingDataChainsUpdatePolicy.UPDATE_IF_OPTIMIZED
orDataChainsUpdatePolicy.UPDATE_IF_REQUIRED
policy should return using this method.protected void
setDataChainsUpdatePolicy
(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 void
Verify 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, setType
Methods inherited from class com.pnfsoftware.jeb.core.AbstractPlugin
dispose, getData, setData
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.IOptimizer
getPreferredExecutionStage, getPriority, getRequiredModeThreshold, getTags, getType, setMasterOptimizer
Methods inherited from interface com.pnfsoftware.jeb.core.IPlugin
dispose, getData, getPluginInformation, setData
-
Field Details
-
ectx
-
cfg
-
-
Constructor Details
-
AbstractEOptimizer
public AbstractEOptimizer()Standard
optimizer, DFA updates handledinternally
. -
AbstractEOptimizer
Standard
optimizer. -
AbstractEOptimizer
-
-
Method Details
-
getMasterOptimizer
Description copied from interface:IOptimizer
Retrieve the optional master optimizer that manages this optimizer.- Specified by:
getMasterOptimizer
in interfaceIOptimizer<IERoutineContext>
- Overrides:
getMasterOptimizer
in 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:IEOptimizer
Get the data chains update policy after the optimization was performed.- Specified by:
getDataChainsUpdatePolicy
in interfaceIEOptimizer
- Returns:
-
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:
performOnExpression
in 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:
performOnTarget
in interfaceIOptimizer<IERoutineContext>
- 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_OPTIMIZED
policy 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_OPTIMIZED
orDataChainsUpdatePolicy.UPDATE_IF_REQUIRED
policy should return using this method.- Parameters:
totalOptimizationCount
- count of optimizations- Returns:
- the count of optimizations
-
deleteUnreachableTrampoline
-
cleanCfg
protected int cleanCfg() -
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)
-