# HG changeset patch # User Gilles Duboscq # Date 1339161079 -7200 # Node ID cedae73d9c2aa296de6e670dc1aa98890cfc63db # Parent 62952fa9e7aa29218cbaf38d76c64099298fc0ea Fix problem with jython and tmt Make loop peeling work when there is no frame state on the loop begin diff -r 62952fa9e7aa -r cedae73d9c2a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopEx.java --- 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(); + } } diff -r 62952fa9e7aa -r cedae73d9c2a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragment.java --- 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); diff -r 62952fa9e7aa -r cedae73d9c2a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragmentInside.java --- 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); } diff -r 62952fa9e7aa -r cedae73d9c2a graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java --- 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);