changeset 5671:a65b2a11bf34

Fix for peeling and VirtualStateNode FrameState.applyToNonVirtual now applies to outter framestates and give usage node in the closure
author Gilles Duboscq <duboscq@ssw.jku.at>
date Thu, 21 Jun 2012 16:26:59 +0200
parents 29684ae5a194
children 272ad540c464
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragmentInside.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/CheckCastSnippets.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/VirtualState.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualObjectState.java
diffstat 7 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java	Wed Jun 20 16:59:47 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java	Thu Jun 21 16:26:59 2012 +0200
@@ -153,7 +153,7 @@
         } else if (value != null) {
             Debug.metric("StateVariables").increment();
             Value operand = nodeOperands.get(value);
-            assert operand != null && (operand instanceof Variable || operand instanceof Constant) : operand;
+            assert operand != null && (operand instanceof Variable || operand instanceof Constant) : operand + " for " + value;
             return operand;
 
         } else {
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragmentInside.java	Wed Jun 20 16:59:47 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragmentInside.java	Thu Jun 21 16:26:59 2012 +0200
@@ -28,6 +28,7 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.iterators.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.VirtualState.NodeClosure;
 import com.oracle.graal.nodes.PhiNode.*;
 import com.oracle.graal.nodes.util.*;
 
@@ -235,8 +236,8 @@
                 newExitMerge.addForwardEnd(end);
             }
 
-            for (PhiNode phi : loopBegin.phis().snapshot()) {
-                PhiNode firstPhi = graph.add(phi.type() == PhiType.Value ? new PhiNode(phi.kind(), newExitMerge) : new PhiNode(phi.type(), newExitMerge));
+            for (final PhiNode phi : loopBegin.phis().snapshot()) {
+                final PhiNode firstPhi = graph.add(phi.type() == PhiType.Value ? new PhiNode(phi.kind(), newExitMerge) : new PhiNode(phi.type(), newExitMerge));
                 for (EndNode end : newExitMerge.forwardEnds()) {
                     LoopEndNode loopEnd = reverseEnds.get(end);
                     ValueNode prim = prim(phi.valueAt(loopEnd));
@@ -245,7 +246,15 @@
                 }
                 ValueNode initializer = firstPhi;
                 if (duplicateState != null) {
-                    duplicateState.replaceFirstInput(phi, firstPhi); // fix the merge's state after
+                    // fix the merge's state after
+                    duplicateState.applyToNonVirtual(new NodeClosure<ValueNode>() {
+                        @Override
+                        public void apply(Node from, ValueNode node) {
+                            if (node == phi) {
+                                from.replaceFirstInput(phi, firstPhi);
+                            }
+                        }
+                    });
                 }
                 mergedInitializers.put(phi, initializer);
             }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/CheckCastSnippets.java	Wed Jun 20 16:59:47 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/CheckCastSnippets.java	Thu Jun 21 16:26:59 2012 +0200
@@ -34,7 +34,6 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.*;
-import com.oracle.graal.compiler.phases.*;
 import com.oracle.graal.cri.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java	Wed Jun 20 16:59:47 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java	Thu Jun 21 16:26:59 2012 +0200
@@ -33,7 +33,6 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.phases.*;
 import com.oracle.graal.cri.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Wed Jun 20 16:59:47 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Thu Jun 21 16:26:59 2012 +0200
@@ -392,10 +392,13 @@
     @Override
     public void applyToNonVirtual(NodeClosure< ? super ValueNode> closure) {
         for (ValueNode value : values.nonNull()) {
-            closure.apply(value);
+            closure.apply(this, value);
         }
         for (VirtualObjectState state : virtualObjectMappings) {
             state.applyToNonVirtual(closure);
         }
+        if (outerFrameState() != null) {
+            outerFrameState().applyToNonVirtual(closure);
+        }
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/VirtualState.java	Wed Jun 20 16:59:47 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/VirtualState.java	Thu Jun 21 16:26:59 2012 +0200
@@ -31,7 +31,7 @@
 public abstract class VirtualState extends Node {
 
     public interface NodeClosure<T extends Node> {
-        void apply(T node);
+        void apply(Node usage, T node);
     }
 
     public abstract VirtualState duplicateWithVirtualState();
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualObjectState.java	Wed Jun 20 16:59:47 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualObjectState.java	Thu Jun 21 16:26:59 2012 +0200
@@ -69,7 +69,7 @@
     @Override
     public void applyToNonVirtual(NodeClosure< ? super ValueNode> closure) {
         for (ValueNode value : fieldValues) {
-            closure.apply(value);
+            closure.apply(this, value);
         }
     }
 }