# HG changeset patch # User Gilles Duboscq # Date 1352206624 -3600 # Node ID e54aeb000ad764c470eeb05ae79187b1e3f63752 # Parent 6b71c116b370a12271f4338b7e17ade8b71f2d2e Directly return the NodeSuccessorList in ControlSplitNode.blockSuccessors instead of creating a new Iterable Add comments to LoopBeginNode.loopEnds()/orderedLoopEnds() diff -r 6b71c116b370 -r e54aeb000ad7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ControlSplitNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ControlSplitNode.java Mon Nov 05 12:58:32 2012 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ControlSplitNode.java Tue Nov 06 13:57:04 2012 +0100 @@ -62,27 +62,7 @@ } public Iterable blockSuccessors() { - return new Iterable() { - @Override - public Iterator iterator() { - return new Iterator() { - int i = 0; - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - @Override - public BeginNode next() { - return ControlSplitNode.this.blockSuccessor(i++); - } - - @Override - public boolean hasNext() { - return i < ControlSplitNode.this.blockSuccessorCount(); - } - }; - } - }; + return blockSuccessors; } public int blockSuccessorIndex(BeginNode successor) { diff -r 6b71c116b370 -r e54aeb000ad7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopBeginNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopBeginNode.java Mon Nov 05 12:58:32 2012 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopBeginNode.java Tue Nov 06 13:57:04 2012 +0100 @@ -48,6 +48,11 @@ this.loopFrequency = loopFrequency; } + /** + * Returns the unordered set of {@link LoopEndNode} that correspond to back-edges for this loop. + * The order of the back-edges is unspecified, if you need to get an ordering compatible for {@link PhiNode} creation, use {@link #orderedLoopEnds()}. + * @return the set of {@code LoopEndNode} that correspond to back-edges for this loop + */ public NodeIterable loopEnds() { return usages().filter(LoopEndNode.class); } @@ -61,6 +66,11 @@ return super.anchored().filter(isNotA(LoopEndNode.class).nor(LoopExitNode.class)); } + /** + * Returns the set of {@link LoopEndNode} that correspond to back-edges for this loop, ordered in increasing {@link #phiPredecessorIndex}. + * This method is suited to create new loop {@link PhiNode}. + * @return the set of {@code LoopEndNode} that correspond to back-edges for this loop + */ public List orderedLoopEnds() { List snapshot = loopEnds().snapshot(); Collections.sort(snapshot, new Comparator() {