soot.shimple.toolkits.scalar
Class SConstantPropagatorAndFolder

java.lang.Object
  extended by soot.Transformer
      extended by soot.BodyTransformer
          extended by soot.shimple.toolkits.scalar.SConstantPropagatorAndFolder

public class SConstantPropagatorAndFolder
extends BodyTransformer

A powerful constant propagator and folder based on an algorithm sketched by Cytron et al that takes conditional control flow into account. This optimization demonstrates some of the benefits of SSA -- particularly the fact that Phi nodes represent natural merge points in the control flow.

Author:
Navindra Umanee
See Also:
Efficiently Computing Static Single Assignment Form and the Control Dependence Graph

Field Summary
protected  boolean debug
           
protected  ShimpleBody sb
           
 
Constructor Summary
SConstantPropagatorAndFolder(Singletons.Global g)
           
 
Method Summary
protected  void internalTransform(Body b, String phaseName, Map options)
          This method is called to perform the transformation itself.
protected  void propagateResults(Map<Local,Constant> localToConstant)
          Propagates constants to the definition and uses of the relevant locals given a mapping.
protected  void removeStmts(List<IfStmt> deadStmts)
          Removes the given list of fall through IfStmts from the body.
protected  void replaceStmts(Map<Stmt,GotoStmt> stmtsToReplace)
          Replaces conditional branches by unconditional branches as given by the mapping.
static SConstantPropagatorAndFolder v()
           
 
Methods inherited from class soot.BodyTransformer
transform, transform, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sb

protected ShimpleBody sb

debug

protected boolean debug
Constructor Detail

SConstantPropagatorAndFolder

public SConstantPropagatorAndFolder(Singletons.Global g)
Method Detail

v

public static SConstantPropagatorAndFolder v()

internalTransform

protected void internalTransform(Body b,
                                 String phaseName,
                                 Map options)
Description copied from class: BodyTransformer
This method is called to perform the transformation itself. It is declared abstract; subclasses must implement this method by making it the entry point to their actual Body transformation.

Specified by:
internalTransform in class BodyTransformer
Parameters:
b - the body on which to apply the transformation
phaseName - the phasename for this transform; not typically used by implementations.
options - the actual computed options; a combination of default options and Scene specified options.

propagateResults

protected void propagateResults(Map<Local,Constant> localToConstant)
Propagates constants to the definition and uses of the relevant locals given a mapping. Notice that we use the Shimple implementation of LocalDefs and LocalUses.


removeStmts

protected void removeStmts(List<IfStmt> deadStmts)
Removes the given list of fall through IfStmts from the body.


replaceStmts

protected void replaceStmts(Map<Stmt,GotoStmt> stmtsToReplace)
Replaces conditional branches by unconditional branches as given by the mapping.