diff graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2788:df4c5254c5cc

Towards goto removal.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 25 May 2011 14:33:44 +0200
parents 847dcd4dbd4c
children aeccd2af4e9e
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Wed May 25 12:20:08 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Wed May 25 14:33:44 2011 +0200
@@ -290,8 +290,7 @@
     private void finishStartBlock(Block startBlock) {
         assert bci() == 0;
         Instruction target = createTargetAt(0, frameState);
-        Goto base = new Goto(target, graph);
-        appendWithBCI(base);
+        appendGoto(target);
     }
 
     public void mergeOrClone(Block target, FrameStateAccess newState) {
@@ -319,6 +318,8 @@
         } else {
             if (!C1XOptions.AssumeVerifiedBytecode && !existingState.isCompatibleWith(newState)) {
                 // stacks or locks do not match--bytecodes would not verify
+                TTY.println(existingState.toString());
+                TTY.println(newState.duplicate(0).toString());
                 throw new CiBailout("stack or locks do not match");
             }
             assert existingState.localsSize() == newState.localsSize();
@@ -427,6 +428,7 @@
             FrameState stateWithException = entryState.duplicateModified(bci, CiKind.Void, exception);
 
             Instruction successor = createTarget(dispatchBlock, stateWithException);
+            //exception.appendNext(successor);
             BlockEnd end = new Goto(successor, graph);
             exception.appendNext(end);
 
@@ -610,7 +612,7 @@
     }
 
     private void genGoto(int fromBCI, int toBCI) {
-        append(new Goto(createTargetAt(toBCI, frameState), graph));
+        appendGoto(createTargetAt(toBCI, frameState));
     }
 
     private void ifNode(Value x, Condition cond, Value y) {
@@ -1065,6 +1067,10 @@
         assert block != null && stateAfter != null;
         assert block.isLoopHeader || block.firstInstruction == null || block.firstInstruction.next() == null : "non-loop block must be iterated after all its predecessors";
 
+        if (block.isExceptionEntry) {
+            assert stateAfter.stackSize() == 1;
+        }
+
         if (block.firstInstruction == null) {
             if (block.isLoopHeader) {
                 block.firstInstruction = new BlockBegin(block.startBci, block.blockID, block.isLoopHeader, graph);
@@ -1165,17 +1171,26 @@
                 deopt.setMessage("unresolved " + block.handler.catchType().name());
                 append(deopt);
                 Instruction nextDispatch = createTarget(block.next, frameState);
-                append(new Goto(nextDispatch, graph));
+                appendGoto(nextDispatch);
             }
         }
     }
 
+    private void appendGoto(Instruction target) {
+        //lastInstr.appendNext(target);
+        append(new Goto(target, graph));
+    }
+
+    private void appendGoto2(Instruction target) {
+        lastInstr.appendNext(target);
+        //append(new Goto(target, graph));
+    }
+
     private void iterateBytecodesForBlock(Block block) {
         assert frameState != null;
 
         stream.setBCI(block.startBci);
 
-        BlockEnd end = null;
         int endBCI = stream.endBCI();
         boolean blockStart = true;
 
@@ -1183,10 +1198,10 @@
         while (bci < endBCI) {
             Block nextBlock = blockFromBci[bci];
             if (nextBlock != null && nextBlock != block) {
+                assert !nextBlock.isExceptionEntry;
                 // we fell through to the next block, add a goto and break
                 Instruction next = createTarget(nextBlock, frameState);
-                end = new Goto(next, graph);
-                lastInstr = lastInstr.appendNext(end);
+                appendGoto(next);
                 break;
             }
             // read the opcode
@@ -1196,10 +1211,10 @@
             traceInstruction(bci, opcode, blockStart);
             processBytecode(bci, opcode);
 
-            if (lastInstr instanceof BlockEnd) {
-                end = (BlockEnd) lastInstr;
+            if (lastInstr instanceof BlockEnd || lastInstr.next() != null) {
                 break;
             }
+
             stream.next();
             bci = stream.currentBCI();
             if (lastInstr instanceof StateSplit) {