changeset 2756:bfcdda4fdd73

Removed the direct connection between BlockBegin and BlockEnd.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Fri, 20 May 2011 14:51:45 +0200
parents e91608c2daff
children 152b98832b0e
files graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java graal/GraalCompiler/src/com/sun/c1x/graph/IR.java graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java
diffstat 4 files changed, 17 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Fri May 20 14:34:36 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Fri May 20 14:51:45 2011 +0200
@@ -257,7 +257,6 @@
         Instruction target = createTargetAt(0, stateAfter);
         Goto base = new Goto(target, stateAfter, graph);
         appendWithBCI(base);
-        ((BlockBegin) startBlock.firstInstruction).setEnd(base);
     }
 
     public void mergeOrClone(Block target, FrameStateAccess newState) {
@@ -375,7 +374,6 @@
                     unwindBlock = new BlockBegin(bci, ir.nextBlockNumber(), graph);
                     Unwind unwind = new Unwind(null, graph);
                     unwindBlock.appendNext(unwind);
-                    unwindBlock.setEnd(unwind);
                 }
                 successor = unwindBlock;
             }
@@ -403,13 +401,11 @@
                         ExceptionDispatch end = new ExceptionDispatch(null, entry, null, handler, null, graph);
                         end.setBlockSuccessor(0, successor);
                         dispatchEntry.appendNext(end);
-                        dispatchEntry.setEnd(end);
                     } else {
                         Deoptimize deopt = new Deoptimize(graph);
                         dispatchEntry.appendNext(deopt);
                         Goto end = new Goto(successor, null, graph);
                         deopt.appendNext(end);
-                        dispatchEntry.setEnd(end);
                     }
 
                     newBlocks.add(dispatchEntry);
@@ -426,7 +422,6 @@
             FrameState stateWithException = entryState.duplicateModified(bci, CiKind.Void, exception);
             BlockEnd end = new Goto(successor, stateWithException, graph);
             exception.appendNext(end);
-            entry.setEnd(end);
 
             if (x instanceof Invoke) {
                 ((Invoke) x).setExceptionEdge(entry);
@@ -1165,7 +1160,6 @@
 
         genThrow(bci);
         BlockEnd end = (BlockEnd) lastInstr;
-        ((BlockBegin) syncHandler.firstInstruction).setEnd(end);
         end.setStateAfter(frameState.create(bci()));
 
         frameState.initializeFrom(origState);
@@ -1178,7 +1172,8 @@
         while ((block = removeFromWorkList()) != null) {
 
             // remove blocks that have no predecessors by the time it their bytecodes are parsed
-            if (block.firstInstruction.predecessors().size() == 0) {
+            Instruction firstInstruction = block.firstInstruction;
+            if (firstInstruction.predecessors().size() == 0) {
                 markVisited(block);
                 continue;
             }
@@ -1186,9 +1181,9 @@
             if (!isVisited(block)) {
                 markVisited(block);
                 // now parse the block
-                frameState.initializeFrom(((BlockBegin) block.firstInstruction).stateBefore());
-                lastInstr = block.firstInstruction;
-                assert block.firstInstruction.next() == null;
+                frameState.initializeFrom(((BlockBegin) firstInstruction).stateBefore());
+                lastInstr = firstInstruction;
+                assert firstInstruction.next() == null;
 
                 iterateBytecodesForBlock(block);
             }
@@ -1246,9 +1241,6 @@
         assert end != null : "end should exist after iterating over bytecodes";
         FrameState stateAtEnd = frameState.create(bci());
         end.setStateAfter(stateAtEnd);
-        if (block.firstInstruction instanceof BlockBegin) {
-            ((BlockBegin) block.firstInstruction).setEnd(end);
-        }
         return end;
     }
 
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java	Fri May 20 14:34:36 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java	Fri May 20 14:51:45 2011 +0200
@@ -200,7 +200,6 @@
         // This goto is not a safepoint.
         Goto e = new Goto(target, null, compilation.graph);
         newSucc.appendNext(e);
-        newSucc.setEnd(e);
         e.reorderSuccessor(0, backEdgeIndex);
         // setup states
         FrameState s = source.end().stateAfter();
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java	Fri May 20 14:34:36 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java	Fri May 20 14:51:45 2011 +0200
@@ -41,8 +41,7 @@
     private static final int INPUT_COUNT = 1;
     private static final int INPUT_STATE_BEFORE = 0;
 
-    private static final int SUCCESSOR_COUNT = 1;
-    private static final int SUCCESSOR_END = 0;
+    private static final int SUCCESSOR_COUNT = 0;
 
     @Override
     protected int inputCount() {
@@ -58,7 +57,11 @@
      * The last node in the block (which contains the successors).
      */
     public BlockEnd end() {
-        return (BlockEnd) successors().get(super.successorCount() + SUCCESSOR_END);
+        Instruction next = next();
+        while (!(next instanceof BlockEnd)) {
+            next = next.next();
+        }
+        return (BlockEnd) next;
     }
 
     @Override
@@ -66,11 +69,6 @@
         return false;
     }
 
-    public void setEnd(BlockEnd end) {
-        assert end != null;
-        successors().set(super.successorCount() + SUCCESSOR_END, end);
-    }
-
     /**
      * A unique id used in tracing.
      */
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java	Fri May 20 14:34:36 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java	Fri May 20 14:51:45 2011 +0200
@@ -22,6 +22,8 @@
  */
 package com.sun.c1x.ir;
 
+import java.util.*;
+
 import com.oracle.graal.graph.*;
 import com.sun.c1x.*;
 import com.sun.c1x.value.*;
@@ -112,10 +114,11 @@
     @Override
     public BlockBegin block() {
         Instruction cur = this;
-        while (!(cur instanceof BlockEnd)) {
-            cur = cur.next();
+        while (!(cur instanceof BlockBegin)) {
+            List<Node> preds = cur.predecessors();
+            cur = (Instruction) preds.get(0);
         }
-        return ((BlockEnd) cur).begin();
+        return (BlockBegin) cur;
     }
 
     /**