public abstract class

AbstractEOptimizer

extends AbstractOptimizer<T extends IOptimizerTarget>
implements IEOptimizer
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.AbstractPlugin
     ↳ com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.AbstractOptimizer<T extends com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.IOptimizerTarget>
       ↳ com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.opt.AbstractEOptimizer
Known Direct Subclasses

Class Overview

Base class for IR optimizers.

The no-arg constructor is for standard optimizers, with DFA updates handled internally.

Summary

[Expand]
Inherited Constants
From interface com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.IOptimizer
Fields
protected CFG<IEStatement> cfg
protected IERoutineContext ectx
[Expand]
Inherited Fields
From class com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.AbstractOptimizer
Public Constructors
AbstractEOptimizer()
Standard optimizer, DFA updates handled internally.
AbstractEOptimizer(DataChainsUpdatePolicy dataChainsUpdatePolicy)
Standard optimizer.
AbstractEOptimizer(DataChainsUpdatePolicy dataChainsUpdatePolicy, OptimizerType type)
Public Methods
DataChainsUpdatePolicy getDataChainsUpdatePolicy()
Get the data chains update policy after the optimization was performed.
IEMasterOptimizer getMasterOptimizer()
Retrieve the optional master optimizer that manages this optimizer.
IEGeneric performOnExpression(IEGeneric exp, IERoutineContext ectx)
The default implementation does nothing and returns null.
final int performOnTarget(IERoutineContext ctx)
Same as perform(true).
Protected Methods
int cleanCfg()
boolean deleteUnreachableTrampoline(BasicBlock<IEStatement> b)
void dumpCfg(String filename)
Dump the CFG.
IEMasterOptimizer getMasterOptimizerSafe()
Safely retrieve a master optimizer.
abstract int perform()
Perform the optimization pass.
final int postPerform(boolean updateDFA, int totalOptimizationCount, boolean requestDFA)
This method is deprecated. This method is deprecated (the `updateDFA` parameter is now useless). Optimizers should use postPerform(int, boolean) instead.
final int postPerform(int totalOptimizationCount, boolean requestDFA)
Optimizers having UPDATE_IF_OPTIMIZED or UPDATE_IF_REQUIRED policy should return using this method.
final int postPerform(boolean updateDFA, int totalOptimizationCount)
This method is deprecated. This method is deprecated (the `updateDFA` parameter is now useless). Optimizers should use postPerform(int) instead.
final int postPerform(int totalOptimizationCount)
Optimizers having UPDATE_IF_OPTIMIZED policy should return using this method.
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.
void verifyCfg()
Verify the CFG.
[Expand]
Inherited Methods
From class com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.AbstractOptimizer
From class com.pnfsoftware.jeb.core.AbstractPlugin
From class java.lang.Object
From interface com.pnfsoftware.jeb.core.IPlugin
From interface com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.opt.IEOptimizer
From interface com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.IOptimizer

Fields

protected CFG<IEStatement> cfg

protected IERoutineContext ectx

Public Constructors

public AbstractEOptimizer ()

Standard optimizer, DFA updates handled internally.

public AbstractEOptimizer (DataChainsUpdatePolicy dataChainsUpdatePolicy)

Standard optimizer.

public AbstractEOptimizer (DataChainsUpdatePolicy dataChainsUpdatePolicy, OptimizerType type)

Public Methods

public DataChainsUpdatePolicy getDataChainsUpdatePolicy ()

Get the data chains update policy after the optimization was performed.

public IEMasterOptimizer getMasterOptimizer ()

Retrieve the optional master optimizer that manages this optimizer.

Returns
  • optional reference

public IEGeneric performOnExpression (IEGeneric exp, IERoutineContext ectx)

The default implementation does nothing and returns null.

Parameters
exp IR expression to optimize
ectx helper routine context
Returns
  • non-null if the expression was optimized; null otherwise

public final int performOnTarget (IERoutineContext ctx)

Same as perform(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.

Protected Methods

protected int cleanCfg ()

protected boolean deleteUnreachableTrampoline (BasicBlock<IEStatement> b)

protected void dumpCfg (String filename)

Dump the CFG. Convenience method calling dump(CFG, String).

Parameters
filename filename (the file will be created in the temp folder)

protected IEMasterOptimizer getMasterOptimizerSafe ()

Safely retrieve a master optimizer. If getMasterOptimizer() provides one, it is returned. Else, an empty immutable generic MO is provided.

Returns
  • never null

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

protected final int postPerform (boolean updateDFA, int totalOptimizationCount, boolean requestDFA)

This method is deprecated.
This method is deprecated (the `updateDFA` parameter is now useless). Optimizers should use postPerform(int, boolean) instead.

protected final int postPerform (int totalOptimizationCount, boolean requestDFA)

Optimizers having UPDATE_IF_OPTIMIZED or UPDATE_IF_REQUIRED policy should return using this method.

Parameters
totalOptimizationCount count of optimizations
Returns
  • the count of optimizations

protected final int postPerform (boolean updateDFA, int totalOptimizationCount)

This method is deprecated.
This method is deprecated (the `updateDFA` parameter is now useless). Optimizers should use postPerform(int) instead.

protected final int postPerform (int totalOptimizationCount)

Optimizers having UPDATE_IF_OPTIMIZED policy should return using this method.

Parameters
totalOptimizationCount count of optimizations
Returns
  • the count of optimizations

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.

Parameters
dataChainsUpdatePolicy null means DFA is handled internally, by the optimizer

protected void verifyCfg ()

Verify the CFG. Convenience method calling verify(CFG).