public class SSACFG extends Object implements ControlFlowGraph<SSAInstruction,ISSABasicBlock>
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<IInstruction,IBasicBlock<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)
add a node to this graph
|
boolean |
containsNode(ISSABasicBlock N) |
SSACFG.BasicBlock |
entry()
Return the entry basic block in the CFG
|
boolean |
equals(Object o) |
SSACFG.BasicBlock |
exit() |
SSACFG.BasicBlock |
getBasicBlock(int bb) |
SSACFG.BasicBlock |
getBlockForInstruction(int instructionIndex)
Get the basic block an instruction belongs to.
|
BitVector |
getCatchBlocks() |
Collection<ISSABasicBlock> |
getExceptionalPredecessors(ISSABasicBlock b)
The order of blocks returned should be arbitrary but deterministic.
|
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) |
Collection<ISSABasicBlock> |
getNormalPredecessors(ISSABasicBlock b)
The order of blocks returned should be arbitrary but deterministic.
|
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)
Return the number of
immediate predecessor nodes of n |
IntSet |
getPredNodeNumbers(ISSABasicBlock node) |
Iterator<ISSABasicBlock> |
getPredNodes(ISSABasicBlock b)
Return an
Iterator over the immediate predecessor nodes of n
This method never returns null. |
int |
getProgramCounter(int index)
TODO: move this into IR?
|
int |
getSuccNodeCount(ISSABasicBlock b)
Return the number of
immediate successor nodes of this Node in the Graph |
IntSet |
getSuccNodeNumbers(ISSABasicBlock b) |
Iterator<ISSABasicBlock> |
getSuccNodes(ISSABasicBlock b)
Return an Iterator over the immediate successor nodes of n
|
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?
|
Iterator<ISSABasicBlock> |
iterateNodes(IntSet s) |
Iterator<ISSABasicBlock> |
iterator() |
void |
removeAllIncidentEdges(ISSABasicBlock node) |
void |
removeEdge(ISSABasicBlock src,
ISSABasicBlock dst) |
void |
removeIncomingEdges(ISSABasicBlock node) |
void |
removeNode(ISSABasicBlock n)
remove a node from this graph
|
void |
removeNodeAndEdges(ISSABasicBlock N)
remove a node and all its incident edges
|
void |
removeOutgoingEdges(ISSABasicBlock node) |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorprotected final SSAInstruction[] instructions
SSAPhiInstructions, which dwell in
SSACFG.BasicBlocks instead.protected final IMethod method
IMethod this ControlFlowGraph representsprotected final AbstractCFG<IInstruction,IBasicBlock<IInstruction>> delegate
public SSACFG(IMethod method, AbstractCFG cfg, SSAInstruction[] instructions)
IllegalArgumentException - if method is nullpublic SSACFG.BasicBlock getBlockForInstruction(int instructionIndex)
getBlockForInstruction in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>instructionIndex - an instruction indexpublic SSAInstruction[] getInstructions()
getInstructions in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>public BitVector getCatchBlocks()
getCatchBlocks in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>public boolean isCatchBlock(int i)
public SSACFG.BasicBlock entry()
ControlFlowGraphentry in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>public SSACFG.BasicBlock exit()
exit in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>public int getNumber(ISSABasicBlock b) throws IllegalArgumentException
getNumber in interface NumberedNodeManager<ISSABasicBlock>IllegalArgumentExceptionpublic SSACFG.BasicBlock getNode(int number)
getNode in interface NumberedNodeManager<ISSABasicBlock>public int getMaxNumber()
getMaxNumber in interface NumberedNodeManager<ISSABasicBlock>public Iterator<ISSABasicBlock> iterator()
iterator in interface NodeManager<ISSABasicBlock>iterator in interface Iterable<ISSABasicBlock>Iterator of the nodes in this graphpublic int getNumberOfNodes()
getNumberOfNodes in interface NodeManager<ISSABasicBlock>public Iterator<ISSABasicBlock> getPredNodes(ISSABasicBlock b) throws IllegalArgumentException
EdgeManagerIterator over the immediate predecessor nodes of n
This method never returns null.getPredNodes in interface EdgeManager<ISSABasicBlock>Iterator over the immediate predecessor nodes of this Node.IllegalArgumentExceptionpublic int getPredNodeCount(ISSABasicBlock b) throws IllegalArgumentException
EdgeManagerimmediate predecessor nodes of ngetPredNodeCount in interface EdgeManager<ISSABasicBlock>IllegalArgumentExceptionpublic Iterator<ISSABasicBlock> getSuccNodes(ISSABasicBlock b) throws IllegalArgumentException
EdgeManager
This method never returns null.
getSuccNodes in interface EdgeManager<ISSABasicBlock>IllegalArgumentExceptionpublic int getSuccNodeCount(ISSABasicBlock b) throws IllegalArgumentException
EdgeManagerimmediate successor nodes of this Node in the GraphgetSuccNodeCount in interface EdgeManager<ISSABasicBlock>IllegalArgumentExceptionpublic void addNode(ISSABasicBlock n) throws UnsupportedOperationException
NodeManageraddNode in interface NodeManager<ISSABasicBlock>UnsupportedOperationExceptionpublic void addEdge(ISSABasicBlock src, ISSABasicBlock dst) throws UnsupportedOperationException
addEdge in interface EdgeManager<ISSABasicBlock>UnsupportedOperationExceptionpublic void removeEdge(ISSABasicBlock src, ISSABasicBlock dst) throws UnsupportedOperationException
removeEdge in interface EdgeManager<ISSABasicBlock>UnsupportedOperationExceptionpublic void removeAllIncidentEdges(ISSABasicBlock node) throws UnsupportedOperationException
removeAllIncidentEdges in interface EdgeManager<ISSABasicBlock>UnsupportedOperationExceptionpublic void removeNodeAndEdges(ISSABasicBlock N) throws UnsupportedOperationException
GraphremoveNodeAndEdges in interface Graph<ISSABasicBlock>UnsupportedOperationException - if the graph implementation does not allow removalpublic void removeNode(ISSABasicBlock n) throws UnsupportedOperationException
NodeManagerremoveNode in interface NodeManager<ISSABasicBlock>UnsupportedOperationExceptionpublic int getProgramCounter(int index)
ControlFlowGraphgetProgramCounter in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>index - an instruction indexpublic boolean containsNode(ISSABasicBlock N)
containsNode in interface NodeManager<ISSABasicBlock>public IMethod getMethod()
getMethod in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>public List<ISSABasicBlock> getExceptionalSuccessors(ISSABasicBlock b)
ControlFlowGraphgetExceptionalSuccessors in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>public Collection<ISSABasicBlock> getExceptionalPredecessors(ISSABasicBlock b)
ControlFlowGraphgetExceptionalPredecessors in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>public boolean hasExceptionalEdge(SSACFG.BasicBlock src, SSACFG.BasicBlock dest)
IllegalArgumentException - if dest is nullpublic boolean hasNormalEdge(SSACFG.BasicBlock src, SSACFG.BasicBlock dest)
IllegalArgumentException - if dest is nullpublic Collection<ISSABasicBlock> getNormalSuccessors(ISSABasicBlock b)
ControlFlowGraphgetNormalSuccessors in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>public Collection<ISSABasicBlock> getNormalPredecessors(ISSABasicBlock b)
ControlFlowGraphgetNormalPredecessors in interface ControlFlowGraph<SSAInstruction,ISSABasicBlock>public Iterator<ISSABasicBlock> iterateNodes(IntSet s)
iterateNodes in interface NumberedNodeManager<ISSABasicBlock>public void removeIncomingEdges(ISSABasicBlock node) throws UnsupportedOperationException
removeIncomingEdges in interface EdgeManager<ISSABasicBlock>UnsupportedOperationExceptionpublic void removeOutgoingEdges(ISSABasicBlock node) throws UnsupportedOperationException
removeOutgoingEdges in interface EdgeManager<ISSABasicBlock>UnsupportedOperationExceptionpublic boolean hasEdge(ISSABasicBlock src, ISSABasicBlock dst) throws UnimplementedError
hasEdge in interface EdgeManager<ISSABasicBlock>UnimplementedErrorpublic IntSet getSuccNodeNumbers(ISSABasicBlock b) throws IllegalArgumentException
getSuccNodeNumbers in interface NumberedEdgeManager<ISSABasicBlock>IllegalArgumentExceptionpublic IntSet getPredNodeNumbers(ISSABasicBlock node) throws UnimplementedError
getPredNodeNumbers in interface NumberedEdgeManager<ISSABasicBlock>UnimplementedErrorpublic SSACFG.BasicBlock getBasicBlock(int bb)