Package soot.shimple.internal
Class ShimpleBodyBuilder
- java.lang.Object
-
- soot.shimple.internal.ShimpleBodyBuilder
-
public class ShimpleBodyBuilder extends Object
This class does the real high-level work. It takes a Jimple body or Jimple/Shimple hybrid body and produces pure Shimple.The work is done in two main steps:
- Trivial Phi nodes are added.
- A renaming algorithm is executed.
This class can also translate out of Shimple by producing an equivalent Jimple body with all Phi nodes removed.
Note that this is an internal class, understanding it should not be necessary from a user point-of-view and relying on it directly is not recommended.
- Author:
- Navindra Umanee
- See Also:
ShimpleBody, Efficiently Computing Static Single Assignment Form and the Control Dependence Graph
-
-
Field Summary
Fields Modifier and Type Field Description protected int[]assignmentCountersprotected ShimpleBodybodyprotected Stack<Integer>[]namingStacksprotected Map<String,Local>newLocalsprotected Map<Local,Local>newLocalsToOldLocalprotected ShimpleOptionsoptionsprotected List<Local>origLocalsPhiNodeManagerphiPiNodeManagerpiprotected ShimpleFactorysf
-
Constructor Summary
Constructors Constructor Description ShimpleBodyBuilder(ShimpleBody body)Transforms the provided body to pure SSA form.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voideliminatePhiNodes()Remove Phi nodes from current body, high probability this destroys SSA form.voideliminatePiNodes()protected LocalfetchNewLocal(Local local, Integer subscript)Clever convenience function to fetch or create new Local's given a Local and the desired subscript.protected intindexOfLocal(Value local)Convenient function that maps new Locals to the originating Local, and finds the appropriate array index into the naming structures.static StringmakeUniqueLocalName(String dupName, Set<String> localNames)Given a set of Strings, return a new name for dupName that is not currently in the set.voidmakeUniqueLocalNames()Make sure the locals in the given body all have unique String names.voidpostElimOpt()voidpreElimOpt()voidrenameLocals()Variable Renaming Algorithm from Cytron et al 91, P26-8, implemented in various bits and pieces by the next functions.voidrenameLocalsSearch(Block block)Driven by renameLocals().static voidsetSeparator(String sep)voidtransform()voidupdate()
-
-
-
Field Detail
-
body
protected final ShimpleBody body
-
options
protected final ShimpleOptions options
-
sf
protected final ShimpleFactory sf
-
assignmentCounters
protected int[] assignmentCounters
-
phi
public final PhiNodeManager phi
-
pi
public final PiNodeManager pi
-
-
Constructor Detail
-
ShimpleBodyBuilder
public ShimpleBodyBuilder(ShimpleBody body)
Transforms the provided body to pure SSA form.
-
-
Method Detail
-
update
public void update()
-
transform
public void transform()
-
preElimOpt
public void preElimOpt()
-
postElimOpt
public void postElimOpt()
-
eliminatePhiNodes
public void eliminatePhiNodes()
Remove Phi nodes from current body, high probability this destroys SSA form.Dead code elimination + register aggregation are performed as recommended by Cytron. The Aggregator looks like it could use some improvements.
- See Also:
ShimpleOptions
-
eliminatePiNodes
public void eliminatePiNodes()
-
renameLocals
public void renameLocals()
Variable Renaming Algorithm from Cytron et al 91, P26-8, implemented in various bits and pieces by the next functions. Must be called after trivial nodes have been added.
-
renameLocalsSearch
public void renameLocalsSearch(Block block)
Driven by renameLocals().
-
fetchNewLocal
protected Local fetchNewLocal(Local local, Integer subscript)
Clever convenience function to fetch or create new Local's given a Local and the desired subscript.
-
indexOfLocal
protected int indexOfLocal(Value local)
Convenient function that maps new Locals to the originating Local, and finds the appropriate array index into the naming structures.
-
makeUniqueLocalNames
public void makeUniqueLocalNames()
Make sure the locals in the given body all have unique String names. Renaming is done if necessary.
-
makeUniqueLocalName
public static String makeUniqueLocalName(String dupName, Set<String> localNames)
Given a set of Strings, return a new name for dupName that is not currently in the set.
-
setSeparator
public static void setSeparator(String sep)
-
-