Package soot.jimple.toolkits.pointer
Class LocalMustAliasAnalysis
- java.lang.Object
-
- soot.toolkits.scalar.AbstractFlowAnalysis<N,A>
-
- soot.toolkits.scalar.FlowAnalysis<N,A>
-
- soot.toolkits.scalar.ForwardFlowAnalysis<Unit,HashMap<Value,Integer>>
-
- soot.jimple.toolkits.pointer.LocalMustAliasAnalysis
-
- Direct Known Subclasses:
StrongLocalMustAliasAnalysis
public class LocalMustAliasAnalysis extends ForwardFlowAnalysis<Unit,HashMap<Value,Integer>>
LocalMustAliasAnalysis attempts to determine if two local variables (at two potentially different program points) must point to the same object. The underlying abstraction is based on global value numbering. See alsoStrongLocalMustAliasAnalysisfor an analysis that soundly treats redefinitions within loops. See Sable TR 2007-8 for details. P.S. The idea behind this analysis and the way it assigns numbers is very similar to what is described in the paper: Lapkowski, C. and Hendren, L. J. 1996. Extended SSA numbering: introducing SSA properties to languages with multi-level pointers. In Proceedings of the 1996 Conference of the Centre For Advanced Studies on Collaborative Research (Toronto, Ontario, Canada, November 12 - 14, 1996). M. Bauer, K. Bennet, M. Gentleman, H. Johnson, K. Lyons, and J. Slonim, Eds. IBM Centre for Advanced Studies Conference. IBM Press, 23. Only major differences: Here we only use primary numbers, no secondary numbers. Further, we use the call graph to determine fields that are not written to in the transitive closure of this method's execution. A third difference is that we assign fixed values toIdentityRefs, because those never change during one execution.- Author:
- Patrick Lam, Eric Bodden
- See Also:
StrongLocalMustAliasAnalysis
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class soot.toolkits.scalar.FlowAnalysis
FlowAnalysis.Flow
-
-
Field Summary
Fields Modifier and Type Field Description protected SootMethodcontainerthe containing methodprotected Set<Value>localsAndFieldRefsThe set of all local variables and field references that we track.protected Map<Unit,Map<Value,Integer>>mergePointToValueToNumbermaps from a merge point (a unit) and a value to the unique value number of that value at this pointprotected intnextNumberthe next value numberprotected Map<Value,Integer>rhsToNumbermaps from right-hand side expressions (non-locals) to value numbers-
Fields inherited from class soot.toolkits.scalar.FlowAnalysis
filterUnitToAfterFlow, unitToAfterFlow
-
Fields inherited from class soot.toolkits.scalar.AbstractFlowAnalysis
filterUnitToBeforeFlow, graph, unitToBeforeFlow
-
-
Constructor Summary
Constructors Constructor Description LocalMustAliasAnalysis(UnitGraph g)Creates a newLocalMustAliasAnalysistracking local variables.LocalMustAliasAnalysis(UnitGraph g, boolean tryTrackFieldAssignments)Creates a newLocalMustAliasAnalysis.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcopy(HashMap<Value,Integer> sourceMap, HashMap<Value,Integer> destMap)Creates a copy of thesourceflow object indest.protected HashMap<Value,Integer>entryInitialFlow()Initial most conservative value: We leave it away to save memory, implicitly UNKNOWN.protected voidflowThrough(HashMap<Value,Integer> in, Unit u, HashMap<Value,Integer> out)Given the merge of theoutsets, compute theinset fors(or in to out, depending on direction).booleanhasInfoOn(Local l, Stmt s)Returns true if this analysis has any information about local l at statement s.StringinstanceKeyString(Local l, Stmt s)Returns a string (natural number) representation of the instance key associated with l at statement s ornullif there is no such key associated.protected voidmerge(HashMap<Value,Integer> in1, HashMap<Value,Integer> in2, HashMap<Value,Integer> out)Compute the merge of thein1andin2sets, putting the result intoout.protected voidmerge(Unit succUnit, HashMap<Value,Integer> inMap1, HashMap<Value,Integer> inMap2, HashMap<Value,Integer> outMap)Merges in1 and in2 into out, just before node succNode.booleanmustAlias(Local l1, Stmt s1, Local l2, Stmt s2)protected HashMap<Value,Integer>newInitialFlow()Initial bottom value: objects have no definitions.static intparameterRefNumber(ParameterRef r)static intthisRefNumber()-
Methods inherited from class soot.toolkits.scalar.ForwardFlowAnalysis
doAnalysis, isForward
-
Methods inherited from class soot.toolkits.scalar.FlowAnalysis
copyFreshToExisting, getFlow, getFlowAfter, getFlowBefore, omissible
-
Methods inherited from class soot.toolkits.scalar.AbstractFlowAnalysis
mergeInto, treatTrapHandlersAsEntries
-
-
-
-
Field Detail
-
localsAndFieldRefs
protected Set<Value> localsAndFieldRefs
The set of all local variables and field references that we track. This set contains objects of typeLocaland, if tryTrackFieldAssignments is enabled, it may also containEquivalentValues ofFieldRefs. If so, these field references are to be tracked on the same way asLocals are.
-
rhsToNumber
protected transient Map<Value,Integer> rhsToNumber
maps from right-hand side expressions (non-locals) to value numbers
-
mergePointToValueToNumber
protected transient Map<Unit,Map<Value,Integer>> mergePointToValueToNumber
maps from a merge point (a unit) and a value to the unique value number of that value at this point
-
nextNumber
protected int nextNumber
the next value number
-
container
protected SootMethod container
the containing method
-
-
Constructor Detail
-
LocalMustAliasAnalysis
public LocalMustAliasAnalysis(UnitGraph g)
Creates a newLocalMustAliasAnalysistracking local variables.
-
LocalMustAliasAnalysis
public LocalMustAliasAnalysis(UnitGraph g, boolean tryTrackFieldAssignments)
Creates a newLocalMustAliasAnalysis. If tryTrackFieldAssignments, we run an interprocedural side-effects analysis to determine which fields are (transitively) written to by this method. All fields which that are not written to are tracked just as local variables. This semantics is sound for single-threaded programs.
-
-
Method Detail
-
merge
protected void merge(Unit succUnit, HashMap<Value,Integer> inMap1, HashMap<Value,Integer> inMap2, HashMap<Value,Integer> outMap)
Description copied from class:AbstractFlowAnalysisMerges in1 and in2 into out, just before node succNode. By default, this method just calls merge(A,A,A), ignoring the node.
-
flowThrough
protected void flowThrough(HashMap<Value,Integer> in, Unit u, HashMap<Value,Integer> out)
Description copied from class:FlowAnalysisGiven the merge of theoutsets, compute theinset fors(or in to out, depending on direction). This function often causes confusion, because the same interface is used for both forward and backward flow analyses. The first parameter is always the argument to the flow function (i.e. it is the "in" set in a forward analysis and the "out" set in a backward analysis), and the third parameter is always the result of the flow function (i.e. it is the "out" set in a forward analysis and the "in" set in a backward analysis).- Specified by:
flowThroughin classFlowAnalysis<Unit,HashMap<Value,Integer>>- Parameters:
in- the input flowu- the current nodeout- the returned flow
-
thisRefNumber
public static int thisRefNumber()
-
parameterRefNumber
public static int parameterRefNumber(ParameterRef r)
-
copy
protected void copy(HashMap<Value,Integer> sourceMap, HashMap<Value,Integer> destMap)
Description copied from class:AbstractFlowAnalysisCreates a copy of thesourceflow object indest.
-
entryInitialFlow
protected HashMap<Value,Integer> entryInitialFlow()
Initial most conservative value: We leave it away to save memory, implicitly UNKNOWN.- Overrides:
entryInitialFlowin classAbstractFlowAnalysis<Unit,HashMap<Value,Integer>>
-
newInitialFlow
protected HashMap<Value,Integer> newInitialFlow()
Initial bottom value: objects have no definitions.- Specified by:
newInitialFlowin classAbstractFlowAnalysis<Unit,HashMap<Value,Integer>>
-
instanceKeyString
public String instanceKeyString(Local l, Stmt s)
Returns a string (natural number) representation of the instance key associated with l at statement s ornullif there is no such key associated.- Parameters:
l- any local of the associated methods- the statement at which to check
-
hasInfoOn
public boolean hasInfoOn(Local l, Stmt s)
Returns true if this analysis has any information about local l at statement s. In particular, it is safe to pass in locals/statements that are not even part of the right method. In those casesfalsewill be returned. Permits s to benull, in which casefalsewill be returned.
-
mustAlias
public boolean mustAlias(Local l1, Stmt s1, Local l2, Stmt s2)
- Returns:
- true if values of l1 (at s1) and l2 (at s2) have the exact same object IDs, i.e. at statement s1 the variable l1 must point to the same object as l2 at s2.
-
merge
protected void merge(HashMap<Value,Integer> in1, HashMap<Value,Integer> in2, HashMap<Value,Integer> out)
Description copied from class:AbstractFlowAnalysisCompute the merge of thein1andin2sets, putting the result intoout. The behavior of this function depends on the implementation ( it may be necessary to check whetherin1andin2are equal or aliased ). Used by the doAnalysis method.
-
-