Class PropagationCallGraphBuilder
java.lang.Object
com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder
- All Implemented Interfaces:
CallGraphBuilder<InstanceKey>
- Direct Known Subclasses:
AbstractRTABuilder
,SSAPropagationCallGraphBuilder
public abstract class PropagationCallGraphBuilder
extends Object
implements CallGraphBuilder<InstanceKey>
This abstract base class provides the general algorithm for a call graph builder that relies on
propagation through an iterative dataflow solver
TODO: This implementation currently keeps all points to sets live ... even those for local variables that do not span interprocedural boundaries. This may be too space-inefficient .. we can consider recomputing local sets on demand.
-
Nested Class Summary
Modifier and TypeClassDescriptionfinal class
Binary op: <dummy>:= ArrayLoad( <arrayref>) Side effect: Creates new equations.final class
Binary op: <dummy>:= ArrayStore( <arrayref>) Side effect: Creates new equations.class
The FilterOperator is a filtered set-union.class
Binary op: <dummy>:= GetField( <ref>) Side effect: Creates new equations.final class
Update the points-to-set for an array contents to include a particular instance key.final class
Update the points-to-set for a field to include a particular instance key.protected class
protected static class
class
Operator that represents a putfieldstatic final class
A pointer key that delegates to an untyped variant, but adds a type filter -
Field Summary
Modifier and TypeFieldDescriptionstatic final com.ibm.wala.ipa.callgraph.propagation.AssignOperator
Singleton operator for assignmentsprotected final ExplicitCallGraph
The call graph under constructionfinal IClassHierarchy
Governing class hierarchyprotected ContextSelector
A context selector which may use information derived from the propagation-based dataflow.protected static final boolean
protected final Set
<CallSiteReference> Set of calls (CallSiteReferences) that are created by entrypointssingleton operator for filterprotected InstanceKeyFactory
An object that abstracts how to model instances in the heap.protected final PropagationCallGraphBuilder.InverseFilterOperator
singleton operator for inverse filterprotected final AnalysisOptions
Special rules for bypassing Java callsprotected PointerKeyFactory
Meta-data regarding how pointers are modeledprotected PropagationSystem
The system of constraints used to build this graph -
Constructor Summary
ModifierConstructorDescriptionprotected
PropagationCallGraphBuilder
(IMethod abstractRootMethod, AnalysisOptions options, IAnalysisCacheView cache, PointerKeyFactory pointerKeyFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAssignmentsForCatchPointerKey
(PointerKey exceptionVar, Set<IClass> catchClasses, PointerKey e) Generate a set of constraints to represent assignment to an exception variable in a catch clause.void
addConstraintsFromChangedNode
(CGNode node, MonitorUtil.IProgressMonitor monitor) Add constraints when the interpretation of a node changes (e.g.protected boolean
Add constraints from newly discovered nodes.protected abstract boolean
addConstraintsFromNode
(CGNode n, MonitorUtil.IProgressMonitor monitor) Add constraints for a node.protected void
assignInstanceToCatch
(PointerKey exceptionVar, Set<IClass> catchClasses, InstanceKey e) Handle assign of a particular exception instance into an exception variablestatic boolean
catches
(Set<IClass> catchClasses, IClass klass, IClassHierarchy cha) protected ExplicitCallGraph
createEmptyCallGraph
(IMethod abstractRootMethod, AnalysisOptions options) protected void
protected IntSet
filterForClass
(IntSet S, IClass klass) getFilteredPointerKeyForLocal
(CGNode node, int valueNumber, IClass filter) getFilteredPointerKeyForLocal
(CGNode node, int valueNumber, FilteredPointerKey.TypeFilter filter) getFilteredPointerKeyForLocal
(CGNode node, int valueNumber, InstanceKey filter) getInstanceKeyForAllocation
(CGNode node, NewSiteReference allocation) <T> InstanceKey
getInstanceKeyForConstant
(TypeReference type, T S) getInstanceKeyForMetadataObject
(Object obj, TypeReference objType) getInstanceKeyForMultiNewArray
(CGNode node, NewSiteReference allocation, int dim) protected IntSet
getInstanceKeysForClass
(IClass klass) protected MutableIntSet
TODO: expand this API to differentiate between different array indicesgetPointerKeyForInstanceField
(InstanceKey I, IField field) getPointerKeyForLocal
(CGNode node, int valueNumber) protected IPointsToSolver
protected CGNode
getTargetForCall
(CGNode caller, CallSiteReference site, IClass recv, InstanceKey[] iKey) boolean
haveAlreadyVisited
(CGNode node) protected boolean
isJavaLangObject
(IClass klass) makeCallGraph
(AnalysisOptions options) makeCallGraph
(AnalysisOptions options, MonitorUtil.IProgressMonitor monitor) Build a call graph.protected abstract IPointsToSolver
protected PropagationSystem
makeSystem
(AnalysisOptions options) protected void
markAlreadyVisited
(CGNode node) protected void
markChanged
(CGNode node) void
markDiscovered
(CGNode node) record that we've discovered a nodestatic boolean
void
setContextInterpreter
(SSAContextInterpreter interpreter) Subclasses must register the context interpreter before building a call graph.void
setContextSelector
(ContextSelector selector) void
void
protected abstract boolean
protected boolean
wasChanged
(CGNode node)
-
Field Details
-
DEBUG_GENERAL
protected static final boolean DEBUG_GENERAL- See Also:
-
pointerKeyFactory
Meta-data regarding how pointers are modeled -
cha
Governing class hierarchy -
options
Special rules for bypassing Java calls -
entrypointCallSites
Set of calls (CallSiteReferences) that are created by entrypoints -
system
The system of constraints used to build this graph -
callGraph
The call graph under construction -
assignOperator
public static final com.ibm.wala.ipa.callgraph.propagation.AssignOperator assignOperatorSingleton operator for assignments -
filterOperator
singleton operator for filter -
inverseFilterOperator
singleton operator for inverse filter -
contextSelector
A context selector which may use information derived from the propagation-based dataflow. -
instanceKeyFactory
An object that abstracts how to model instances in the heap.
-
-
Constructor Details
-
PropagationCallGraphBuilder
protected PropagationCallGraphBuilder(IMethod abstractRootMethod, AnalysisOptions options, IAnalysisCacheView cache, PointerKeyFactory pointerKeyFactory) - Parameters:
options
- governing call graph construction optionspointerKeyFactory
- factory which embodies pointer abstraction policy
-
-
Method Details
-
getSystem
-
createEmptyCallGraph
protected ExplicitCallGraph createEmptyCallGraph(IMethod abstractRootMethod, AnalysisOptions options) -
isJavaLangObject
- Returns:
- true iff the klass represents java.lang.Object
-
makeCallGraph
public CallGraph makeCallGraph(AnalysisOptions options) throws IllegalArgumentException, CancelException -
makeCallGraph
public CallGraph makeCallGraph(AnalysisOptions options, MonitorUtil.IProgressMonitor monitor) throws IllegalArgumentException, CallGraphBuilderCancelException Description copied from interface:CallGraphBuilder
Build a call graph.- Specified by:
makeCallGraph
in interfaceCallGraphBuilder<InstanceKey>
- Parameters:
options
- an object representing controlling options that the call graph building algorithm needs to know.- Returns:
- the built call graph
- Throws:
IllegalArgumentException
CallGraphBuilderCancelException
-
makeSystem
-
makeSolver
-
customInit
protected void customInit() -
addConstraintsFromNode
protected abstract boolean addConstraintsFromNode(CGNode n, MonitorUtil.IProgressMonitor monitor) throws CancelException Add constraints for a node.- Returns:
- true iff any new constraints are added.
- Throws:
CancelException
-
addConstraintsFromNewNodes
protected boolean addConstraintsFromNewNodes(MonitorUtil.IProgressMonitor monitor) throws CancelException Add constraints from newly discovered nodes. Note: the act of adding constraints may discover new nodes, so this routine is iterative.- Returns:
- true iff any new constraints are added.
- Throws:
CancelException
-
getPointerKeyForLocal
- Returns:
- the PointerKey that acts as a representative for the class of pointers that includes the local variable identified by the value number parameter.
-
getFilteredPointerKeyForLocal
public FilteredPointerKey getFilteredPointerKeyForLocal(CGNode node, int valueNumber, FilteredPointerKey.TypeFilter filter) - Returns:
- the PointerKey that acts as a representative for the class of pointers that includes the local variable identified by the value number parameter.
-
getFilteredPointerKeyForLocal
public FilteredPointerKey getFilteredPointerKeyForLocal(CGNode node, int valueNumber, IClass filter) -
getFilteredPointerKeyForLocal
public FilteredPointerKey getFilteredPointerKeyForLocal(CGNode node, int valueNumber, InstanceKey filter) -
getPointerKeyForReturnValue
- Returns:
- the PointerKey that acts as a representative for the class of pointers that includes the return value for a node
-
getPointerKeyForExceptionalReturnValue
- Returns:
- the PointerKey that acts as a representative for the class of pointers that includes the exceptional return value
-
getPointerKeyForStaticField
- Returns:
- the PointerKey that acts as a representative for the class of pointers that includes the contents of the static field
-
getPointerKeyForInstanceField
- Returns:
- the PointerKey that acts as a representation for the class of pointers that includes the given instance field. null if there's some problem.
- Throws:
IllegalArgumentException
- if I is nullIllegalArgumentException
- if field is null
-
getPointerKeyForArrayContents
TODO: expand this API to differentiate between different array indices- Parameters:
I
- an InstanceKey representing an abstract array- Returns:
- the PointerKey that acts as a representation for the class of pointers that includes the given array contents, or null if none found.
- Throws:
IllegalArgumentException
- if I is null
-
assignInstanceToCatch
protected void assignInstanceToCatch(PointerKey exceptionVar, Set<IClass> catchClasses, InstanceKey e) Handle assign of a particular exception instance into an exception variable- Parameters:
exceptionVar
- points-to set for a variable representing a caught exceptioncatchClasses
- set of TypeReferences that the exceptionVar may catche
- a particular exception instance
-
addAssignmentsForCatchPointerKey
protected void addAssignmentsForCatchPointerKey(PointerKey exceptionVar, Set<IClass> catchClasses, PointerKey e) Generate a set of constraints to represent assignment to an exception variable in a catch clause. Note that we use FilterOperator to filter out types that the exception handler doesn't catch.- Parameters:
exceptionVar
- points-to set for a variable representing a caught exceptioncatchClasses
- set of TypeReferences that the exceptionVar may catche
- points-to-set representing a thrown exception that might be caught.
-
catches
- Parameters:
catchClasses
- Set of TypeReferenceklass
- an Exception Class- Returns:
- true iff klass is a subclass of some element of the Set
- Throws:
IllegalArgumentException
- if catchClasses is null
-
representsNullType
- Throws:
IllegalArgumentException
-
getClassHierarchy
- Specified by:
getClassHierarchy
in interfaceCallGraphBuilder<InstanceKey>
-
getOptions
-
getJavaLangObject
-
getCallGraph
-
setContextInterpreter
Subclasses must register the context interpreter before building a call graph. -
getPointerAnalysis
- Specified by:
getPointerAnalysis
in interfaceCallGraphBuilder<InstanceKey>
- Returns:
- the Pointer Analysis information computed as a side-effect of call graph construction.
-
getPropagationSystem
-
getPointerKeyFactory
-
setPointerKeyFactory
-
getContextInterpreter
-
getTargetForCall
protected CGNode getTargetForCall(CGNode caller, CallSiteReference site, IClass recv, InstanceKey[] iKey) - Parameters:
caller
- the caller nodeiKey
- an abstraction of the receiver of the call (or null if not applicable)- Returns:
- the CGNode to which this particular call should dispatch.
-
getContextSelector
- Returns:
- the context selector for this call graph builder
-
setContextSelector
-
getInstanceKeys
-
setInstanceKeys
-
getInstanceKeyForAllocation
- Returns:
- the InstanceKey that acts as a representative for the class of objects that includes objects allocated at the given new instruction in the given node
-
getInstanceKeyForMultiNewArray
public InstanceKey getInstanceKeyForMultiNewArray(CGNode node, NewSiteReference allocation, int dim) - Parameters:
dim
- the dimension of the array whose instance we would like to model. dim == 0 represents the first dimension, e.g., the [Object; instances in [[Object; e.g., the [[Object; instances in [[[Object; dim == 1 represents the second dimension, e.g., the [Object instances in [[[Object;- Returns:
- the InstanceKey that acts as a representative for the class of array contents objects that includes objects allocated at the given new instruction in the given node
-
getInstanceKeyForConstant
-
getInstanceKeyForMetadataObject
-
haveAlreadyVisited
-
markAlreadyVisited
-
markDiscovered
record that we've discovered a node -
markChanged
-
wasChanged
-
getMutableInstanceKeysForClass
-
getInstanceKeysForClass
-
filterForClass
-
getSolver
-
addConstraintsFromChangedNode
public void addConstraintsFromChangedNode(CGNode node, MonitorUtil.IProgressMonitor monitor) throws CancelException Add constraints when the interpretation of a node changes (e.g. reflection)- Throws:
CancelException
-
unconditionallyAddConstraintsFromNode
protected abstract boolean unconditionallyAddConstraintsFromNode(CGNode node, MonitorUtil.IProgressMonitor monitor) throws CancelException - Throws:
CancelException
-
getAnalysisCache
- Specified by:
getAnalysisCache
in interfaceCallGraphBuilder<InstanceKey>
- Returns:
- A cache of various analysis artifacts used during call graph construction.
-