changeset 19374:2412408a4319

Fixes to the graph builder after recent changes.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sat, 14 Feb 2015 15:29:49 +0100
parents 03adf6499fee
children 3d750310932f
files graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Sat Feb 14 15:19:55 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Sat Feb 14 15:29:49 2015 +0100
@@ -1158,6 +1158,9 @@
             }
 
             public <T extends FloatingNode> T append(T v) {
+                if (v.graph() != null) {
+                    return v;
+                }
                 T added = currentGraph.unique(v);
                 return added;
             }
@@ -1696,10 +1699,6 @@
                     condition = logicNegationNode.getValue();
                 }
 
-                if (condition.graph() == null) {
-                    condition = currentGraph.unique(condition);
-                }
-
                 if (condition instanceof LogicConstantNode) {
                     LogicConstantNode constantLogicNode = (LogicConstantNode) condition;
                     boolean value = constantLogicNode.getValue();
@@ -1713,7 +1712,12 @@
                     appendGoto(nextBlock);
                 } else {
 
+                    if (condition.graph() == null) {
+                        condition = currentGraph.unique(condition);
+                    }
+
                     if (trueBlock.getSuccessorCount() == 1 && falseBlock.getSuccessorCount() == 1 && trueBlock.getSuccessor(0) == falseBlock.getSuccessor(0)) {
+                        int oldBci = stream.currentBCI();
                         int trueBlockInt = checkPositiveIntConstantPushed(trueBlock);
                         if (trueBlockInt != -1) {
                             int falseBlockInt = checkPositiveIntConstantPushed(falseBlock);
@@ -1731,6 +1735,7 @@
                                 }
                                 frameState.push(Kind.Int, conditionalNode);
                                 appendGoto(trueBlock.getSuccessor(0));
+                                stream.setBCI(oldBci);
                                 return;
                             }
                         }
@@ -1749,9 +1754,12 @@
                 stream.setBCI(block.startBci);
                 int currentBC = stream.currentBC();
                 if (currentBC >= Bytecodes.ICONST_0 && currentBC <= Bytecodes.ICONST_5) {
-                    stream.nextBCI();
-                    if (stream.currentBCI() <= block.endBci || currentBC == Bytecodes.GOTO || currentBC == Bytecodes.GOTO_W) {
-                        return currentBC - Bytecodes.ICONST_0;
+                    int constValue = currentBC - Bytecodes.ICONST_0;
+                    int currentBCI = stream.nextBCI();
+                    stream.setBCI(currentBCI);
+                    currentBC = stream.currentBC();
+                    if (stream.currentBCI() > block.endBci || currentBC == Bytecodes.GOTO || currentBC == Bytecodes.GOTO_W) {
+                        return constValue;
                     }
                 }
                 return -1;