# HG changeset patch # User Roland Schatz # Date 1385395560 -3600 # Node ID 640516a8ca6b68772c00c0c4cb69ee3fb45ca892 # Parent 5801a5e3e7e4dbc519f66d68a0705b46d730bf6b Separate class for MemoryProxy and MemoryPhi. diff -r 5801a5e3e7e4 -r 640516a8ca6b graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java Mon Nov 25 17:04:39 2013 +0100 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java Mon Nov 25 17:06:00 2013 +0100 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.Graph.DuplicationReplacement; import com.oracle.graal.graph.iterators.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.VirtualState.NodeClosure; import com.oracle.graal.nodes.VirtualState.VirtualClosure; import com.oracle.graal.nodes.cfg.*; @@ -313,7 +312,20 @@ final ValueNode replaceWith; ProxyNode newVpn = getDuplicatedNode(vpn); if (newVpn != null) { - PhiNode phi = graph.addWithoutUnique(vpn.type() == PhiType.Value ? new PhiNode(vpn.kind(), merge) : new PhiNode(vpn.type(), merge, vpn.getIdentity())); + PhiNode phi; + switch (vpn.type()) { + case Value: + phi = graph.addWithoutUnique(new PhiNode(vpn.kind(), merge)); + break; + case Guard: + phi = graph.addWithoutUnique(new PhiNode(vpn.type(), merge)); + break; + case Memory: + phi = graph.addWithoutUnique(new MemoryPhiNode(merge, ((MemoryProxyNode) vpn).getLocationIdentity())); + break; + default: + throw GraalInternalError.shouldNotReachHere(); + } phi.addInput(vpn); phi.addInput(newVpn); replaceWith = phi; diff -r 5801a5e3e7e4 -r 640516a8ca6b graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java Mon Nov 25 17:04:39 2013 +0100 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java Mon Nov 25 17:06:00 2013 +0100 @@ -166,6 +166,24 @@ // TODO (gd) ? } + private static PhiNode patchPhi(StructuredGraph graph, PhiNode phi, MergeNode merge) { + PhiNode ret; + switch (phi.type()) { + case Value: + ret = new PhiNode(phi.kind(), merge); + break; + case Guard: + ret = new PhiNode(PhiType.Guard, merge); + break; + case Memory: + ret = new MemoryPhiNode(merge, ((MemoryPhiNode) phi).getLocationIdentity()); + break; + default: + throw GraalInternalError.shouldNotReachHere(); + } + return graph.addWithoutUnique(ret); + } + private void patchPeeling(LoopFragmentInside peel) { LoopBeginNode loopBegin = loop().loopBegin(); StructuredGraph graph = loopBegin.graph(); @@ -180,7 +198,7 @@ } // create a new phi (we don't patch the old one since some usages of the old one may // still be valid) - PhiNode newPhi = graph.addWithoutUnique(phi.type() == PhiType.Value ? new PhiNode(phi.kind(), loopBegin) : new PhiNode(phi.type(), loopBegin, phi.getIdentity())); + PhiNode newPhi = patchPhi(graph, phi, loopBegin); newPhi.addInput(first); for (LoopEndNode end : loopBegin.orderedLoopEnds()) { newPhi.addInput(phi.valueAt(end)); @@ -270,7 +288,7 @@ } for (final PhiNode phi : loopBegin.phis().snapshot()) { - final PhiNode firstPhi = graph.addWithoutUnique(phi.type() == PhiType.Value ? new PhiNode(phi.kind(), newExitMerge) : new PhiNode(phi.type(), newExitMerge, phi.getIdentity())); + final PhiNode firstPhi = patchPhi(graph, phi, newExitMerge); for (AbstractEndNode end : newExitMerge.forwardEnds()) { LoopEndNode loopEnd = reverseEnds.get(end); ValueNode prim = prim(phi.valueAt(loopEnd)); diff -r 5801a5e3e7e4 -r 640516a8ca6b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryPhiNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryPhiNode.java Mon Nov 25 17:06:00 2013 +0100 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2009, 2011, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.nodes; + +import com.oracle.graal.api.meta.*; + +/** + * The {@code PhiNode} represents the merging of dataflow in the memory graph. + */ +public class MemoryPhiNode extends PhiNode { + + private final LocationIdentity identity; + + public MemoryPhiNode(MergeNode merge, LocationIdentity identity) { + super(PhiType.Memory, merge); + this.identity = identity; + } + + public LocationIdentity getLocationIdentity() { + return identity; + } +} diff -r 5801a5e3e7e4 -r 640516a8ca6b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryProxyNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryProxyNode.java Mon Nov 25 17:06:00 2013 +0100 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.nodes; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.nodes.PhiNode.PhiType; +import com.oracle.graal.nodes.spi.*; + +public class MemoryProxyNode extends ProxyNode implements MemoryProxy, LIRLowerable { + + private final LocationIdentity identity; + + public MemoryProxyNode(ValueNode value, AbstractBeginNode exit, LocationIdentity identity) { + super(value, exit, PhiType.Memory); + this.identity = identity; + } + + public LocationIdentity getLocationIdentity() { + return identity; + } + + @Override + public void generate(LIRGeneratorTool generator) { + } + + public static MemoryProxyNode forMemory(ValueNode value, AbstractBeginNode exit, LocationIdentity location, StructuredGraph graph) { + return graph.unique(new MemoryProxyNode(value, exit, location)); + } +} diff -r 5801a5e3e7e4 -r 640516a8ca6b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java Mon Nov 25 17:04:39 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java Mon Nov 25 17:06:00 2013 +0100 @@ -51,7 +51,6 @@ @Input(notDataflow = true) private MergeNode merge; @Input private final NodeInputList values = new NodeInputList<>(this); private final PhiType type; - private final LocationIdentity identity; /** * Create a value phi ({@link PhiType#Value}) with the specified kind. @@ -68,7 +67,6 @@ assert stamp != StampFactory.forVoid(); this.type = PhiType.Value; this.merge = merge; - this.identity = null; } /** @@ -77,12 +75,11 @@ * @param type the type of the new phi * @param merge the merge that the new phi belongs to */ - public PhiNode(PhiType type, MergeNode merge, LocationIdentity identity) { + public PhiNode(PhiType type, MergeNode merge) { super(type.stamp); assert type.stamp != null : merge + " " + type; this.type = type; this.merge = merge; - this.identity = identity; } public PhiType type() { @@ -93,11 +90,6 @@ return merge; } - public LocationIdentity getIdentity() { - assert type != PhiType.Value; - return identity; - } - public void setMerge(MergeNode x) { updateUsages(merge, x); merge = x; diff -r 5801a5e3e7e4 -r 640516a8ca6b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ProxyNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ProxyNode.java Mon Nov 25 17:04:39 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ProxyNode.java Mon Nov 25 17:06:00 2013 +0100 @@ -22,7 +22,6 @@ */ package com.oracle.graal.nodes; -import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.Node.ValueNumberable; import com.oracle.graal.graph.spi.*; @@ -37,17 +36,15 @@ * loop. */ @NodeInfo(nameTemplate = "{p#type/s}Proxy") -public class ProxyNode extends FloatingNode implements IterableNodeType, ValueNumberable, Canonicalizable, Virtualizable, LIRLowerable, ValueProxy, GuardingNode { +public class ProxyNode extends FloatingNode implements IterableNodeType, ValueNumberable, Canonicalizable, Virtualizable, ValueProxy, GuardingNode { @Input(notDataflow = true) private AbstractBeginNode proxyPoint; @Input private ValueNode value; private final PhiType type; - private final LocationIdentity identity; - public ProxyNode(ValueNode value, AbstractBeginNode exit, PhiType type, LocationIdentity identity) { + public ProxyNode(ValueNode value, AbstractBeginNode exit, PhiType type) { super(type == PhiType.Value ? value.stamp() : type.stamp); this.type = type; - this.identity = identity; assert exit != null; this.proxyPoint = exit; this.value = value; @@ -70,11 +67,6 @@ return type; } - public LocationIdentity getIdentity() { - assert type != PhiType.Value; - return identity; - } - @Override public boolean verify() { assert value != null; @@ -84,11 +76,6 @@ } @Override - public void generate(LIRGeneratorTool generator) { - assert type == PhiType.Memory; - } - - @Override public Node canonical(CanonicalizerTool tool) { if (type == PhiType.Value && value.isConstant()) { return value; @@ -107,15 +94,11 @@ } public static ProxyNode forGuard(ValueNode value, AbstractBeginNode exit, StructuredGraph graph) { - return graph.unique(new ProxyNode(value, exit, PhiType.Guard, null)); + return graph.unique(new ProxyNode(value, exit, PhiType.Guard)); } public static ProxyNode forValue(ValueNode value, AbstractBeginNode exit, StructuredGraph graph) { - return graph.unique(new ProxyNode(value, exit, PhiType.Value, null)); - } - - public static ProxyNode forMemory(ValueNode value, AbstractBeginNode exit, LocationIdentity location, StructuredGraph graph) { - return graph.unique(new ProxyNode(value, exit, PhiType.Memory, location)); + return graph.unique(new ProxyNode(value, exit, PhiType.Value)); } @Override diff -r 5801a5e3e7e4 -r 640516a8ca6b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/MemoryProxy.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/MemoryProxy.java Mon Nov 25 17:06:00 2013 +0100 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.nodes.spi; + +import com.oracle.graal.api.meta.*; + +public interface MemoryProxy extends ValueProxy { + + LocationIdentity getLocationIdentity(); +} diff -r 5801a5e3e7e4 -r 640516a8ca6b graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Mon Nov 25 17:04:39 2013 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Mon Nov 25 17:06:00 2013 +0100 @@ -28,7 +28,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.graph.*; @@ -262,7 +261,7 @@ } else if (merged == null) { merged = last; } else { - PhiNode phi = merge.graph().addWithoutUnique(new PhiNode(PhiType.Memory, merge, key)); + MemoryPhiNode phi = merge.graph().addWithoutUnique(new MemoryPhiNode(merge, key)); for (int j = 0; j < mergedStatesCount; j++) { phi.addInput(merged); } @@ -306,7 +305,7 @@ Map phis = new HashMap<>(); for (LocationIdentity location : modifiedLocations) { - PhiNode phi = loop.graph().addWithoutUnique(new PhiNode(PhiType.Memory, loop, location)); + MemoryPhiNode phi = loop.graph().addWithoutUnique(new MemoryPhiNode(loop, location)); phi.addInput(initialState.getLastLocationAccess(location)); phis.put(location, phi); initialState.lastMemorySnapshot.put(location, phi); @@ -328,7 +327,7 @@ for (LocationIdentity location : modifiedLocations) { ValueNode lastAccessAtExit = state.lastMemorySnapshot.get(location); if (lastAccessAtExit != null) { - state.lastMemorySnapshot.put(location, ProxyNode.forMemory(lastAccessAtExit, exit, location, loop.graph())); + state.lastMemorySnapshot.put(location, MemoryProxyNode.forMemory(lastAccessAtExit, exit, location, loop.graph())); } } } diff -r 5801a5e3e7e4 -r 640516a8ca6b graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Mon Nov 25 17:04:39 2013 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Mon Nov 25 17:06:00 2013 +0100 @@ -33,7 +33,6 @@ import com.oracle.graal.graph.*; import com.oracle.graal.graph.Node.Verbosity; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.extended.*; @@ -286,14 +285,12 @@ KillSet excludedLocations = new KillSet(); if (block.getBeginNode() instanceof MergeNode) { MergeNode mergeNode = (MergeNode) block.getBeginNode(); - for (PhiNode phi : mergeNode.usages().filter(PhiNode.class)) { - if (phi.type() == PhiType.Memory) { - if (foundExcludeNode) { - set.add(phi.getIdentity()); - } else { - excludedLocations.add(phi.getIdentity()); - foundExcludeNode = phi == excludeNode; - } + for (MemoryPhiNode phi : mergeNode.usages().filter(MemoryPhiNode.class)) { + if (foundExcludeNode) { + set.add(phi.getLocationIdentity()); + } else { + excludedLocations.add(phi.getLocationIdentity()); + foundExcludeNode = phi == excludeNode; } } } diff -r 5801a5e3e7e4 -r 640516a8ca6b graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java Mon Nov 25 17:04:39 2013 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java Mon Nov 25 17:06:00 2013 +0100 @@ -380,7 +380,7 @@ } else if (usage instanceof ProxyNode) { ProxyNode proxy = (ProxyNode) usage; assert proxy.type() == PhiType.Value; - ProxyNode newProxy = graph.unique(new ProxyNode((ValueNode) intrinsifiedNode, proxy.proxyPoint(), PhiType.Value, proxy.getIdentity())); + ProxyNode newProxy = graph.unique(new ProxyNode((ValueNode) intrinsifiedNode, proxy.proxyPoint(), PhiType.Value)); for (Node proxyUsage : usage.usages().snapshot()) { checkCheckCastUsage(graph, newProxy, proxy, proxyUsage); } diff -r 5801a5e3e7e4 -r 640516a8ca6b graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java Mon Nov 25 17:04:39 2013 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java Mon Nov 25 17:06:00 2013 +0100 @@ -114,7 +114,7 @@ if (initialState.getReadCache().get(entry.getKey()) != entry.getValue()) { ValueNode value = exitState.getReadCache(entry.getKey().object, entry.getKey().identity, this); if (!(value instanceof ProxyNode) || ((ProxyNode) value).proxyPoint() != exitNode) { - ProxyNode proxy = new ProxyNode(value, exitNode, PhiType.Value, null); + ProxyNode proxy = new ProxyNode(value, exitNode, PhiType.Value); effects.addFloatingNode(proxy, "readCacheProxy"); entry.setValue(proxy); } diff -r 5801a5e3e7e4 -r 640516a8ca6b graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java Mon Nov 25 17:04:39 2013 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java Mon Nov 25 17:06:00 2013 +0100 @@ -247,7 +247,7 @@ ValueNode value = obj.getEntry(i); if (!(value instanceof VirtualObjectNode || value.isConstant())) { if (exitNode.loopBegin().isPhiAtMerge(value) || initialObj == null || !initialObj.isVirtual() || initialObj.getEntry(i) != value) { - ProxyNode proxy = new ProxyNode(value, exitNode, PhiType.Value, null); + ProxyNode proxy = new ProxyNode(value, exitNode, PhiType.Value); obj.setEntry(i, proxy); effects.addFloatingNode(proxy, "virtualProxy"); } @@ -257,7 +257,7 @@ if (initialObj == null || initialObj.isVirtual()) { ProxyNode proxy = proxies.get(obj.virtual); if (proxy == null) { - proxy = new ProxyNode(obj.getMaterializedValue(), exitNode, PhiType.Value, null); + proxy = new ProxyNode(obj.getMaterializedValue(), exitNode, PhiType.Value); effects.addFloatingNode(proxy, "proxy"); } else { effects.replaceFirstInput(proxy, proxy.value(), obj.getMaterializedValue()); diff -r 5801a5e3e7e4 -r 640516a8ca6b graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java Mon Nov 25 17:04:39 2013 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java Mon Nov 25 17:06:00 2013 +0100 @@ -171,7 +171,7 @@ protected void processLoopExit(LoopExitNode exitNode, ReadEliminationBlockState initialState, ReadEliminationBlockState exitState, GraphEffectList effects) { for (Map.Entry, ValueNode> entry : exitState.getReadCache().entrySet()) { if (initialState.getReadCache().get(entry.getKey()) != entry.getValue()) { - ProxyNode proxy = new ProxyNode(exitState.getCacheEntry(entry.getKey()), exitNode, PhiType.Value, null); + ProxyNode proxy = new ProxyNode(exitState.getCacheEntry(entry.getKey()), exitNode, PhiType.Value); effects.addFloatingNode(proxy, "readCacheProxy"); entry.setValue(proxy); }