changeset 21094:56668f0816f7

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 23 Apr 2015 13:37:27 +0200
parents a11325faa4d9 (diff) 00b66fc966b1 (current diff)
children 9212e6b75c07
files
diffstat 2 files changed, 24 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SchedulingTest2.java	Thu Apr 23 11:25:16 2015 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SchedulingTest2.java	Thu Apr 23 13:37:27 2015 +0200
@@ -66,7 +66,7 @@
         assertDeepEquals(2, schedule.getCFG().getBlocks().size());
         for (BinaryArithmeticNode<?> node : graph.getNodes().filter(BinaryArithmeticNode.class)) {
             if (node instanceof AddNode) {
-                assertTrue(node.toString() + " expected: " + nodeToBlock.get(beginNode) + " but was: " + nodeToBlock.get(node), nodeToBlock.get(node) == nodeToBlock.get(beginNode));
+                assertTrue(node.toString() + " expected: " + nodeToBlock.get(beginNode) + " but was: " + nodeToBlock.get(node), nodeToBlock.get(node) != nodeToBlock.get(beginNode));
             }
         }
 
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Thu Apr 23 11:25:16 2015 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Thu Apr 23 13:37:27 2015 +0200
@@ -313,8 +313,14 @@
             }
         }
         FixedNode endNode = b.getEndNode();
+        FixedNode fixedEndNode = null;
+        if (isFixedEnd(endNode)) {
+            // Only if the end node is either a control split or an end node, we need to force it to
+            // be the last node in the schedule.
+            fixedEndNode = endNode;
+        }
         for (Node n : earliestSorting) {
-            if (n != endNode) {
+            if (n != fixedEndNode) {
                 if (n instanceof FixedNode) {
                     assert nodeMap.get(n) == b;
                     checkWatchList(b, nodeMap, unprocessed, result, watchList, n);
@@ -337,11 +343,11 @@
             assert nodeMap.get(n) == b;
             assert !(n instanceof FixedNode);
             if (unprocessed.isMarked(n)) {
-                sortIntoList(n, b, result, nodeMap, unprocessed, endNode);
+                sortIntoList(n, b, result, nodeMap, unprocessed, fixedEndNode);
             }
         }
 
-        if (unprocessed.isMarked(endNode)) {
+        if (endNode != null && unprocessed.isMarked(endNode)) {
             sortIntoList(endNode, b, result, nodeMap, unprocessed, null);
         }
 
@@ -491,8 +497,10 @@
         // Start analysis with control flow ends.
         for (Block b : cfg.postOrder()) {
             FixedNode endNode = b.getEndNode();
-            stack.push(endNode);
-            nodeToBlock.set(endNode, b);
+            if (isFixedEnd(endNode)) {
+                stack.push(endNode);
+                nodeToBlock.set(endNode, b);
+            }
         }
 
         processStack(cfg, blockToNodes, nodeToBlock, visited, floatingReads, stack);
@@ -539,8 +547,10 @@
         // Add end nodes as the last nodes in each block.
         for (Block b : cfg.getBlocks()) {
             FixedNode endNode = b.getEndNode();
-            if (endNode != b.getBeginNode()) {
-                addNode(blockToNodes, b, endNode);
+            if (isFixedEnd(endNode)) {
+                if (endNode != b.getBeginNode()) {
+                    addNode(blockToNodes, b, endNode);
+                }
             }
         }
 
@@ -555,6 +565,10 @@
         assert MemoryScheduleVerification.check(cfg.getStartBlock(), blockToNodes);
     }
 
+    private static boolean isFixedEnd(FixedNode endNode) {
+        return endNode instanceof ControlSplitNode || endNode instanceof ControlSinkNode || endNode instanceof AbstractEndNode;
+    }
+
     private static void resortEarliestWithinBlock(Block b, BlockMap<List<Node>> blockToNodes, NodeMap<Block> nodeToBlock, NodeBitMap unprocessed) {
         ArrayList<FloatingReadNode> watchList = new ArrayList<>();
         List<Node> oldList = blockToNodes.get(b);
@@ -679,7 +693,8 @@
                                         inputEarliest = nodeToBlock.get(((ControlSplitNode) input).getPrimarySuccessor());
                                     } else {
                                         assert inputEarliest.getSuccessorCount() == 1;
-                                        inputEarliest = inputEarliest.getSuccessors().get(0);
+                                        assert !(input instanceof AbstractEndNode);
+                                        // Keep regular inputEarliest
                                     }
                                 }
                                 if (earliest.getDominatorDepth() < inputEarliest.getDominatorDepth()) {