changeset 16059:bab1a955411e

Backed out changeset: 23c4dd4f72a3 (avoid duplication of frame states during unrolling)
author Lukas Stadler <lukas.stadler@oracle.com>
date Fri, 06 Jun 2014 13:29:00 +0200
parents 45bd621d9bb9
children 1629244c0df2
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/OnStackReplacementPhase.java graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInsideBefore.java graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInsideFrom.java graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentWhole.java graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopTransformations.java graal/com.oracle.graal.loop/src/com/oracle/graal/loop/phases/LoopTransformHighPhase.java
diffstat 8 files changed, 39 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/OnStackReplacementPhase.java	Fri Jun 06 12:16:45 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/OnStackReplacementPhase.java	Fri Jun 06 13:29:00 2014 +0200
@@ -73,7 +73,7 @@
                 break;
             }
 
-            LoopTransformations.peel(osrLoop, true);
+            LoopTransformations.peel(osrLoop);
             for (Node usage : osr.usages().snapshot()) {
                 ProxyNode proxy = (ProxyNode) usage;
                 proxy.replaceAndDelete(proxy.value());
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java	Fri Jun 06 12:16:45 2014 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java	Fri Jun 06 13:29:00 2014 +0200
@@ -57,9 +57,9 @@
         return loop;
     }
 
-    public abstract LoopFragment duplicate(boolean createExitFrameStates);
+    public abstract LoopFragment duplicate();
 
-    public abstract void insertBefore(LoopEx l, boolean createExitFrameStates);
+    public abstract void insertBefore(LoopEx l);
 
     public void disconnect() {
         // TODO (gd) possibly abstract
@@ -299,7 +299,7 @@
      * Merges the early exits (i.e. loop exits) that were duplicated as part of this fragment, with
      * the original fragment's exits.
      */
-    protected void mergeEarlyExits(boolean createExitFrameStates) {
+    protected void mergeEarlyExits() {
         assert isDuplicate();
         StructuredGraph graph = graph();
         for (BeginNode earlyExit : LoopFragment.toHirBlocks(original().loop().lirLoop().getExits())) {
@@ -325,24 +325,19 @@
             FrameState state = null;
             if (exitState != null) {
                 state = exitState;
+                exitState = exitState.duplicateWithVirtualState();
+                loopEarlyExit.setStateAfter(exitState);
                 merge.setStateAfter(state);
-
-                if (createExitFrameStates) {
-                    exitState = exitState.duplicateWithVirtualState();
-                    loopEarlyExit.setStateAfter(exitState);
-                    /*
-                     * Using the old exit's state as the merge's state is necessary because some of
-                     * the VirtualState nodes contained in the old exit's state may be shared by
-                     * other dominated VirtualStates. Those dominated virtual states need to see the
-                     * proxy->phi update that are applied below.
-                     * 
-                     * We now update the original fragment's nodes accordingly:
-                     */
-                    state.applyToVirtual(node -> original.nodes.clearAndGrow(node));
-                    exitState.applyToVirtual(node -> original.nodes.markAndGrow(node));
-                } else {
-                    loopEarlyExit.setStateAfter(null);
-                }
+                /*
+                 * Using the old exit's state as the merge's state is necessary because some of the
+                 * VirtualState nodes contained in the old exit's state may be shared by other
+                 * dominated VirtualStates. Those dominated virtual states need to see the
+                 * proxy->phi update that are applied below.
+                 *
+                 * We now update the original fragment's nodes accordingly:
+                 */
+                state.applyToVirtual(node -> original.nodes.clearAndGrow(node));
+                exitState.applyToVirtual(node -> original.nodes.markAndGrow(node));
             }
             FrameState finalExitState = exitState;
 
@@ -378,7 +373,7 @@
                     if (merge.isPhiAtMerge(usage)) {
                         return false;
                     }
-                    if (finalExitState != null && usage instanceof VirtualState) {
+                    if (usage instanceof VirtualState) {
                         VirtualState stateUsage = (VirtualState) usage;
                         if (finalExitState.isPartOfThisState(stateUsage)) {
                             return false;
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java	Fri Jun 06 12:16:45 2014 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java	Fri Jun 06 13:29:00 2014 +0200
@@ -63,7 +63,7 @@
     }
 
     @Override
-    public LoopFragmentInside duplicate(boolean createExitFrameStates) {
+    public LoopFragmentInside duplicate() {
         assert !isDuplicate();
         return new LoopFragmentInside(this);
     }
@@ -85,14 +85,14 @@
     }
 
     @Override
-    public void insertBefore(LoopEx loop, boolean createExitFrameStates) {
+    public void insertBefore(LoopEx loop) {
         assert this.isDuplicate() && this.original().loop() == loop;
 
         patchNodes(dataFixBefore);
 
         BeginNode end = mergeEnds();
 
-        mergeEarlyExits(createExitFrameStates);
+        mergeEarlyExits();
 
         original().patchPeeling(this);
 
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInsideBefore.java	Fri Jun 06 12:16:45 2014 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInsideBefore.java	Fri Jun 06 13:29:00 2014 +0200
@@ -45,7 +45,7 @@
     }
 
     @Override
-    public LoopFragmentInsideBefore duplicate(boolean createExitFrameStates) {
+    public LoopFragmentInsideBefore duplicate() {
         return new LoopFragmentInsideBefore(this);
     }
 
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInsideFrom.java	Fri Jun 06 12:16:45 2014 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInsideFrom.java	Fri Jun 06 13:29:00 2014 +0200
@@ -45,7 +45,7 @@
     }
 
     @Override
-    public LoopFragmentInsideFrom duplicate(boolean createExitFrameStates) {
+    public LoopFragmentInsideFrom duplicate() {
         return new LoopFragmentInsideFrom(this);
     }
 
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentWhole.java	Fri Jun 06 12:16:45 2014 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentWhole.java	Fri Jun 06 13:29:00 2014 +0200
@@ -39,18 +39,18 @@
     }
 
     @Override
-    public LoopFragmentWhole duplicate(boolean createExitFrameStates) {
+    public LoopFragmentWhole duplicate() {
         LoopFragmentWhole loopFragmentWhole = new LoopFragmentWhole(this);
-        loopFragmentWhole.reify(createExitFrameStates);
+        loopFragmentWhole.reify();
         return loopFragmentWhole;
     }
 
-    private void reify(boolean createExitFrameStates) {
+    private void reify() {
         assert this.isDuplicate();
 
         patchNodes(null);
 
-        mergeEarlyExits(createExitFrameStates);
+        mergeEarlyExits();
     }
 
     @Override
@@ -102,7 +102,7 @@
     }
 
     @Override
-    public void insertBefore(LoopEx loop, boolean createExitFrameStates) {
+    public void insertBefore(LoopEx loop) {
         // TODO Auto-generated method stub
 
     }
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopTransformations.java	Fri Jun 06 12:16:45 2014 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopTransformations.java	Fri Jun 06 13:29:00 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,14 +44,14 @@
 
     public static void invert(LoopEx loop, FixedNode point) {
         LoopFragmentInsideBefore head = loop.insideBefore(point);
-        LoopFragmentInsideBefore duplicate = head.duplicate(true);
+        LoopFragmentInsideBefore duplicate = head.duplicate();
         head.disconnect();
-        head.insertBefore(loop, true);
+        head.insertBefore(loop);
         duplicate.appendInside(loop);
     }
 
-    public static void peel(LoopEx loop, boolean createExitFrameStates) {
-        loop.inside().duplicate(createExitFrameStates).insertBefore(loop, createExitFrameStates);
+    public static void peel(LoopEx loop) {
+        loop.inside().duplicate().insertBefore(loop);
     }
 
     public static void fullUnroll(LoopEx loop, PhaseContext context, CanonicalizerPhase canonicalizer) {
@@ -61,7 +61,7 @@
         StructuredGraph graph = loopBegin.graph();
         while (!loopBegin.isDeleted()) {
             Mark mark = graph.getMark();
-            peel(loop, false);
+            peel(loop);
             canonicalizer.applyIncremental(graph, context, mark);
             loopBegin.removeDeadPhis();
             loop.invalidateFragments();
@@ -88,7 +88,7 @@
         while (successors.hasNext()) {
             Position position = successors.nextPosition();
             // create a new loop duplicate, connect it and simplify it
-            LoopFragmentWhole duplicateLoop = originalLoop.duplicate(true);
+            LoopFragmentWhole duplicateLoop = originalLoop.duplicate();
             controlSplitClass.set(newControlSplit, position, BeginNode.begin(duplicateLoop.entryPoint()));
             ControlSplitNode duplicatedControlSplit = duplicateLoop.getDuplicatedNode(controlSplitNode);
             graph.removeSplitPropagate(duplicatedControlSplit, (BeginNode) controlSplitClass.get(duplicatedControlSplit, position));
@@ -105,8 +105,8 @@
         }
         // TODO (gd) implement counted loop
         LoopFragmentWhole main = loop.whole();
-        LoopFragmentWhole prologue = main.duplicate(true);
-        prologue.insertBefore(loop, false);
+        LoopFragmentWhole prologue = main.duplicate();
+        prologue.insertBefore(loop);
         // CountedLoopBeginNode counted = prologue.countedLoop();
         // StructuredGraph graph = (StructuredGraph) counted.graph();
         // ValueNode tripCountPrologue = counted.tripCount();
@@ -115,7 +115,7 @@
         // graph.replaceFloating(tripCountMain, "tripCountMain - (tripCountPrologue % factor)");
         LoopFragmentInside inside = loop.inside();
         for (int i = 0; i < factor; i++) {
-            inside.duplicate(false).appendInside(loop);
+            inside.duplicate().appendInside(loop);
         }
     }
 
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/phases/LoopTransformHighPhase.java	Fri Jun 06 12:16:45 2014 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/phases/LoopTransformHighPhase.java	Fri Jun 06 13:29:00 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
                 for (LoopEx loop : data.outterFirst()) {
                     if (LoopPolicies.shouldPeel(loop, probabilities)) {
                         Debug.log("Peeling %s", loop);
-                        LoopTransformations.peel(loop, true);
+                        LoopTransformations.peel(loop);
                         Debug.dump(graph, "After peeling %s", loop);
                     }
                 }