public abstract class

AbstractEExpressionOptimizer

extends AbstractEOptimizer
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.AbstractPlugin
     ↳ com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.AbstractOptimizer<T>
       ↳ com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.opt.AbstractEOptimizer
         ↳ com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.opt.AbstractEExpressionOptimizer

Class Overview

Skeleton for a top-down, recursive, IEGeneric optimizer. Expressions are provided in depth-first, pre-order way: parent expressions are provided before their constituting children.

By default, IEStatements are not candidates for optimization (although they can be). Generally, IEStatements should be optimized via the use an AbstractEStatementOptimizer.

Summary

Nested Classes
class AbstractEExpressionOptimizer.EOR Optimized Expression  
[Expand]
Inherited Constants
From interface com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.IOptimizer
Fields
protected boolean skipLeftSideOfAssignment
protected boolean skipStatementProcessing
[Expand]
Inherited Fields
From class com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.opt.AbstractEOptimizer
From class com.pnfsoftware.jeb.core.units.code.asm.decompiler.opt.AbstractOptimizer
Public Constructors
AbstractEExpressionOptimizer()
AbstractEExpressionOptimizer(DataChainsUpdatePolicy dataChainsUpdatePolicy)
AbstractEExpressionOptimizer(IERoutineContext ctx, DataChainsUpdatePolicy dataChainsUpdatePolicy)
Public Methods
int perform(boolean updateDFA)
Perform the optimization pass.
Protected Methods
IEGeneric doSubstitution(IEGeneric e, SubstitutionDefinition... substitutions)
Attempt to apply the first matching SubstitutionDefinition on an IEGeneric expression.
abstract AbstractEExpressionOptimizer.EOR optimizeExpression(IEGeneric e)
Attempt to optimize expressions.
[Expand]
Inherited Methods
From class com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.opt.AbstractEOptimizer
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.opt.IOptimizer

Fields

protected boolean skipLeftSideOfAssignment

protected boolean skipStatementProcessing

Public Constructors

public AbstractEExpressionOptimizer ()

public AbstractEExpressionOptimizer (DataChainsUpdatePolicy dataChainsUpdatePolicy)

public AbstractEExpressionOptimizer (IERoutineContext ctx, DataChainsUpdatePolicy dataChainsUpdatePolicy)

Public Methods

public int perform (boolean updateDFA)

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.

Note: in what scenario would you want when to use perform(false) ? one example is to optimize performances when chain-calling optimizers in a master optimizer for example. TODO: describe one scenario in detail.

Parameters
updateDFA if true, update data chains according to the optimizer's policy; if false, the optimizer should not perform final DFA computations if needed
Returns
  • the number of optimizations performed; if negative, an error has occurred and the optimizing process should be aborted

Protected Methods

protected IEGeneric doSubstitution (IEGeneric e, SubstitutionDefinition... substitutions)

Attempt to apply the first matching SubstitutionDefinition on an IEGeneric expression.

Parameters
e the target expression to be matched and modified
substitutions a list of candidate substitutions
Returns
  • null if no substitution was performed, else the new expression

protected abstract AbstractEExpressionOptimizer.EOR optimizeExpression (IEGeneric e)

Attempt to optimize expressions. Sub-expressions may be examined. The implementor should not attempt to modify parent or cousins expressions.

Returns
  • the new (optimized) expression as well as DFA update hints, or null if the expression could not be optimized