changeset 19331:9a12234da10c baseline-0.1

Simplification to ControlFlowGraph#identifyBlock.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 12 Feb 2015 21:22:47 +0100
parents 3370072ffbfb
children 833d0361c3e2
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java
diffstat 1 files changed, 20 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java	Thu Feb 12 21:17:30 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java	Thu Feb 12 21:22:47 2015 +0100
@@ -118,42 +118,39 @@
         return loops;
     }
 
-    public void clearNodeToBlock() {
-        nodeToBlock.clear();
-        for (Block block : reversePostOrder) {
-            identifyBlock(block);
-        }
-    }
-
     private void identifyBlock(Block block) {
-        Node cur = block.getBeginNode();
-        Node last;
+        AbstractBeginNode start = block.getBeginNode();
 
         // assign proxies of a loop exit to this block
-        if (cur instanceof AbstractBeginNode) {
-            for (Node usage : cur.usages()) {
+        if (start instanceof LoopExitNode) {
+            for (Node usage : start.usages()) {
                 if (usage instanceof ProxyNode) {
                     nodeToBlock.set(usage, block);
                 }
             }
+        } else if (start instanceof AbstractMergeNode) {
+            for (PhiNode phi : ((AbstractMergeNode) start).phis()) {
+                nodeToBlock.set(phi, block);
+            }
         }
 
-        do {
+        FixedWithNextNode cur = start;
+        while (true) {
             assert !cur.isDeleted();
-
             assert nodeToBlock.get(cur) == null;
             nodeToBlock.set(cur, block);
-            if (cur instanceof AbstractMergeNode) {
-                for (PhiNode phi : ((AbstractMergeNode) cur).phis()) {
-                    nodeToBlock.set(phi, block);
-                }
+            FixedNode next = cur.next();
+            if (next instanceof AbstractBeginNode) {
+                block.endNode = cur;
+                return;
+            } else if (next instanceof FixedWithNextNode) {
+                cur = (FixedWithNextNode) next;
+            } else {
+                nodeToBlock.set(next, block);
+                block.endNode = next;
+                return;
             }
-
-            last = cur;
-            cur = cur.successors().first();
-        } while (cur != null && !(cur instanceof AbstractBeginNode));
-
-        block.endNode = (FixedNode) last;
+        }
     }
 
     private void identifyBlocks() {