diff graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2769:dd6419f4bfe2

Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Mon, 23 May 2011 21:21:47 +0200
parents 43ffa0e47a46
children 056e392d63d4
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Mon May 23 19:21:53 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Mon May 23 21:21:47 2011 +0200
@@ -685,8 +685,8 @@
         If ifNode = new If(x, cond, y, null, graph);
         append(ifNode);
         Instruction tsucc = createTargetAt(stream().readBranchDest(), frameState);
+        ifNode.setBlockSuccessor(0, tsucc);
         Instruction fsucc = createTargetAt(stream().nextBCI(), frameState);
-        ifNode.setBlockSuccessor(0, tsucc);
         ifNode.setBlockSuccessor(1, fsucc);
     }
 
@@ -1056,19 +1056,21 @@
         BytecodeTableSwitch ts = new BytecodeTableSwitch(stream(), bci);
         int max = ts.numberOfCases();
         List<Instruction> list = new ArrayList<Instruction>(max + 1);
-        boolean isBackwards = false;
+        List<Integer> offsetList = new ArrayList<Integer>(max + 1);
         for (int i = 0; i < max; i++) {
             // add all successors to the successor list
             int offset = ts.offsetAt(i);
-            list.add(createTargetAt(bci + offset, frameState));
-            isBackwards |= offset < 0; // track if any of the successors are backwards
+            list.add(null);
+            offsetList.add(offset);
         }
         int offset = ts.defaultOffset();
-        isBackwards |= offset < 0; // if the default successor is backwards
-        list.add(createTargetAt(bci + offset, frameState));
-        boolean isSafepoint = isBackwards && !noSafepoints();
-        FrameState stateAfter = isSafepoint ? frameState.create(bci()) : null;
-        append(new TableSwitch(value, list, ts.lowKey(), stateAfter, graph));
+        list.add(null);
+        offsetList.add(offset);
+        TableSwitch tableSwitch = new TableSwitch(value, list, ts.lowKey(), null, graph);
+        for (int i = 0; i < offsetList.size(); ++i) {
+            tableSwitch.setBlockSuccessor(i, createTargetAt(bci + offsetList.get(i), frameState));
+        }
+        append(tableSwitch);
     }
 
     private void genLookupswitch() {
@@ -1077,21 +1079,23 @@
         BytecodeLookupSwitch ls = new BytecodeLookupSwitch(stream(), bci);
         int max = ls.numberOfCases();
         List<Instruction> list = new ArrayList<Instruction>(max + 1);
+        List<Integer> offsetList = new ArrayList<Integer>(max + 1);
         int[] keys = new int[max];
-        boolean isBackwards = false;
         for (int i = 0; i < max; i++) {
             // add all successors to the successor list
             int offset = ls.offsetAt(i);
-            list.add(createTargetAt(bci + offset, frameState));
+            list.add(null);
+            offsetList.add(offset);
             keys[i] = ls.keyAt(i);
-            isBackwards |= offset < 0; // track if any of the successors are backwards
         }
         int offset = ls.defaultOffset();
-        isBackwards |= offset < 0; // if the default successor is backwards
-        list.add(createTargetAt(bci + offset, frameState));
-        boolean isSafepoint = isBackwards && !noSafepoints();
-        FrameState stateAfter = isSafepoint ? frameState.create(bci()) : null;
-        append(new LookupSwitch(value, list, keys, stateAfter, graph));
+        list.add(null);
+        offsetList.add(offset);
+        LookupSwitch lookupSwitch = new LookupSwitch(value, list, keys, null, graph);
+        for (int i = 0; i < offsetList.size(); ++i) {
+            lookupSwitch.setBlockSuccessor(i, createTargetAt(bci + offsetList.get(i), frameState));
+        }
+        append(lookupSwitch);
     }
 
     private Value appendConstant(CiConstant constant) {