changeset 5727:42f3dac334f9

Merge.
author Doug Simon <doug.simon@oracle.com>
date Thu, 28 Jun 2012 14:10:30 +0200
parents 4e5828456c28 (current diff) 1d2eeb28537f (diff)
children 956217932b8c
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/InliningPhase.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java
diffstat 7 files changed, 76 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragment.java	Thu Jun 28 14:09:11 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragment.java	Thu Jun 28 14:10:30 2012 +0200
@@ -30,6 +30,7 @@
 import com.oracle.graal.lir.cfg.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.PhiNode.PhiType;
+import com.oracle.graal.nodes.VirtualState.*;
 
 
 public abstract class LoopFragment {
@@ -139,7 +140,7 @@
     }
 
     protected static NodeBitMap computeNodes(Graph graph, Collection<BeginNode> blocks, Collection<BeginNode> earlyExits) {
-        NodeBitMap nodes = graph.createNodeBitMap(true);
+        final NodeBitMap nodes = graph.createNodeBitMap(true);
         for (BeginNode b : blocks) {
             for (Node n : b.getBlockNodes()) {
                 if (n instanceof Invoke) {
@@ -158,6 +159,12 @@
             FrameState stateAfter = earlyExit.stateAfter();
             if (stateAfter != null) {
                 nodes.mark(stateAfter);
+                stateAfter.applyToVirtual(new VirtualClosure() {
+                    @Override
+                    public void apply(VirtualState node) {
+                        nodes.mark(node);
+                    }
+                });
             }
             nodes.mark(earlyExit);
             for (ValueProxyNode proxy : earlyExit.proxies()) {
@@ -229,9 +236,10 @@
             merge.setNext(next);
 
             FrameState exitState = earlyExit.stateAfter();
+            FrameState newExitState = newEarlyExit.stateAfter();
             FrameState state = null;
             if (exitState != null) {
-                state = exitState.duplicate();
+                state = exitState.duplicateWithVirtualState();
                 merge.setStateAfter(state);
             }
 
@@ -239,8 +247,8 @@
                 anchored.replaceFirstInput(earlyExit, merge);
             }
 
-            for (ValueProxyNode vpn : earlyExit.proxies().snapshot()) {
-                ValueNode replaceWith;
+            for (final ValueProxyNode vpn : earlyExit.proxies().snapshot()) {
+                final ValueNode replaceWith;
                 ValueProxyNode newVpn = getDuplicatedNode(vpn);
                 if (newVpn != null) {
                     PhiNode phi = graph.add(vpn.type() == PhiType.Value ? new PhiNode(vpn.kind(), merge) : new PhiNode(vpn.type(), merge));
@@ -251,10 +259,23 @@
                     replaceWith = vpn.value();
                 }
                 if (state != null) {
-                    state.replaceFirstInput(vpn, replaceWith);
+                    state.applyToNonVirtual(new NodeClosure<ValueNode>() {
+                        @Override
+                        public void apply(Node from, ValueNode node) {
+                            if (node == vpn) {
+                                from.replaceFirstInput(vpn, replaceWith);
+                            }
+                        }
+                    });
                 }
                 for (Node usage : vpn.usages().snapshot()) {
-                    if (usage != exitState && !merge.isPhiAtMerge(usage)) {
+                    if (!merge.isPhiAtMerge(usage)) {
+                        if (usage instanceof VirtualState) {
+                            VirtualState stateUsage = (VirtualState) usage;
+                            if (exitState.isPartOfThisState(stateUsage) || newExitState.isPartOfThisState(stateUsage)) {
+                                continue;
+                            }
+                        }
                         usage.replaceFirstInput(vpn, replaceWith);
                     }
                 }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragmentInside.java	Thu Jun 28 14:09:11 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragmentInside.java	Thu Jun 28 14:10:30 2012 +0200
@@ -229,7 +229,7 @@
             FrameState state = loopBegin.stateAfter();
             FrameState duplicateState = null;
             if (state != null) {
-                duplicateState = state.duplicate();
+                duplicateState = state.duplicateWithVirtualState();
                 newExitMerge.setStateAfter(duplicateState);
             }
             for (EndNode end : endsToMerge) {
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/InliningPhase.java	Thu Jun 28 14:09:11 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/InliningPhase.java	Thu Jun 28 14:10:30 2012 +0200
@@ -184,7 +184,6 @@
 
     @Override
     public StructuredGraph buildGraph(final ResolvedJavaMethod method) {
-        final StructuredGraph newGraph = new StructuredGraph(method);
 
         return Debug.scope("buildInlineGraph", this, new Callable<StructuredGraph>() {
 
@@ -196,8 +195,7 @@
                         return cachedGraph;
                     }
                 }
-
-
+                StructuredGraph newGraph = new StructuredGraph(method);
                 if (plan != null) {
                     plan.runPhases(PhasePosition.AFTER_PARSING, newGraph);
                 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ArrayCopySnippets.java	Thu Jun 28 14:09:11 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ArrayCopySnippets.java	Thu Jun 28 14:10:30 2012 +0200
@@ -318,8 +318,8 @@
             int cardShift = cardTableShift();
             long cardStart = cardTableStart();
             long dstAddr = GetObjectAddressNode.get(dest);
-            long start = (dstAddr + header + destPos * scale) >>> cardShift;
-            long end = (dstAddr + header + (destPos + length - 1) * scale) >>> cardShift;
+            long start = (dstAddr + header + (long) destPos * scale) >>> cardShift;
+            long end = (dstAddr + header + ((long) destPos + length - 1) * scale) >>> cardShift;
             long count = end - start + 1;
             while (count-- > 0) {
                 DirectStoreNode.store((start + cardStart) + count, false);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Thu Jun 28 14:09:11 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Thu Jun 28 14:10:30 2012 +0200
@@ -400,4 +400,31 @@
             outerFrameState().applyToNonVirtual(closure);
         }
     }
+
+    @Override
+    public void applyToVirtual(VirtualClosure closure) {
+        closure.apply(this);
+        for (VirtualObjectState state : virtualObjectMappings) {
+            state.applyToVirtual(closure);
+        }
+        if (outerFrameState() != null) {
+            outerFrameState().applyToVirtual(closure);
+        }
+    }
+
+    @Override
+    public boolean isPartOfThisState(VirtualState state) {
+        if (state == this) {
+            return true;
+        }
+        if (outerFrameState() != null && outerFrameState().isPartOfThisState(state)) {
+            return true;
+        }
+        for (VirtualObjectState objectState : virtualObjectMappings) {
+            if (objectState.isPartOfThisState(state)) {
+                return true;
+            }
+        }
+        return false;
+    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/VirtualState.java	Thu Jun 28 14:09:11 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/VirtualState.java	Thu Jun 28 14:10:30 2012 +0200
@@ -34,8 +34,16 @@
         void apply(Node usage, T node);
     }
 
+    public interface VirtualClosure {
+        void apply(VirtualState node);
+    }
+
     public abstract VirtualState duplicateWithVirtualState();
 
     public abstract void applyToNonVirtual(NodeClosure<? super ValueNode> closure);
 
+    public abstract void applyToVirtual(VirtualClosure closure);
+
+    public abstract boolean isPartOfThisState(VirtualState state);
+
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualObjectState.java	Thu Jun 28 14:09:11 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualObjectState.java	Thu Jun 28 14:10:30 2012 +0200
@@ -72,4 +72,14 @@
             closure.apply(this, value);
         }
     }
+
+    @Override
+    public boolean isPartOfThisState(VirtualState state) {
+        return this == state;
+    }
+
+    @Override
+    public void applyToVirtual(VirtualClosure closure) {
+        closure.apply(this);
+    }
 }