# HG changeset patch # User Gilles Duboscq # Date 1340881828 -7200 # Node ID 1d2eeb28537f076197d3e0b39bc757be7368a40a # Parent e4b9af013c4a90b749fc1f2ce6f2e94402c7ba33# Parent dfcb73ac6ba2b4ee0b9da83c93579fddf1862e75 Merge diff -r dfcb73ac6ba2 -r 1d2eeb28537f 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 Thu Jun 28 11:30:21 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragment.java Thu Jun 28 13:10:28 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 blocks, Collection 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() { + @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); } } diff -r dfcb73ac6ba2 -r 1d2eeb28537f 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 Thu Jun 28 11:30:21 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopFragmentInside.java Thu Jun 28 13:10:28 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) { diff -r dfcb73ac6ba2 -r 1d2eeb28537f graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/InliningPhase.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/InliningPhase.java Thu Jun 28 11:30:21 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/InliningPhase.java Thu Jun 28 13:10:28 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() { @@ -196,8 +195,7 @@ return cachedGraph; } } - - + StructuredGraph newGraph = new StructuredGraph(method); if (plan != null) { plan.runPhases(PhasePosition.AFTER_PARSING, newGraph); } diff -r dfcb73ac6ba2 -r 1d2eeb28537f graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ArrayCopySnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ArrayCopySnippets.java Thu Jun 28 11:30:21 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/ArrayCopySnippets.java Thu Jun 28 13:10:28 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); diff -r dfcb73ac6ba2 -r 1d2eeb28537f graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java Thu Jun 28 11:30:21 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java Thu Jun 28 13:10:28 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; + } } diff -r dfcb73ac6ba2 -r 1d2eeb28537f graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/VirtualState.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/VirtualState.java Thu Jun 28 11:30:21 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/VirtualState.java Thu Jun 28 13:10:28 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 closure); + public abstract void applyToVirtual(VirtualClosure closure); + + public abstract boolean isPartOfThisState(VirtualState state); + } diff -r dfcb73ac6ba2 -r 1d2eeb28537f graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualObjectState.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualObjectState.java Thu Jun 28 11:30:21 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualObjectState.java Thu Jun 28 13:10:28 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); + } }