public class LocalMustAliasAnalysis extends ForwardFlowAnalysis<Unit,java.util.HashMap<Value,java.lang.Integer>>
StrongLocalMustAliasAnalysis
for 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
to IdentityRef
s, because those never change during one execution.StrongLocalMustAliasAnalysis
FlowAnalysis.Flow
Modifier and Type | Field and Description |
---|---|
protected SootMethod |
container
the containing method
|
protected java.util.Set<Value> |
localsAndFieldRefs
The set of all local variables and field references that we track.
|
protected java.util.Map<Unit,java.util.Map<Value,java.lang.Integer>> |
mergePointToValueToNumber
maps from a merge point (a unit) and a value to the unique value number of that value at this point
|
protected int |
nextNumber
the next value number
|
protected java.util.Map<Value,java.lang.Integer> |
rhsToNumber
maps from right-hand side expressions (non-locals) to value numbers
|
filterUnitToAfterFlow, unitToAfterFlow
filterUnitToBeforeFlow, graph, unitToBeforeFlow
Constructor and Description |
---|
LocalMustAliasAnalysis(UnitGraph g)
Creates a new
LocalMustAliasAnalysis tracking local variables. |
LocalMustAliasAnalysis(UnitGraph g,
boolean tryTrackFieldAssignments)
Creates a new
LocalMustAliasAnalysis . |
Modifier and Type | Method and Description |
---|---|
protected void |
copy(java.util.HashMap<Value,java.lang.Integer> sourceMap,
java.util.HashMap<Value,java.lang.Integer> destMap)
Creates a copy of the
source flow object in dest . |
protected java.util.HashMap<Value,java.lang.Integer> |
entryInitialFlow()
Initial most conservative value: We leave it away to save memory, implicitly UNKNOWN.
|
protected void |
flowThrough(java.util.HashMap<Value,java.lang.Integer> in,
Unit u,
java.util.HashMap<Value,java.lang.Integer> out)
Given the merge of the
out sets, compute the in
set for s (or in to out, depending on direction). |
boolean |
hasInfoOn(Local l,
Stmt s)
Returns true if this analysis has any information about local l
at statement s.
|
java.lang.String |
instanceKeyString(Local l,
Stmt s)
Returns a string (natural number) representation of the instance key associated with l
at statement s or
null if there is no such key associated. |
protected void |
merge(java.util.HashMap<Value,java.lang.Integer> in1,
java.util.HashMap<Value,java.lang.Integer> in2,
java.util.HashMap<Value,java.lang.Integer> out)
Compute the merge of the
in1 and in2 sets, putting the result into out . |
protected void |
merge(Unit succUnit,
java.util.HashMap<Value,java.lang.Integer> inMap1,
java.util.HashMap<Value,java.lang.Integer> inMap2,
java.util.HashMap<Value,java.lang.Integer> outMap)
Merges in1 and in2 into out, just before node succNode.
|
boolean |
mustAlias(Local l1,
Stmt s1,
Local l2,
Stmt s2) |
protected java.util.HashMap<Value,java.lang.Integer> |
newInitialFlow()
Initial bottom value: objects have no definitions.
|
static int |
parameterRefNumber(ParameterRef r) |
static int |
thisRefNumber() |
doAnalysis, isForward
getFlow, getFlowAfter, getFlowBefore, omissible
mergeInto, treatTrapHandlersAsEntries
protected java.util.Set<Value> localsAndFieldRefs
Local
and, if tryTrackFieldAssignments is
enabled, it may also contain EquivalentValue
s of FieldRef
s.
If so, these field references are to be tracked on the same way as Local
s are.protected transient java.util.Map<Value,java.lang.Integer> rhsToNumber
protected transient java.util.Map<Unit,java.util.Map<Value,java.lang.Integer>> mergePointToValueToNumber
protected int nextNumber
protected SootMethod container
public LocalMustAliasAnalysis(UnitGraph g)
LocalMustAliasAnalysis
tracking local variables.public LocalMustAliasAnalysis(UnitGraph g, boolean tryTrackFieldAssignments)
LocalMustAliasAnalysis
. 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.protected void merge(Unit succUnit, java.util.HashMap<Value,java.lang.Integer> inMap1, java.util.HashMap<Value,java.lang.Integer> inMap2, java.util.HashMap<Value,java.lang.Integer> outMap)
AbstractFlowAnalysis
merge
in class AbstractFlowAnalysis<Unit,java.util.HashMap<Value,java.lang.Integer>>
protected void flowThrough(java.util.HashMap<Value,java.lang.Integer> in, Unit u, java.util.HashMap<Value,java.lang.Integer> out)
FlowAnalysis
out
sets, compute the in
set for s
(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).flowThrough
in class FlowAnalysis<Unit,java.util.HashMap<Value,java.lang.Integer>>
in
- the input flowu
- the current nodeout
- the returned flowpublic static int thisRefNumber()
public static int parameterRefNumber(ParameterRef r)
protected void copy(java.util.HashMap<Value,java.lang.Integer> sourceMap, java.util.HashMap<Value,java.lang.Integer> destMap)
AbstractFlowAnalysis
source
flow object in dest
.copy
in class AbstractFlowAnalysis<Unit,java.util.HashMap<Value,java.lang.Integer>>
protected java.util.HashMap<Value,java.lang.Integer> entryInitialFlow()
entryInitialFlow
in class AbstractFlowAnalysis<Unit,java.util.HashMap<Value,java.lang.Integer>>
protected java.util.HashMap<Value,java.lang.Integer> newInitialFlow()
newInitialFlow
in class AbstractFlowAnalysis<Unit,java.util.HashMap<Value,java.lang.Integer>>
public java.lang.String instanceKeyString(Local l, Stmt s)
null
if there is no such key associated.l
- any local of the associated methods
- the statement at which to checkpublic boolean hasInfoOn(Local l, Stmt s)
false
will be returned.
Permits s to be null
, in which case false
will be returned.public boolean mustAlias(Local l1, Stmt s1, Local l2, Stmt s2)
protected void merge(java.util.HashMap<Value,java.lang.Integer> in1, java.util.HashMap<Value,java.lang.Integer> in2, java.util.HashMap<Value,java.lang.Integer> out)
AbstractFlowAnalysis
in1
and in2
sets, putting the result into out
.
The behavior of this function depends on the implementation ( it may be necessary to check whether
in1
and in2
are equal or aliased ).
Used by the doAnalysis method.merge
in class AbstractFlowAnalysis<Unit,java.util.HashMap<Value,java.lang.Integer>>