public abstract class

AbstractMasterOptimizer

extends Object
implements IMasterOptimizer<T>
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.AbstractMasterOptimizer<T>
Known Direct Subclasses

Class Overview

Standard implementation of a generic master optimizer.

Summary

Constants
int MODE_AGGRESSIVE
int MODE_NORMAL
Fields
protected int currentMode current optimization mode
protected int grp1NMaxRunCount maximum run count for the group [1..N] (<0 means no limit)
protected List<IMasterOptimizerInstrumenter<T>> instrumenters instrumenters
protected SortedMap<Integer, List<OptimizerEntry<T>>> optGrpMap groups of optimizers; groups 0 and -1 are entry and exit groups, respectively
protected List<OptimizerEntry<T>> optList list of all optimizers
protected T t default target
Public Constructors
AbstractMasterOptimizer(T t, int grp1NMaxRunCount)
Create a master optimizer.
Public Methods
int getMode()
OptimizerEntry<T> getOptimizer(Class<? extends IOptimizer<T>> clazz)
IOptimizer<T> getOptimizerObject(Class<? extends IOptimizer<T>> clazz)
List<OptimizerEntry<T>> getRegisteredOptimizers(int groupId)
Get a copy of the lists of optimizer entries registered with this MO and belonging to the provided optimizer group.
List<OptimizerEntry<T>> getRegisteredOptimizers()
Get a copy of the list of optimizer entries registered with this MO.
T getTarget()
Get the target onto which the optimizations will be performed.
int perform()
Perform an optimization round.
int perform(int depth)
int performMultiple(List<OptimizerEntry<T>> list)
int performSingle(OptimizerEntry<T> e)
void registerInstrumenter(IMasterOptimizerInstrumenter<T> instrumenter)
Register an instrumenter.
OptimizerEntry<T> registerOptimizer(int group, IOptimizer<T> opt)
Register an optimizer, with its default priority.
OptimizerEntry<T> registerOptimizer(IOptimizer<T> opt)
Register an optimizer to the main group, with its default priority.
OptimizerEntry<T> registerOptimizer(int group, IOptimizer<T> opt, double priority)
Register an optimizer.
int setMode(int mode)
void setTarget(T t)
Set the optimizer's target.
boolean unregisterInstrumenter(IMasterOptimizerInstrumenter<T> instrumenter)
Unregister an instrumenter
boolean unregisterOptimizer(OptimizerEntry<T> e)
Remove an optimizer.
Protected Methods
void postAllOptimizationsCallback(T target)
This method might be overridden, but the parent should be called first.
void postOptimizationCallback(T target, OptimizerEntry<T> e, int cnt, long executionTimeMs)
This method might be overridden, but the parent should be called first.
void preAllOptimizationsCallback(T target)
This method might be overridden, but the parent should be called first.
void preOptimizationCallback(T target, OptimizerEntry<T> e)
This method might be overridden, but the parent should be called first.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.IMasterOptimizer

Constants

public static final int MODE_AGGRESSIVE

Constant Value: 10 (0x0000000a)

public static final int MODE_NORMAL

Constant Value: 0 (0x00000000)

Fields

protected int currentMode

current optimization mode

protected int grp1NMaxRunCount

maximum run count for the group [1..N] (<0 means no limit)

protected List<IMasterOptimizerInstrumenter<T>> instrumenters

instrumenters

protected SortedMap<Integer, List<OptimizerEntry<T>>> optGrpMap

groups of optimizers; groups 0 and -1 are entry and exit groups, respectively

protected List<OptimizerEntry<T>> optList

list of all optimizers

protected T t

default target

Public Constructors

public AbstractMasterOptimizer (T t, int grp1NMaxRunCount)

Create a master optimizer.

Parameters
t the default target, may be null
grp1NMaxRunCount maximum run count for the group [1..N]

Public Methods

public int getMode ()

public OptimizerEntry<T> getOptimizer (Class<? extends IOptimizer<T>> clazz)

public IOptimizer<T> getOptimizerObject (Class<? extends IOptimizer<T>> clazz)

public List<OptimizerEntry<T>> getRegisteredOptimizers (int groupId)

Get a copy of the lists of optimizer entries registered with this MO and belonging to the provided optimizer group.

public List<OptimizerEntry<T>> getRegisteredOptimizers ()

Get a copy of the list of optimizer entries registered with this MO.

public T getTarget ()

Get the target onto which the optimizations will be performed.

public int perform ()

Perform an optimization round.

Returns
  • the total number of optimizations performed

public int perform (int depth)

public int performMultiple (List<OptimizerEntry<T>> list)

public int performSingle (OptimizerEntry<T> e)

public void registerInstrumenter (IMasterOptimizerInstrumenter<T> instrumenter)

Register an instrumenter. Instrumenters will be called following their registration order.

public OptimizerEntry<T> registerOptimizer (int group, IOptimizer<T> opt)

Register an optimizer, with its default priority.

public OptimizerEntry<T> registerOptimizer (IOptimizer<T> opt)

Register an optimizer to the main group, with its default priority.

public OptimizerEntry<T> registerOptimizer (int group, IOptimizer<T> opt, double priority)

Register an optimizer.

public int setMode (int mode)

public void setTarget (T t)

Set the optimizer's target.

public boolean unregisterInstrumenter (IMasterOptimizerInstrumenter<T> instrumenter)

Unregister an instrumenter

Returns
  • true if the instrumenter was removed, false otherwise

public boolean unregisterOptimizer (OptimizerEntry<T> e)

Remove an optimizer.

Protected Methods

protected void postAllOptimizationsCallback (T target)

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

protected void postOptimizationCallback (T target, OptimizerEntry<T> 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 (T target)

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

protected void preOptimizationCallback (T target, OptimizerEntry<T> 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.