Package com.ibm.wala.demandpa.flowgraph
Class AbstractFlowGraph
- java.lang.Object
-
- com.ibm.wala.util.graph.AbstractGraph<T>
-
- com.ibm.wala.util.graph.AbstractNumberedGraph<T>
-
- com.ibm.wala.util.graph.labeled.AbstractNumberedLabeledGraph<T,U>
-
- com.ibm.wala.util.graph.labeled.SlowSparseNumberedLabeledGraph<Object,IFlowLabel>
-
- com.ibm.wala.demandpa.flowgraph.AbstractFlowGraph
-
- All Implemented Interfaces:
IFlowGraph
,EdgeManager<Object>
,Graph<Object>
,LabeledEdgeManager<Object,IFlowLabel>
,LabeledGraph<Object,IFlowLabel>
,NodeManager<Object>
,NumberedEdgeManager<Object>
,NumberedGraph<Object>
,NumberedNodeManager<Object>
,Iterable<Object>
- Direct Known Subclasses:
AbstractDemandFlowGraph
public abstract class AbstractFlowGraph extends SlowSparseNumberedLabeledGraph<Object,IFlowLabel> implements IFlowGraph
A graph whose edges are labeled withIFlowLabel
s.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<PointerKey,SSAAbstractInvokeInstruction>
callDefs
Map: LocalPointerKey -> SSAInvokeInstruction.protected Map<PointerKey,Set<SSAAbstractInvokeInstruction>>
callParams
Map:LocalPointerKey
-> Set<SSAInvokeInstruction
>.protected CallGraph
cg
protected IClassHierarchy
cha
protected HeapModel
heapModel
protected MemoryAccessMap
mam
protected Map<PointerKey,CGNode>
params
Map: LocalPointerKey -> CGNode.protected Map<PointerKey,CGNode>
returns
Map:LocalPointerKey
->CGNode
.
-
Constructor Summary
Constructors Constructor Description AbstractFlowGraph(MemoryAccessMap mam, HeapModel heapModel, IClassHierarchy cha, CallGraph cg)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addExceptionDefConstraints(IR ir, CGNode node, List<ProgramCounter> peis, PointerKey exceptionVar, Set<IClass> catchClasses)
Generate constraints which assign exception values into an exception pointerprotected void
addNodeConstantConstraints(CGNode node, IR ir)
add constraints for reference constants assigned to varsprotected void
addNodePassthruExceptionConstraints(CGNode node, IR ir)
Add constraints to represent the flow of exceptions to the exceptional return value for this nodeprotected void
addNodesForInvocations(CGNode node, IR ir)
For each invocation in the method, add nodes for actual parameters and return valuesstatic PointerKey
convertPointerKeyToHeapModel(PointerKey pk, HeapModel h)
convert a pointer key to one in the memory access map's heap model TODO move this somewhere more appropriateprotected Iterator<PointerKey>
getArrayReads(PointerKey arrayRef)
SSAAbstractInvokeInstruction
getInstrReturningTo(LocalPointerKey pk)
get theSSAInvokeInstruction
whose return value is assigned to a pointer key.Iterator<SSAAbstractInvokeInstruction>
getInstrsPassingParam(LocalPointerKey pk)
Iterator<PointerKey>
getReadsOfInstanceField(PointerKey pk, IField f)
Iterator<? extends Object>
getReadsOfStaticField(StaticFieldKey sfk)
Iterator<PointerKey>
getWritesToInstanceField(PointerKey pk, IField f)
Iterator<? extends Object>
getWritesToStaticField(StaticFieldKey sfk)
boolean
isParam(LocalPointerKey pk)
void
visitPreds(Object node, IFlowLabel.IFlowLabelVisitor v)
Apply a visitor to the predecessors of some node.void
visitSuccs(Object node, IFlowLabel.IFlowLabelVisitor v)
Apply a visitor to the successors of some node.-
Methods inherited from class com.ibm.wala.util.graph.labeled.SlowSparseNumberedLabeledGraph
copyInto, duplicate, getEdgeManager, getNodeManager
-
Methods inherited from class com.ibm.wala.util.graph.labeled.AbstractNumberedLabeledGraph
addEdge, getDefaultLabel, getEdgeLabels, getPredLabels, getPredNodeCount, getPredNodeNumbers, getPredNodes, getSuccLabels, getSuccNodeCount, getSuccNodeNumbers, getSuccNodes, hasEdge, removeEdge
-
Methods inherited from class com.ibm.wala.util.graph.AbstractNumberedGraph
getMaxNumber, getNode, getNumber, getPredNodeNumbers, getSuccNodeNumbers, iterateNodes
-
Methods inherited from class com.ibm.wala.util.graph.AbstractGraph
addEdge, addNode, containsNode, getNumberOfNodes, getPredNodeCount, getPredNodes, getSuccNodeCount, getSuccNodes, hasEdge, iterator, removeAllIncidentEdges, removeEdge, removeIncomingEdges, removeNode, removeNodeAndEdges, removeOutgoingEdges, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.ibm.wala.util.graph.EdgeManager
addEdge, getPredNodeCount, getPredNodes, getSuccNodeCount, getSuccNodes, hasEdge, removeAllIncidentEdges, removeEdge, removeIncomingEdges, removeOutgoingEdges
-
Methods inherited from interface com.ibm.wala.util.graph.Graph
removeNodeAndEdges
-
Methods inherited from interface com.ibm.wala.demandpa.flowgraph.IFlowGraph
addSubgraphForNode, getPossibleTargets, getPotentialCallers, hasSubgraphForNode
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface com.ibm.wala.util.graph.labeled.LabeledEdgeManager
addEdge, getDefaultLabel, getEdgeLabels, getPredLabels, getPredNodeCount, getPredNodes, getSuccLabels, getSuccNodeCount, getSuccNodes, hasEdge, removeEdge
-
Methods inherited from interface com.ibm.wala.util.graph.NodeManager
addNode, containsNode, getNumberOfNodes, iterator, removeNode
-
-
-
-
Field Detail
-
callDefs
protected final Map<PointerKey,SSAAbstractInvokeInstruction> callDefs
Map: LocalPointerKey -> SSAInvokeInstruction. If we have (x, foo()), that means that x was def'fed by the return value from the call to foo()
-
callParams
protected final Map<PointerKey,Set<SSAAbstractInvokeInstruction>> callParams
Map:LocalPointerKey
-> Set<SSAInvokeInstruction
>. If we have (x, foo()), that means x was passed as a parameter to the call to foo(). The parameter position is not represented and must be recovered.
-
params
protected final Map<PointerKey,CGNode> params
Map: LocalPointerKey -> CGNode. If we have (x, foo), then x is a parameter of method foo. For now, we have to re-discover the parameter position. TODO this should just be a set; we can get the CGNode from theLocalPointerKey
-
returns
protected final Map<PointerKey,CGNode> returns
Map:LocalPointerKey
->CGNode
. If we have (x, foo), then x is a return value of method foo. Must re-discover if x is normal or exceptional return value.
-
mam
protected final MemoryAccessMap mam
-
heapModel
protected final HeapModel heapModel
-
cha
protected final IClassHierarchy cha
-
cg
protected final CallGraph cg
-
-
Constructor Detail
-
AbstractFlowGraph
public AbstractFlowGraph(MemoryAccessMap mam, HeapModel heapModel, IClassHierarchy cha, CallGraph cg)
-
-
Method Detail
-
visitSuccs
public void visitSuccs(Object node, IFlowLabel.IFlowLabelVisitor v)
Description copied from interface:IFlowGraph
Apply a visitor to the successors of some node.- Specified by:
visitSuccs
in interfaceIFlowGraph
-
visitPreds
public void visitPreds(Object node, IFlowLabel.IFlowLabelVisitor v)
Description copied from interface:IFlowGraph
Apply a visitor to the predecessors of some node.- Specified by:
visitPreds
in interfaceIFlowGraph
-
addNodesForInvocations
protected void addNodesForInvocations(CGNode node, IR ir)
For each invocation in the method, add nodes for actual parameters and return values- Parameters:
node
-
-
isParam
public boolean isParam(LocalPointerKey pk)
- Specified by:
isParam
in interfaceIFlowGraph
- Returns:
true
iffpk
is a formal parameter
-
getInstrsPassingParam
public Iterator<SSAAbstractInvokeInstruction> getInstrsPassingParam(LocalPointerKey pk)
- Specified by:
getInstrsPassingParam
in interfaceIFlowGraph
- Returns:
- the
SSAInvokeInstruction
s passing some pointer as a parameter
-
getInstrReturningTo
public SSAAbstractInvokeInstruction getInstrReturningTo(LocalPointerKey pk)
Description copied from interface:IFlowGraph
get theSSAInvokeInstruction
whose return value is assigned to a pointer key.- Specified by:
getInstrReturningTo
in interfaceIFlowGraph
- Returns:
- the instruction, or
null
if no return value is assigned to pk
-
getWritesToStaticField
public Iterator<? extends Object> getWritesToStaticField(StaticFieldKey sfk) throws IllegalArgumentException
- Specified by:
getWritesToStaticField
in interfaceIFlowGraph
- Parameters:
sfk
- the static field- Returns:
- all the variables whose values are written to sfk
- Throws:
IllegalArgumentException
- if sfk == null
-
getReadsOfStaticField
public Iterator<? extends Object> getReadsOfStaticField(StaticFieldKey sfk) throws IllegalArgumentException
- Specified by:
getReadsOfStaticField
in interfaceIFlowGraph
- Parameters:
sfk
- the static field- Returns:
- all the variables that get the value of sfk
- Throws:
IllegalArgumentException
- if sfk == null
-
getWritesToInstanceField
public Iterator<PointerKey> getWritesToInstanceField(PointerKey pk, IField f)
- Specified by:
getWritesToInstanceField
in interfaceIFlowGraph
-
convertPointerKeyToHeapModel
public static PointerKey convertPointerKeyToHeapModel(PointerKey pk, HeapModel h)
convert a pointer key to one in the memory access map's heap model TODO move this somewhere more appropriate- Throws:
UnsupportedOperationException
- if it doesn't know how to handle aPointerKey
-
getReadsOfInstanceField
public Iterator<PointerKey> getReadsOfInstanceField(PointerKey pk, IField f)
- Specified by:
getReadsOfInstanceField
in interfaceIFlowGraph
-
getArrayReads
protected Iterator<PointerKey> getArrayReads(PointerKey arrayRef)
-
addNodePassthruExceptionConstraints
protected void addNodePassthruExceptionConstraints(CGNode node, IR ir)
Add constraints to represent the flow of exceptions to the exceptional return value for this node
-
addExceptionDefConstraints
protected void addExceptionDefConstraints(IR ir, CGNode node, List<ProgramCounter> peis, PointerKey exceptionVar, Set<IClass> catchClasses)
Generate constraints which assign exception values into an exception pointer- Parameters:
node
- governing nodepeis
- list of PEI instructionsexceptionVar
- PointerKey representing a pointer to an exception valuecatchClasses
- the types "caught" by the exceptionVar
-
-