|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object vasco.InterProceduralAnalysis<M,N,A>
M
- the type of a methodN
- the type of a node in the CFGA
- the type of a data flow valuepublic abstract class InterProceduralAnalysis<M,N,A>
A generic inter-procedural analysis which is fully context-sensitive.
This class is a base for forward and backward inter-procedural analysis classes. This inter-procedural analysis framework is fully context sensitive even in the presence of recursion and uses data flow values reaching a method to distinguish contexts.
Context
,
ContextTransitionTable
,
CallSite
Field Summary | |
---|---|
protected Map<M,List<Context<M,N,A>>> |
contexts
A mapping from methods to a list of contexts for quick lookups. |
protected ContextTransitionTable<M,N,A> |
contextTransitions
A record of transitions from calling context and call-site to called method and called context. |
protected boolean |
freeResultsOnTheFly
A flag, if set, directs the analysis to free memory storing data flow values of individual statements once a context has been analysed and would not be required to be re-analysed. |
protected boolean |
reverse
true if the direction of analysis is backward, or false if it is forward. |
protected boolean |
verbose
Whether to print information about contexts. |
protected NavigableSet<Context<M,N,A>> |
worklist
A work-list of contexts to process. |
Constructor Summary | |
---|---|
InterProceduralAnalysis(boolean reverse)
Constructs a new inter-procedural analysis. |
Method Summary | |
---|---|
abstract A |
boundaryValue(M entryPoint)
Returns the initial data flow value at the program entry points. |
abstract A |
copy(A src)
Returns a copy of the given data flow value. |
abstract void |
doAnalysis()
Performs the actual data flow analysis. |
Set<CallSite<M,N,A>> |
getCallers(Context<M,N,A> target)
Returns the callers of a value context. |
Context<M,N,A> |
getContext(M method,
A value)
Retrieves a particular value context if it has been constructed. |
List<Context<M,N,A>> |
getContexts(M method)
Returns a list of value contexts constructed for a given method. |
ContextTransitionTable<M,N,A> |
getContextTransitionTable()
Returns a reference to the context transition table used by this analysis. |
DataFlowSolution<N,A> |
getMeetOverValidPathsSolution()
Returns a meet-over-valid-paths solution by merging data flow values across contexts for each program point. |
Set<M> |
getMethods()
Returns all methods for which at least one context was created. |
Map<M,Context<M,N,A>> |
getTargets(CallSite<M,N,A> callSite)
Returns the target of a call-site. |
abstract A |
meet(A op1,
A op2)
Returns the meet of two data flow values. |
abstract ProgramRepresentation<M,N> |
programRepresentation()
Returns a program representation on top of which the inter-procedural analysis runs. |
abstract A |
topValue()
Returns the default data flow value (lattice top). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final NavigableSet<Context<M,N,A>> worklist
protected final Map<M,List<Context<M,N,A>>> contexts
protected final ContextTransitionTable<M,N,A> contextTransitions
protected final boolean reverse
protected boolean freeResultsOnTheFly
This setting is only useful for analyses that aggregate secondary results on the fly (e.g. call graph analysis that can do away with points-to information once the calls for a particular context have been resolved). This is not safe for use in analyses whose results will be directly used later (e.g. liveness analysis).
Memory is freed when a context is removed from the work-list and no context reachable from it in the transition table is also on the work-list. This ensures that the removed context will not be added again on the work-list for re-analysis of any statement.
Note that the data flow values at the entry/exit of the context are not freed, and hence it is still used to terminate recursion or as a cache hit for arbitrary call sites with same values.
The default value for this flag is false.
protected boolean verbose
Constructor Detail |
---|
public InterProceduralAnalysis(boolean reverse)
reverse
- true if the analysis is in the reverse direction,
false if it is in the forward directionMethod Detail |
---|
public abstract A boundaryValue(M entryPoint)
Note that this method will be called exactly once per entry point specified by the program representation.
entryPoint
- an entry point specified by the program representation
ProgramRepresentation.getEntryPoints()
public abstract A copy(A src)
src
- the data flow value to copy
public abstract void doAnalysis()
A work-list of contexts is maintained, each with it's own work-list of CFG nodes to process. For each node removed from the work-list of the newest context, the meet of values along incoming edges (in the direction of analysis) is computed and then the flow function is processed depending on whether the node contains a call or not. If the resulting data flow value has changed, then nodes along outgoing edges (in the direction of analysis) are also added to the work-list.
Analysis starts with the context for the program entry points with the given boundary values and ends when the work-list is empty.
See the SOAP '13 paper for the full algorithm in Figure 1.
public Set<CallSite<M,N,A>> getCallers(Context<M,N,A> target)
target
- the value context
public Context<M,N,A> getContext(M method, A value)
method
- the method whose value context to findvalue
- the data flow value at the entry (forward flow) or exit
(backward flow) of the method
public List<Context<M,N,A>> getContexts(M method)
method
- the method whose contexts to retrieve
public ContextTransitionTable<M,N,A> getContextTransitionTable()
public DataFlowSolution<N,A> getMeetOverValidPathsSolution()
This method should not be invoked if the flag
freeResultsOnTheFly
had been set during analysis.
public Set<M> getMethods()
public Map<M,Context<M,N,A>> getTargets(CallSite<M,N,A> callSite)
callSite
- the call-site whose targets to retrieve
public abstract A meet(A op1, A op2)
op1
- the first operandop2
- the second operand
public abstract ProgramRepresentation<M,N> programRepresentation()
public abstract A topValue()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |