public class SSACFG extends java.lang.Object implements ControlFlowGraph<SSAInstruction,ISSABasicBlock>, MinimalCFG<ISSABasicBlock>
This implementation is uglified in the name of performance. This implementation does not
directly track the graph structure, but instead delegates to a prebuilt ControlFlowGraph
which stores the structure. This decision from 2004 may have been premature optimization, left
over from a world where IRs and related structures were long-lived. In today's system,
they are cached and reconstituted by SSACache. Perhaps we should just extend AbstractCFG and not worry so much about space.
As the current implementation stands, the delegate graph stores the graph structure, and this
class additionally stores SSACFG.BasicBlocks and the SSAInstruction array.
| Modifier and Type | Class and Description |
|---|---|
class |
SSACFG.BasicBlock
A Basic Block in an SSA IR
|
class |
SSACFG.ExceptionHandlerBasicBlock |
| Modifier and Type | Field and Description |
|---|---|
protected AbstractCFG<com.ibm.wala.shrikeBT.IInstruction,IBasicBlock<com.ibm.wala.shrikeBT.IInstruction>> |
delegate
A delegate CFG, pre-built, which stores the graph structure of this CFG.
|
protected SSAInstruction[] |
instructions
The "normal" instructions which constitute the SSA form.
|
protected IMethod |
method
The
IMethod this ControlFlowGraph represents |
| Constructor and Description |
|---|
SSACFG(IMethod method,
AbstractCFG cfg,
SSAInstruction[] instructions) |
| Modifier and Type | Method and Description |
|---|---|
void |
addEdge(ISSABasicBlock src,
ISSABasicBlock dst) |
void |
addNode(ISSABasicBlock n) |
boolean |
containsNode(ISSABasicBlock N) |
SSACFG.BasicBlock |
entry()
Return the entry basic block in the CFG
|
boolean |
equals(java.lang.Object o) |
SSACFG.BasicBlock |
exit() |
SSACFG.BasicBlock |
getBasicBlock(int bb) |
SSACFG.BasicBlock |
getBlockForInstruction(int instructionIndex)
Get the basic block an instruction belongs to.
|
com.ibm.wala.util.intset.BitVector |
getCatchBlocks() |
java.util.Collection<ISSABasicBlock> |
getExceptionalPredecessors(ISSABasicBlock b)
The order of blocks returned should be arbitrary but deterministic.
|
java.util.List<ISSABasicBlock> |
getExceptionalSuccessors(ISSABasicBlock b)
The order of blocks returned must indicate the exception-handling scope.
|
SSAInstruction[] |
getInstructions()
NB: Use iterators such as IR.iterateAllInstructions() instead of this method.
|
int |
getMaxNumber() |
IMethod |
getMethod() |
SSACFG.BasicBlock |
getNode(int number) |
java.util.Collection<ISSABasicBlock> |
getNormalPredecessors(ISSABasicBlock b)
The order of blocks returned should be arbitrary but deterministic.
|
java.util.Collection<ISSABasicBlock> |
getNormalSuccessors(ISSABasicBlock b)
The order of blocks returned should be arbitrary but deterministic.
|
int |
getNumber(ISSABasicBlock b) |
int |
getNumberOfNodes() |
int |
getPredNodeCount(ISSABasicBlock b) |
com.ibm.wala.util.intset.IntSet |
getPredNodeNumbers(ISSABasicBlock node) |
java.util.Iterator<ISSABasicBlock> |
getPredNodes(ISSABasicBlock b) |
int |
getProgramCounter(int index)
TODO: move this into IR?
|
int |
getSuccNodeCount(ISSABasicBlock b) |
com.ibm.wala.util.intset.IntSet |
getSuccNodeNumbers(ISSABasicBlock b) |
java.util.Iterator<ISSABasicBlock> |
getSuccNodes(ISSABasicBlock b) |
boolean |
hasEdge(ISSABasicBlock src,
ISSABasicBlock dst) |
boolean |
hasExceptionalEdge(SSACFG.BasicBlock src,
SSACFG.BasicBlock dest)
has exceptional edge src -> dest
|
int |
hashCode() |
boolean |
hasNormalEdge(SSACFG.BasicBlock src,
SSACFG.BasicBlock dest)
has normal edge src -> dest
|
boolean |
isCatchBlock(int i)
is the given i a catch block?
|
java.util.Iterator<ISSABasicBlock> |
iterateNodes(com.ibm.wala.util.intset.IntSet s) |
java.util.Iterator<ISSABasicBlock> |
iterator() |
void |
removeAllIncidentEdges(ISSABasicBlock node) |
void |
removeEdge(ISSABasicBlock src,
ISSABasicBlock dst) |
void |
removeIncomingEdges(ISSABasicBlock node) |
void |
removeNode(ISSABasicBlock n) |
void |
removeNodeAndEdges(ISSABasicBlock N) |
void |
removeOutgoingEdges(ISSABasicBlock node) |
java.util.stream.Stream<ISSABasicBlock> |
stream() |
java.lang.String |
toString() |
protected final SSAInstruction[] instructions
SSAPhiInstructions, which dwell in SSACFG.BasicBlocks instead.protected final IMethod method
IMethod this ControlFlowGraph representsprotected final AbstractCFG<com.ibm.wala.shrikeBT.IInstruction,IBasicBlock<com.ibm.wala.shrikeBT.IInstruction>> delegate
public SSACFG(IMethod method, AbstractCFG cfg, SSAInstruction[] instructions)
java.lang.IllegalArgumentException - if method is nullpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic SSACFG.BasicBlock getBlockForInstruction(int instructionIndex)
getBlockForInstruction in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>instructionIndex - an instruction indexpublic SSAInstruction[] getInstructions()
Return the instructions. Note that the CFG is created from the Shrike CFG prior to creating the SSA instructions.
getInstructions in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>public java.lang.String toString()
toString in class java.lang.Objectpublic com.ibm.wala.util.intset.BitVector getCatchBlocks()
getCatchBlocks in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>public boolean isCatchBlock(int i)
public SSACFG.BasicBlock entry()
MinimalCFGentry in interface MinimalCFG<ISSABasicBlock>public SSACFG.BasicBlock exit()
exit in interface MinimalCFG<ISSABasicBlock>public int getNumber(ISSABasicBlock b) throws java.lang.IllegalArgumentException
getNumber in interface com.ibm.wala.util.graph.NumberedNodeManager<ISSABasicBlock>java.lang.IllegalArgumentExceptionpublic SSACFG.BasicBlock getNode(int number)
getNode in interface com.ibm.wala.util.graph.NumberedNodeManager<ISSABasicBlock>public int getMaxNumber()
getMaxNumber in interface com.ibm.wala.util.graph.NumberedNodeManager<ISSABasicBlock>public java.util.Iterator<ISSABasicBlock> iterator()
iterator in interface com.ibm.wala.util.graph.NodeManager<ISSABasicBlock>iterator in interface java.lang.Iterable<ISSABasicBlock>public java.util.stream.Stream<ISSABasicBlock> stream()
stream in interface com.ibm.wala.util.graph.NodeManager<ISSABasicBlock>public int getNumberOfNodes()
getNumberOfNodes in interface com.ibm.wala.util.graph.NodeManager<ISSABasicBlock>public java.util.Iterator<ISSABasicBlock> getPredNodes(ISSABasicBlock b) throws java.lang.IllegalArgumentException
getPredNodes in interface com.ibm.wala.util.graph.EdgeManager<ISSABasicBlock>java.lang.IllegalArgumentExceptionpublic int getPredNodeCount(ISSABasicBlock b) throws java.lang.IllegalArgumentException
getPredNodeCount in interface com.ibm.wala.util.graph.EdgeManager<ISSABasicBlock>java.lang.IllegalArgumentExceptionpublic java.util.Iterator<ISSABasicBlock> getSuccNodes(ISSABasicBlock b) throws java.lang.IllegalArgumentException
getSuccNodes in interface com.ibm.wala.util.graph.EdgeManager<ISSABasicBlock>java.lang.IllegalArgumentExceptionpublic int getSuccNodeCount(ISSABasicBlock b) throws java.lang.IllegalArgumentException
getSuccNodeCount in interface com.ibm.wala.util.graph.EdgeManager<ISSABasicBlock>java.lang.IllegalArgumentExceptionpublic void addNode(ISSABasicBlock n) throws java.lang.UnsupportedOperationException
addNode in interface com.ibm.wala.util.graph.NodeManager<ISSABasicBlock>java.lang.UnsupportedOperationExceptionpublic void addEdge(ISSABasicBlock src, ISSABasicBlock dst) throws java.lang.UnsupportedOperationException
addEdge in interface com.ibm.wala.util.graph.EdgeManager<ISSABasicBlock>java.lang.UnsupportedOperationExceptionpublic void removeEdge(ISSABasicBlock src, ISSABasicBlock dst) throws java.lang.UnsupportedOperationException
removeEdge in interface com.ibm.wala.util.graph.EdgeManager<ISSABasicBlock>java.lang.UnsupportedOperationExceptionpublic void removeAllIncidentEdges(ISSABasicBlock node) throws java.lang.UnsupportedOperationException
removeAllIncidentEdges in interface com.ibm.wala.util.graph.EdgeManager<ISSABasicBlock>java.lang.UnsupportedOperationExceptionpublic void removeNodeAndEdges(ISSABasicBlock N) throws java.lang.UnsupportedOperationException
removeNodeAndEdges in interface com.ibm.wala.util.graph.Graph<ISSABasicBlock>java.lang.UnsupportedOperationExceptionpublic void removeNode(ISSABasicBlock n) throws java.lang.UnsupportedOperationException
removeNode in interface com.ibm.wala.util.graph.NodeManager<ISSABasicBlock>java.lang.UnsupportedOperationExceptionpublic int getProgramCounter(int index)
ControlFlowGraphgetProgramCounter in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>index - an instruction indexpublic boolean containsNode(ISSABasicBlock N)
containsNode in interface com.ibm.wala.util.graph.NodeManager<ISSABasicBlock>public IMethod getMethod()
getMethod in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>public java.util.List<ISSABasicBlock> getExceptionalSuccessors(ISSABasicBlock b)
MinimalCFGgetExceptionalSuccessors in interface MinimalCFG<ISSABasicBlock>public java.util.Collection<ISSABasicBlock> getExceptionalPredecessors(ISSABasicBlock b)
MinimalCFGgetExceptionalPredecessors in interface MinimalCFG<ISSABasicBlock>public boolean hasExceptionalEdge(SSACFG.BasicBlock src, SSACFG.BasicBlock dest)
java.lang.IllegalArgumentException - if dest is nullpublic boolean hasNormalEdge(SSACFG.BasicBlock src, SSACFG.BasicBlock dest)
java.lang.IllegalArgumentException - if dest is nullpublic java.util.Collection<ISSABasicBlock> getNormalSuccessors(ISSABasicBlock b)
MinimalCFGgetNormalSuccessors in interface MinimalCFG<ISSABasicBlock>public java.util.Collection<ISSABasicBlock> getNormalPredecessors(ISSABasicBlock b)
MinimalCFGgetNormalPredecessors in interface MinimalCFG<ISSABasicBlock>public java.util.Iterator<ISSABasicBlock> iterateNodes(com.ibm.wala.util.intset.IntSet s)
iterateNodes in interface com.ibm.wala.util.graph.NumberedNodeManager<ISSABasicBlock>public void removeIncomingEdges(ISSABasicBlock node) throws java.lang.UnsupportedOperationException
removeIncomingEdges in interface com.ibm.wala.util.graph.EdgeManager<ISSABasicBlock>java.lang.UnsupportedOperationExceptionpublic void removeOutgoingEdges(ISSABasicBlock node) throws java.lang.UnsupportedOperationException
removeOutgoingEdges in interface com.ibm.wala.util.graph.EdgeManager<ISSABasicBlock>java.lang.UnsupportedOperationExceptionpublic boolean hasEdge(ISSABasicBlock src, ISSABasicBlock dst) throws com.ibm.wala.util.debug.UnimplementedError
hasEdge in interface com.ibm.wala.util.graph.EdgeManager<ISSABasicBlock>com.ibm.wala.util.debug.UnimplementedErrorpublic com.ibm.wala.util.intset.IntSet getSuccNodeNumbers(ISSABasicBlock b) throws java.lang.IllegalArgumentException
getSuccNodeNumbers in interface com.ibm.wala.util.graph.NumberedEdgeManager<ISSABasicBlock>java.lang.IllegalArgumentExceptionpublic com.ibm.wala.util.intset.IntSet getPredNodeNumbers(ISSABasicBlock node) throws com.ibm.wala.util.debug.UnimplementedError
getPredNodeNumbers in interface com.ibm.wala.util.graph.NumberedEdgeManager<ISSABasicBlock>com.ibm.wala.util.debug.UnimplementedErrorpublic SSACFG.BasicBlock getBasicBlock(int bb)