changeset 7317:40be0ff5a3ce

Include probability when calculating block weight.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 09 Jan 2013 21:41:37 +0100
parents a64cf8797166
children 323ece2b012b
files graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java
diffstat 1 files changed, 26 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java	Wed Jan 09 21:19:10 2013 +0100
+++ b/graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java	Wed Jan 09 21:41:37 2013 +0100
@@ -163,6 +163,16 @@
         }
         curBit--;
 
+        if (cur.getBeginNode().probability() > 0.5) {
+            weight |= 1 << curBit;
+        }
+        curBit--;
+
+        if (cur.getBeginNode().probability() > 0.05) {
+            weight |= 1 << curBit;
+        }
+        curBit--;
+
         // guarantee that weight is > 0
         weight |= 1;
 
@@ -265,18 +275,22 @@
 
         do {
             Block cur = workList.remove(workList.size() - 1);
-            appendBlock(cur);
-
-            Node endNode = cur.getEndNode();
-            if (endNode instanceof IfNode && ((IfNode) endNode).probability() < 0.5) {
-                assert cur.numberOfSux() == 2;
-                checkAndSortIntoWorkList(cur.suxAt(1));
-                checkAndSortIntoWorkList(cur.suxAt(0));
-            } else {
-                for (Block sux : cur.getSuccessors()) {
-                    checkAndSortIntoWorkList(sux);
-                }
-            }
+            processBlock(cur);
         } while (workList.size() > 0);
     }
+
+    private void processBlock(Block cur) {
+        appendBlock(cur);
+
+        Node endNode = cur.getEndNode();
+        if (endNode instanceof IfNode && ((IfNode) endNode).probability() < 0.5) {
+            assert cur.numberOfSux() == 2;
+            checkAndSortIntoWorkList(cur.suxAt(1));
+            checkAndSortIntoWorkList(cur.suxAt(0));
+        } else {
+            for (Block sux : cur.getSuccessors()) {
+                checkAndSortIntoWorkList(sux);
+            }
+        }
+    }
 }