changeset 5519:cedae73d9c2a

Fix problem with jython and tmt Make loop peeling work when there is no frame state on the loop begin
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 08 Jun 2012 15:11:19 +0200
parents 62952fa9e7aa
children e05bb6f6c58b
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopEx.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragment.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragmentInside.java graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java
diffstat 4 files changed, 31 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopEx.java	Fri Jun 08 11:52:37 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopEx.java	Fri Jun 08 15:11:19 2012 +0200
@@ -96,4 +96,9 @@
     public int size() {
         return whole().nodes().count();
     }
+
+    @Override
+    public String toString() {
+        return isCounted() ? "Counted" : "" + "Loop (depth=" + lirLoop().depth + ") " + loopBegin();
+    }
 }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragment.java	Fri Jun 08 11:52:37 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragment.java	Fri Jun 08 15:11:19 2012 +0200
@@ -227,8 +227,11 @@
             newEarlyExit.setNext(newEnd);
             merge.setNext(next);
             FrameState exitState = earlyExit.stateAfter();
-            FrameState state = exitState.duplicate();
-            merge.setStateAfter(state);
+            FrameState state = null;
+            if (exitState != null) {
+                state = exitState.duplicate();
+                merge.setStateAfter(state);
+            }
 
             for (Node anchored : earlyExit.anchored().snapshot()) {
                 anchored.replaceFirstInput(earlyExit, merge);
@@ -252,7 +255,9 @@
                 } else {
                     replaceWith = vpn.value();
                 }
-                state.replaceFirstInput(vpn, replaceWith);
+                if (state != null) {
+                    state.replaceFirstInput(vpn, replaceWith);
+                }
                 for (Node usage : vpn.usages().snapshot()) {
                     if (usage != exitState && !merge.isPhiAtMerge(usage)) {
                         usage.replaceFirstInput(vpn, replaceWith);
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragmentInside.java	Fri Jun 08 11:52:37 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragmentInside.java	Fri Jun 08 15:11:19 2012 +0200
@@ -86,7 +86,12 @@
 
         mergeEarlyExits();
 
-        FixedNode entry = getDuplicatedNode(this.loop().loopBegin());
+        BeginNode entry = getDuplicatedNode(this.loop().loopBegin());
+        FrameState state = entry.stateAfter();
+        if (state != null) {
+            entry.setStateAfter(null);
+            GraphUtil.killWithUnusedFloatingInputs(state);
+        }
         loop.entryPoint().replaceAtPredecessor(entry);
         end.setNext(loop.entryPoint());
     }
@@ -97,11 +102,8 @@
             LoopFragmentWhole whole = loop().whole();
             whole.nodes(); // init nodes bitmap in whole
             nodes = whole.nodes.copy();
-            // remove the loop begin, its FS and the phis
-            LoopBeginNode loopBegin = loop().loopBegin();
-            //nodes.clear(loopBegin);
-            nodes.clear(loopBegin.stateAfter());
-            for (PhiNode phi : loopBegin.phis()) {
+            // remove the phis
+            for (PhiNode phi : loop().loopBegin().phis()) {
                 nodes.clear(phi);
             }
         }
@@ -221,8 +223,12 @@
             assert endsToMerge.size() > 1;
             MergeNode newExitMerge = graph.add(new MergeNode());
             newExit = newExitMerge;
-            FrameState duplicateState = loopBegin.stateAfter().duplicate();
-            newExitMerge.setStateAfter(duplicateState);
+            FrameState state = loopBegin.stateAfter();
+            FrameState duplicateState = null;
+            if (state != null) {
+                duplicateState = state.duplicate();
+                newExitMerge.setStateAfter(duplicateState);
+            }
             for (EndNode end : endsToMerge) {
                 newExitMerge.addForwardEnd(end);
             }
@@ -236,7 +242,9 @@
                     firstPhi.addInput(prim);
                 }
                 ValueNode initializer = firstPhi;
-                duplicateState.replaceFirstInput(phi, firstPhi); // fix the merge's state after
+                if (duplicateState != null) {
+                    duplicateState.replaceFirstInput(phi, firstPhi); // fix the merge's state after
+                }
                 if (phi.type() == PhiType.Virtual) {
                     initializer = GraphUtil.mergeVirtualChain(graph, firstPhi, newExitMerge);
                 }
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Fri Jun 08 11:52:37 2012 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Fri Jun 08 15:11:19 2012 +0200
@@ -924,6 +924,7 @@
                 assert !node.isDeleted() : "trying to duplicate deleted node";
                 Node replacement = replacements.replacement(node);
                 if (replacement != node) {
+                    assert replacement != null;
                     newNodes.put(node, replacement);
                 } else {
                     Node newNode = node.clone(graph);