changeset 13494:ab4c3a33a8b1

Bugfix: node successors are unordered, so emitting a jump to the first successor hits a random target
author Christian Wimmer <christian.wimmer@oracle.com>
date Fri, 03 Jan 2014 11:46:35 -0800
parents 03bb0ee05409
children 818d2885db2f
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Thu Jan 02 18:02:01 2014 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Fri Jan 03 11:46:35 2014 -0800
@@ -486,9 +486,17 @@
                 }
             }
         }
-        if (block.getSuccessorCount() >= 1 && !hasBlockEnd(block)) {
+
+        if (!hasBlockEnd(block)) {
             NodeClassIterable successors = block.getEndNode().successors();
-            assert successors.isNotEmpty() : "should have at least one successor : " + block.getEndNode();
+            assert successors.count() == block.getSuccessorCount();
+            if (block.getSuccessorCount() != 1) {
+                /*
+                 * If we have more than one successor, we cannot just use the first one. Since
+                 * successors are unordered, this would be a random choice.
+                 */
+                throw new GraalInternalError("Block without BlockEndOp: " + block.getEndNode());
+            }
             emitJump(getLIRBlock((FixedNode) successors.first()));
         }
 
@@ -731,6 +739,10 @@
         if (isLegal(result)) {
             setResult(x.asNode(), emitMove(result));
         }
+
+        if (x instanceof InvokeWithExceptionNode) {
+            emitJump(getLIRBlock(((InvokeWithExceptionNode) x).next()));
+        }
     }
 
     protected abstract void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState);