public class

EMasterOptimizer

extends AbstractMasterOptimizer<T>
implements IEMasterOptimizer
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.AbstractMasterOptimizer<T>
     ↳ com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.opt.EMasterOptimizer

Class Overview

Standard master optimizer for CFG of IEStatement IR instructions. Comes with a bundle of standard expression optimizers, all registered in the DEFAULT_GROUP. Additional optimizers can be registered. Refer to the constructor javadoc. Special use registers can be specified in order to improve the optimization rate of the dead-code removal and expression substitution standard optimizers.

Summary

[Expand]
Inherited Constants
From interface com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.IMasterOptimizer
Fields
public static final EMasterOptimizer EMPTY
public static int defaultMaxRunCount no max
[Expand]
Inherited Fields
From class com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.AbstractMasterOptimizer
Public Constructors
EMasterOptimizer(IERoutineContext ectx)
Create a standard IR master optimizer with no maximum runcount (unsafe).
EMasterOptimizer(IERoutineContext ectx, int grp1NMaxRunCount)
Create a standard IR master optimizer.
EMasterOptimizer(IERoutineContext ectx, int grp1NMaxRunCount, boolean autoRegisterStandardOptimizers)
Create a standard IR master optimizer.
Public Methods
void addDefaultInput(int bit, IEImm val)
void addDisregardedOutputBits(Collection<Integer> disregardedOutputBits)
void addDisregardedOutputFilter(IEOptFilterCanDiscard filter)
void addDisregardedOutputVariables(Collection<? extends IEVar> disregardedOutputVars)
boolean canDiscardUnusedDefinition(IERoutineContext ectx, DFA<IEStatement> dfa, long insnAddress, int def)
Check if a variable definition, unused by the routine, and reaching a routine exit point, can be safely discarded.
IEImm getDefaultInput(int reg)
Set<Integer> getDisregardedOutputRegisters()
Protected Methods
String getTargetAddress(IERoutineContext target)
boolean onOptimizerException(IERoutineContext ctx, IOptimizer<IERoutineContext> opt, Exception ex)
This method is called when an optimizer hard-failed and generated an exception.
void postAllOptimizationsCallback(IERoutineContext ctx)
This method might be overridden, but the parent should be called first.
void postOptimizationCallback(IERoutineContext ctx, OptimizerEntry<IERoutineContext> e, int cnt, long executionTimeMs)
This method might be overridden, but the parent should be called first.
void preAllOptimizationsCallback(IERoutineContext ctx)
This method might be overridden, but the parent should be called first.
void preOptimizationCallback(IERoutineContext ctx, OptimizerEntry<IERoutineContext> e)
This method might be overridden, but the parent should be called first.
[Expand]
Inherited Methods
From class com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.AbstractMasterOptimizer
From class java.lang.Object
From interface com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.opt.IEMasterOptimizer
From interface com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.IMasterOptimizer

Fields

public static final EMasterOptimizer EMPTY

public static int defaultMaxRunCount

no max

Public Constructors

public EMasterOptimizer (IERoutineContext ectx)

Create a standard IR master optimizer with no maximum runcount (unsafe).

Parameters
ectx optional default context; the target routine may be set after construction using #setTarget(IERoutineContext)

public EMasterOptimizer (IERoutineContext ectx, int grp1NMaxRunCount)

Create a standard IR master optimizer.

Parameters
ectx optional default context; the target routine may be set after construction using #setTarget(IERoutineContext)
grp1NMaxRunCount maximum run count for the group [1..N]

public EMasterOptimizer (IERoutineContext ectx, int grp1NMaxRunCount, boolean autoRegisterStandardOptimizers)

Create a standard IR master optimizer.

Parameters
ectx optional default context; the target routine may be set after construction using #setTarget(IERoutineContext)
grp1NMaxRunCount maximum run count for the group [1..N]

Public Methods

public void addDefaultInput (int bit, IEImm val)

public void addDisregardedOutputBits (Collection<Integer> disregardedOutputBits)

public void addDisregardedOutputFilter (IEOptFilterCanDiscard filter)

public void addDisregardedOutputVariables (Collection<? extends IEVar> disregardedOutputVars)

public boolean canDiscardUnusedDefinition (IERoutineContext ectx, DFA<IEStatement> dfa, long insnAddress, int def)

Check if a variable definition, unused by the routine, and reaching a routine exit point, can be safely discarded. The implementation may depend on the master optimizer's mode.

Parameters
dfa a data flow analysis object on a CFG

public IEImm getDefaultInput (int reg)

public Set<Integer> getDisregardedOutputRegisters ()

Protected Methods

protected String getTargetAddress (IERoutineContext target)

protected boolean onOptimizerException (IERoutineContext ctx, IOptimizer<IERoutineContext> opt, Exception ex)

This method is called when an optimizer hard-failed and generated an exception.

Parameters
ctx the target that being optimized
opt the failing optimizer
ex the generated exception
Returns
  • if true, the exception will be neutered and the master optimizer will resume the optimizing process; else, the exception will be thrown

protected void postAllOptimizationsCallback (IERoutineContext ctx)

This method might be overridden, but the parent should be called first.

protected void postOptimizationCallback (IERoutineContext ctx, OptimizerEntry<IERoutineContext> e, int cnt, long executionTimeMs)

This method might be overridden, but the parent should be called first. Note that this method might have a big impact on decompilation performance, so override carefully.

protected void preAllOptimizationsCallback (IERoutineContext ctx)

This method might be overridden, but the parent should be called first.

protected void preOptimizationCallback (IERoutineContext ctx, OptimizerEntry<IERoutineContext> e)

This method might be overridden, but the parent should be called first. Note that this method might have a big impact on decompilation performance, so override carefully.