public class SortedGraphIterator extends Object
A typical use is as follows:
BasicBlock start = ir.cfg.entry(); SortedGraphIterator bbIter = new SortedGraphIterator(start, true); // true means forward analysis; false means backward analysis for (BasicBlock currBlock = start; currBlock!= null;) { // do your analysis of the currBlock here boolean changed = ... // true if the solution of currBlock has been changed since // the last visit of currBlock. // false if not. currBlock = (BasicBlock) bbIter.markAndGetNextTopSort(changed); }
Modifier and Type | Field and Description |
---|---|
protected SortedGraphNode |
barrier
The earliest place where we needed to move currentNode back in the list
because its successor needed to be processed.
|
protected int |
changeMark
A unique marker to use to mark nodes
|
protected SortedGraphNode |
currentNode
The current node we are processing
|
protected boolean |
forward
The direction we are moving on the graph
|
Constructor and Description |
---|
SortedGraphIterator(SortedGraphNode current,
boolean forward)
Constructor
|
Modifier and Type | Method and Description |
---|---|
private void |
advanceBarrier()
This method keeps track of nodes in the graph that are known to
not have been visited yet even once.
|
boolean |
isSinglePredecessor(SortedGraphNode currentNode,
SortedGraphNode nextNode)
This method checks to see if the second parameter has a single
successor, which is the first parameter.
|
boolean |
isSingleSuccessor(SortedGraphNode currentNode,
SortedGraphNode nextNode)
This method checks to see if the second parameter has a single
predecessor, which is the first parameter.
|
SortedGraphNode |
markAndGetNextTopSort(boolean changed)
General fixed-pointer iterator; call this repeatedly until there
is no more work to do.
|
protected SortedGraphNode barrier
protected int changeMark
protected SortedGraphNode currentNode
protected boolean forward
public SortedGraphIterator(SortedGraphNode current, boolean forward)
current
- the node to start the iteration atforward
- the direction we are processing the graphpublic SortedGraphNode markAndGetNextTopSort(boolean changed)
changed
- Whether analysis of the current element changed
any data-flow result.isSingleSuccessor(org.jikesrvm.compilers.opt.util.SortedGraphNode, org.jikesrvm.compilers.opt.util.SortedGraphNode)
,
isSinglePredecessor(org.jikesrvm.compilers.opt.util.SortedGraphNode, org.jikesrvm.compilers.opt.util.SortedGraphNode)
public boolean isSingleSuccessor(SortedGraphNode currentNode, SortedGraphNode nextNode)
currentNode
- the possibly unique predecessornextNode
- the node of interestpublic boolean isSinglePredecessor(SortedGraphNode currentNode, SortedGraphNode nextNode)
currentNode
- the possibly unique predecessornextNode
- the node of interestprivate void advanceBarrier()