changeset 3002:bf14154d5b14

Model frame states as inputs to their instruction.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Thu, 16 Jun 2011 16:09:39 +0200
parents ef9afe6ffd5e
children a7a7e87ad230
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/StateSplit.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameState.java
diffstat 3 files changed, 17 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/StateSplit.java	Thu Jun 16 16:03:26 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/StateSplit.java	Thu Jun 16 16:09:39 2011 +0200
@@ -32,10 +32,10 @@
  */
 public abstract class StateSplit extends Instruction {
 
-    private static final int INPUT_COUNT = 0;
+    private static final int INPUT_COUNT = 1;
+    private static final int INPUT_STATE_AFTER = 0;
 
     private static final int SUCCESSOR_COUNT = 1;
-    private static final int SUCCESSOR_STATE_AFTER = 0;
 
     @Override
     protected int inputCount() {
@@ -52,11 +52,11 @@
      */
      @Override
     public FrameState stateAfter() {
-        return (FrameState) successors().get(super.successorCount() + SUCCESSOR_STATE_AFTER);
+        return (FrameState) inputs().get(super.inputCount() + INPUT_STATE_AFTER);
     }
 
     public FrameState setStateAfter(FrameState n) {
-        return (FrameState) successors().set(super.successorCount() + SUCCESSOR_STATE_AFTER, n);
+        return (FrameState) inputs().set(super.inputCount() + INPUT_STATE_AFTER, n);
     }
 
     /**
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java	Thu Jun 16 16:03:26 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java	Thu Jun 16 16:09:39 2011 +0200
@@ -143,20 +143,6 @@
             }
         }
 
-        for (Node n : graph.getNodes()) {
-            if (n instanceof FrameState) {
-                FrameState f = (FrameState) n;
-                if (f.predecessors().size() == 1) {
-                    Block predBlock = nodeToBlock.get(f.predecessors().get(0));
-                    assert predBlock != null;
-                    nodeToBlock.set(f, predBlock);
-                    predBlock.getInstructions().add(f);
-                } else {
-                    assert f.predecessors().size() == 0;
-                }
-            }
-        }
-
         computeDominators();
 
 
@@ -341,8 +327,13 @@
             return;
         }
 
+        FrameState state = null;
         for (Node input : i.inputs()) {
-            addToSorting(b, input, sortedInstructions, map);
+            if (input instanceof FrameState) {
+                state = (FrameState) input;
+            } else {
+                addToSorting(b, input, sortedInstructions, map);
+            }
         }
 
         for (Node pred : i.predecessors()) {
@@ -357,6 +348,10 @@
             }
         }
 
+        if (state != null) {
+            addToSorting(b, state, sortedInstructions, map);
+        }
+
         // Now predecessors and inputs are scheduled => we can add this node.
         if (!(i instanceof FrameState)) {
             sortedInstructions.add(i);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameState.java	Thu Jun 16 16:03:26 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameState.java	Thu Jun 16 16:09:39 2011 +0200
@@ -398,9 +398,9 @@
     }
 
     public Merge block() {
-        for (Node preds : predecessors()) {
-            if (preds instanceof Merge) {
-                return (Merge) preds;
+        for (Node n : usages()) {
+            if (n instanceof Merge) {
+                return (Merge) n;
             }
         }
         return null;