# HG changeset patch # User Miguel Garcia # Date 1400076425 -7200 # Node ID c93c3dc57f53e8cad0d486bbecf6333d8a085578 # Parent cd436bc5d63a2bfcdbd026d31384c5ffaa8b5822 [single-pass-iter] readability and one more assertion diff -r cd436bc5d63a -r c93c3dc57f53 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/SinglePassNodeIterator.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/SinglePassNodeIterator.java Wed May 14 18:13:41 2014 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/SinglePassNodeIterator.java Wed May 14 16:07:05 2014 +0200 @@ -58,9 +58,9 @@ private final NodeBitMap visitedEnds; /** - * @see SinglePassNodeIterator.QElem + * @see SinglePassNodeIterator.PathStart */ - private final Deque> nodeQueue; + private final Deque> nodeQueue; /** * The keys in this map may be: @@ -104,23 +104,26 @@ *
    *
  • a {@link MergeNode} whose pre-state results from merging those of its forward-ends, see * {@link #nextQueuedNode()}
  • - *
  • the successor of a control-split node, in which case the pre-state of the successor in - * question is also stored in the item, see {@link #nextQueuedNode()}
  • + *
  • a successor of a control-split node, in which case the state on entry to it (the + * successor) is also stored in the item, see {@link #nextQueuedNode()}
  • *
*

*/ - private static class QElem { + private static class PathStart { private final FixedNode node; - private final U preState; + private final U stateOnEntry; - private QElem(FixedNode node, U preState) { + private PathStart(FixedNode node, U stateOnEntry) { this.node = node; - this.preState = preState; + this.stateOnEntry = stateOnEntry; assert repOK(); } + /** + * @return true iff this instance is internally consistent (ie, its "representation is OK") + */ private boolean repOK() { - return (node instanceof MergeNode && preState == null) || (node instanceof BeginNode && preState != null); + return (node instanceof MergeNode && stateOnEntry == null) || (node instanceof BeginNode && stateOnEntry != null); } } @@ -191,7 +194,7 @@ private void queueSuccessors(FixedNode x) { for (Node node : x.successors()) { if (node != null) { - nodeQueue.addFirst(new QElem<>((BeginNode) node, state)); + nodeQueue.addFirst(new PathStart<>((BeginNode) node, state)); } } } @@ -210,7 +213,7 @@ if (nodeQueue.isEmpty()) { return null; } - QElem elem = nodeQueue.removeFirst(); + PathStart elem = nodeQueue.removeFirst(); if (elem.node instanceof MergeNode) { MergeNode merge = (MergeNode) elem.node; state = pruneEntry(merge.forwardEndAt(0)).clone(); @@ -225,7 +228,7 @@ } else { BeginNode begin = (BeginNode) elem.node; assert begin.predecessor() != null; - state = elem.preState.clone(); + state = elem.stateOnEntry.clone(); state.afterSplit(begin); return begin; } @@ -292,7 +295,7 @@ } } if (endsVisited) { - nodeQueue.add(new QElem<>(merge, null)); + nodeQueue.add(new PathStart<>(merge, null)); } } @@ -338,6 +341,7 @@ private void keepForLater(FixedNode x, T s) { assert !nodeStates.containsKey(x); assert (x instanceof LoopBeginNode) || (x instanceof LoopEndNode) || (x instanceof EndNode); + assert s != null; nodeStates.put(x, s); }