# HG changeset patch # User Bernhard Urban # Date 1374862720 -7200 # Node ID 2cdd22e1ac5e481c11873160d7009065625500d6 # Parent a9225e3678aa790809cd4e633b0cde0a8e3d02aa SchedulingPhase: check if fixed nodes have the same order before and after sorting a block diff -r a9225e3678aa -r 2cdd22e1ac5e graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Fri Jul 26 19:49:36 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Fri Jul 26 20:18:40 2013 +0200 @@ -515,9 +515,32 @@ default: throw new GraalInternalError("unknown scheduling strategy"); } + assert sameOrderForFixedNodes(blockToNodesMap.get(b), sortedInstructions) : "fixed nodes in sorted block are not in the same order"; blockToNodesMap.put(b, sortedInstructions); } + private static boolean sameOrderForFixedNodes(List fixed, List sorted) { + Iterator fixedIterator = fixed.iterator(); + Iterator sortedIterator = sorted.iterator(); + + while (sortedIterator.hasNext()) { + ScheduledNode sortedCurrent = sortedIterator.next(); + if (sortedCurrent instanceof FixedNode) { + if (!(fixedIterator.hasNext() && fixedIterator.next() == sortedCurrent)) { + return false; + } + } + } + + while (fixedIterator.hasNext()) { + if (fixedIterator.next() instanceof FixedNode) { + return false; + } + } + + return true; + } + /** * Sorts the nodes within a block by adding the nodes to a list in a post-order iteration over * all inputs. This means that a node is added to the list after all its inputs have been