N
- The type of nodes in the interprocedural control-flow graph.D
- The type of data-flow facts to be computed by the tabulation problem.M
- The type of objects used to represent methods.V
- The type of values to be computed along flow edges.I
- The type of inter-procedural control-flow graph being used.public class IDESolver<N,D,M,V,I extends InterproceduralCFG<N,M>>
extends java.lang.Object
IDETabulationProblem
as described in the 1996 paper by Sagiv,
Horwitz and Reps. To solve the problem, call solve()
. Results can then be
queried by using resultAt(Object, Object)
and resultsAt(Object)
.
Note that this solver and its data structures internally use mostly LinkedHashSet
s
instead of normal HashSet
s to fix the iteration order as much as possible. This
is to produce, as much as possible, reproducible benchmarking results. We have found
that the iteration order can matter a lot in terms of speed.Constructor and Description |
---|
IDESolver(IDETabulationProblem<N,D,M,V,I> tabulationProblem)
Creates a solver for the given problem, which caches flow functions and edge functions.
|
IDESolver(IDETabulationProblem<N,D,M,V,I> tabulationProblem,
CacheBuilder flowFunctionCacheBuilder,
CacheBuilder edgeFunctionCacheBuilder)
Creates a solver for the given problem, constructing caches with the given
CacheBuilder . |
Modifier and Type | Method and Description |
---|---|
protected void |
addIncoming(N sP,
D d3,
N n,
D d2) |
protected void |
awaitCompletionComputeValuesAndShutdown()
Awaits the completion of the exploded super graph.
|
protected java.util.Set<D> |
computeCallFlowFunction(FlowFunction<D> callFlowFunction,
D d1,
D d2)
Computes the call flow function for the given call-site abstraction
|
protected java.util.Set<D> |
computeCallToReturnFlowFunction(FlowFunction<D> callToReturnFlowFunction,
D d1,
D d2)
Computes the call-to-return flow function for the given call-site
abstraction
|
protected java.util.Set<D> |
computeNormalFlowFunction(FlowFunction<D> flowFunction,
D d1,
D d2)
Computes the normal flow function for the given set of start and end
abstractions-
|
protected java.util.Set<D> |
computeReturnFlowFunction(FlowFunction<D> retFunction,
D d1,
D d2,
N callSite,
java.util.Set<D> callerSideDs)
Computes the return flow function for the given set of caller-side
abstractions.
|
protected java.util.Set<<any>> |
endSummary(N sP,
D d3) |
protected java.lang.String |
getDebugName()
Returns a String used to identify the output of this solver in debug mode.
|
protected CountingThreadPoolExecutor |
getExecutor()
Factory method for this solver's thread-pool executor.
|
protected java.util.Map<N,java.util.Set<D>> |
incoming(D d1,
N sP) |
protected V |
joinValueAt(N unit,
D fact,
V curr,
V newVal) |
void |
printStats() |
protected void |
processExit(PathEdge<N,D> edge)
Lines 21-32 of the algorithm.
|
protected void |
propagate(D sourceVal,
N target,
D targetVal,
EdgeFunction<V> f,
N relatedCallSite,
boolean isUnbalancedReturn)
Propagates the flow further down the exploded super graph, merging any edge function that might
already have been computed for targetVal at target.
|
protected void |
propagateUnbalancedReturnFlow(N retSiteC,
D targetVal,
EdgeFunction<V> edgeFunction,
N relatedCallSite) |
protected D |
restoreContextOnReturnedFact(N callSite,
D d4,
D d5)
This method will be called for each incoming edge and can be used to
transfer knowledge from the calling edge to the returning edge, without
affecting the summary edges at the callee.
|
V |
resultAt(N stmt,
D value)
Returns the V-type result for the given value at the given statement.
|
java.util.Map<D,V> |
resultsAt(N stmt)
Returns the resulting environment for the given statement.
|
protected void |
scheduleEdgeProcessing(PathEdge<N,D> edge)
Dispatch the processing of a given edge.
|
void |
solve()
Runs the solver on the configured problem.
|
protected void |
submitInitialSeeds()
Schedules the processing of initial seeds, initiating the analysis.
|
public static <any> DEFAULT_CACHE_BUILDER
protected static final Logger logger
protected <any> computedIntraPEdges
protected <any> computedInterPEdges
public static final boolean DEBUG
protected CountingThreadPoolExecutor executor
protected int numThreads
protected final JumpFunctions<N,D,V> jumpFn
protected final I extends InterproceduralCFG<N,M> icfg
protected final <any> endSummary
protected final <any> incoming
protected final java.util.Set<N> unbalancedRetSites
protected final FlowFunctions<N,D,M> flowFunctions
protected final EdgeFunctions<N,D,M,V> edgeFunctions
protected final JoinLattice<V> valueLattice
protected final EdgeFunction<V> allTop
protected final <any> val
public long flowFunctionApplicationCount
public long flowFunctionConstructionCount
public long propagationCount
public long durationFlowFunctionConstruction
public long durationFlowFunctionApplication
protected final D zeroValue
protected final FlowFunctionCache<N,D,M> ffCache
protected final EdgeFunctionCache<N,D,M,V> efCache
protected final boolean followReturnsPastSeeds
protected final boolean computeValues
public IDESolver(IDETabulationProblem<N,D,M,V,I> tabulationProblem)
solve()
.public IDESolver(IDETabulationProblem<N,D,M,V,I> tabulationProblem, CacheBuilder flowFunctionCacheBuilder, CacheBuilder edgeFunctionCacheBuilder)
CacheBuilder
. The solver must then be started by calling
solve()
.flowFunctionCacheBuilder
- A valid CacheBuilder
or null
if no caching is to be used for flow functions.edgeFunctionCacheBuilder
- A valid CacheBuilder
or null
if no caching is to be used for edge functions.public void solve()
protected void submitInitialSeeds()
solve()
should be called instead.protected void awaitCompletionComputeValuesAndShutdown()
protected void scheduleEdgeProcessing(PathEdge<N,D> edge)
edge
- the edge to processprotected java.util.Set<D> computeCallFlowFunction(FlowFunction<D> callFlowFunction, D d1, D d2)
callFlowFunction
- The call flow function to computed1
- The abstraction at the current method's start node.d2
- The abstraction at the call siteprotected java.util.Set<D> computeCallToReturnFlowFunction(FlowFunction<D> callToReturnFlowFunction, D d1, D d2)
callToReturnFlowFunction
- The call-to-return flow function to
computed1
- The abstraction at the current method's start node.d2
- The abstraction at the call siteprotected void processExit(PathEdge<N,D> edge)
edge
- an edge whose target node resembles a method exitsprotected void propagateUnbalancedReturnFlow(N retSiteC, D targetVal, EdgeFunction<V> edgeFunction, N relatedCallSite)
protected D restoreContextOnReturnedFact(N callSite, D d4, D d5)
callSite
- d4
- Fact stored with the incoming edge, i.e., present at the
caller sided5
- Fact that originally should be propagated to the caller.protected java.util.Set<D> computeReturnFlowFunction(FlowFunction<D> retFunction, D d1, D d2, N callSite, java.util.Set<D> callerSideDs)
retFunction
- The return flow function to computed1
- The abstraction at the beginning of the calleed2
- The abstraction at the exit node in the calleecallSite
- The call sitecallerSideDs
- The abstractions at the call siteprotected java.util.Set<D> computeNormalFlowFunction(FlowFunction<D> flowFunction, D d1, D d2)
flowFunction
- The normal flow function to computed1
- The abstraction at the method's start noded1
- The abstraction at the current nodeprotected void propagate(D sourceVal, N target, D targetVal, EdgeFunction<V> f, N relatedCallSite, boolean isUnbalancedReturn)
sourceVal
- the source value of the propagated summary edgetarget
- the target statementtargetVal
- the target value at the target statementf
- the new edge function computed from (s0,sourceVal) to (target,targetVal)relatedCallSite
- for call and return flows the related call statement, null
otherwise
(this value is not used within this implementation but may be useful for subclasses of IDESolver
)isUnbalancedReturn
- true
if this edge is propagating an unbalanced return
(this value is not used within this implementation but may be useful for subclasses of IDESolver
)public V resultAt(N stmt, D value)
public java.util.Map<D,V> resultsAt(N stmt)
protected CountingThreadPoolExecutor getExecutor()
protected java.lang.String getDebugName()
public void printStats()