diff graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java @ 2621:dd115f80acf8

changed stateAfter FrameState to successor (instead of input), checkstyle fixes, added fixed root node to graph
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 10 May 2011 11:55:12 +0200
parents 3558ca7088c0
children 91d3952f7eb7 8e44074058af
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java	Mon May 09 19:12:55 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java	Tue May 10 11:55:12 2011 +0200
@@ -44,7 +44,8 @@
     private static final int INPUT_COUNT = 1;
     private static final int INPUT_STATE_BEFORE = 0;
 
-    private static final int SUCCESSOR_COUNT = 0;
+    private static final int SUCCESSOR_COUNT = 1;
+    private static final int SUCCESSOR_END = 0;
 
     @Override
     protected int inputCount() {
@@ -69,6 +70,33 @@
         return (FrameState) inputs().set(super.inputCount() + INPUT_STATE_BEFORE, n);
     }
 
+    /**
+     * The last node in the block (which contains the successors).
+     */
+    public BlockEnd end() {
+        return (BlockEnd) successors().get(super.successorCount() + SUCCESSOR_END);
+    }
+
+    public void setEnd(BlockEnd end) {
+        assert end != null;
+        BlockEnd old = this.end();
+        if (old != end) {
+            if (old != null) {
+                // disconnect this block from the old end
+                old.setBegin(null);
+                // disconnect this block from its current successors
+                for (BlockBegin s : old.blockSuccessors()) {
+                    s.blockPredecessors().remove(this);
+                }
+            }
+            successors().set(super.successorCount() + SUCCESSOR_END, end);
+            end.setBegin(this);
+            for (BlockBegin s : end.blockSuccessors()) {
+                s.addPredecessor(this);
+            }
+        }
+    }
+
     private static final List<BlockBegin> NO_HANDLERS = Collections.emptyList();
 
     /**
@@ -101,11 +129,6 @@
     private int blockFlags;
 
     /**
-     * A link to the last node in the block (which contains the successors).
-     */
-    private BlockEnd end;
-
-    /**
      * The {@link BlockBegin} nodes for which this node is a successor.
      */
     private final List<BlockBegin> predecessors;
@@ -195,14 +218,6 @@
     }
 
     /**
-     * Gets the block end associated with this basic block.
-     * @return the block end
-     */
-    public BlockEnd end() {
-        return end;
-    }
-
-    /**
      * Gets the exception handlers that cover one or more instructions of this basic block.
      *
      * @return the exception handlers
@@ -233,32 +248,6 @@
     }
 
     /**
-     * Set the block end for this block begin. This method will
-     * reset this block's successor list and rebuild it to be equivalent
-     * to the successor list of the specified block end.
-     * @param end the new block end for this block begin
-     */
-    public void setEnd(BlockEnd end) {
-        assert end != null;
-        BlockEnd old = this.end;
-        if (old != end) {
-            if (old != null) {
-                // disconnect this block from the old end
-                old.setBegin(null);
-                // disconnect this block from its current successors
-                for (BlockBegin s : old.blockSuccessors()) {
-                    s.blockPredecessors().remove(this);
-                }
-            }
-            this.end = end;
-            end.setBegin(this);
-            for (BlockBegin s : end.blockSuccessors()) {
-                s.addPredecessor(this);
-            }
-        }
-    }
-
-    /**
      * Set a flag on this block.
      * @param flag the flag to set
      */
@@ -310,7 +299,7 @@
         while ((block = queue.poll()) != null) {
             closure.apply(block);
             queueBlocks(queue, block.exceptionHandlerBlocks(), mark);
-            queueBlocks(queue, block.end.blockSuccessors(), mark);
+            queueBlocks(queue, block.end().blockSuccessors(), mark);
             queueBlocks(queue, predecessors ? block.predecessors : null, mark);
         }
     }
@@ -595,10 +584,10 @@
         }
 
         builder.append("]");
-        if (end != null) {
+        if (end() != null) {
             builder.append(" -> ");
             boolean hasSucc = false;
-            for (BlockBegin s : end.blockSuccessors()) {
+            for (BlockBegin s : end().blockSuccessors()) {
                 if (hasSucc) {
                     builder.append(", ");
                 }
@@ -615,7 +604,7 @@
      * @return the number of successors
      */
     public int numberOfSux() {
-        return end.blockSuccessorCount();
+        return end().blockSuccessorCount();
     }
 
     /**
@@ -624,7 +613,7 @@
      * @return the successor
      */
     public BlockBegin suxAt(int i) {
-        return end.blockSuccessor(i);
+        return end().blockSuccessor(i);
     }
 
     /**
@@ -768,7 +757,7 @@
         boolean hasPhisInLocals = false;
         boolean hasPhisOnStack = false;
 
-        if (end != null && end.stateAfter() != null) {
+        if (end() != null && end().stateAfter() != null) {
             FrameState state = stateBefore();
 
             int i = 0;