# HG changeset patch # User Lukas Stadler # Date 1396629152 -7200 # Node ID e302df8bf51cc7d59ed097e422880f49bce14239 # Parent cd9404a8216b09a5581e4b2176bfbe4ae4617276 separate subclasses for value and guard phis and proxies diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PhiCreationTests.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PhiCreationTests.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PhiCreationTests.java Fri Apr 04 18:32:32 2014 +0200 @@ -41,7 +41,7 @@ @Test public void test1() { StructuredGraph graph = parse("test1Snippet"); - Assert.assertFalse(graph.getNodes().filter(PhiNode.class).iterator().hasNext()); + Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext()); } public static int test1Snippet(int a) { @@ -54,7 +54,7 @@ @Test public void test2() { StructuredGraph graph = parse("test2Snippet"); - Assert.assertFalse(graph.getNodes().filter(PhiNode.class).iterator().hasNext()); + Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext()); } public static int test2Snippet(int a) { @@ -68,7 +68,7 @@ public void test3() { StructuredGraph graph = parse("test3Snippet"); Debug.dump(graph, "Graph"); - Assert.assertFalse(graph.getNodes().filter(PhiNode.class).iterator().hasNext()); + Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext()); } public static int test3Snippet(int a) { @@ -84,7 +84,7 @@ public void test4() { StructuredGraph graph = parse("test4Snippet"); Debug.dump(graph, "Graph"); - Assert.assertFalse(graph.getNodes().filter(PhiNode.class).iterator().hasNext()); + Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext()); } public static int test4Snippet(int a) { diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EAMergingTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EAMergingTest.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EAMergingTest.java Fri Apr 04 18:32:32 2014 +0200 @@ -34,7 +34,7 @@ public void testSimpleMerge() { testEscapeAnalysis("simpleMergeSnippet", null, false); assertEquals(1, returnNodes.size()); - assertTrue(returnNodes.get(0).result() instanceof PhiNode); + assertTrue(returnNodes.get(0).result() instanceof ValuePhiNode); PhiNode phi = (PhiNode) returnNodes.get(0).result(); assertTrue(phi.valueAt(0) instanceof ParameterNode); assertTrue(phi.valueAt(1) instanceof ParameterNode); diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java Fri Apr 04 18:32:32 2014 +0200 @@ -164,7 +164,7 @@ ValueNode result = getReturn("testBadLoopSnippet").result(); assertEquals(0, graph.getNodes().filter(LoadFieldNode.class).count()); assertTrue(result instanceof ProxyNode); - assertTrue(((ProxyNode) result).value() instanceof PhiNode); + assertTrue(((ProxyNode) result).value() instanceof ValuePhiNode); } @SuppressWarnings("all") diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/UnsafeEATest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/UnsafeEATest.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/UnsafeEATest.java Fri Apr 04 18:32:32 2014 +0200 @@ -87,7 +87,7 @@ public void testMergedDouble() { testEscapeAnalysis("testMergedDoubleSnippet", null, false); Assert.assertEquals(1, returnNodes.size()); - Assert.assertTrue(returnNodes.get(0).result() instanceof PhiNode); + Assert.assertTrue(returnNodes.get(0).result() instanceof ValuePhiNode); PhiNode phi = (PhiNode) returnNodes.get(0).result(); Assert.assertTrue(phi.valueAt(0) instanceof LoadFieldNode); Assert.assertTrue(phi.valueAt(1) instanceof LoadFieldNode); diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Fri Apr 04 18:32:32 2014 +0200 @@ -39,7 +39,6 @@ import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.JumpOp; 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.*; @@ -464,9 +463,9 @@ } PhiResolver resolver = new PhiResolver(gen); for (PhiNode phi : merge.phis()) { - if (phi.type() == PhiType.Value) { + if (phi instanceof ValuePhiNode) { ValueNode curVal = phi.valueAt(pred); - resolver.move(operandForPhi(phi), operand(curVal)); + resolver.move(operandForPhi((ValuePhiNode) phi), operand(curVal)); } } resolver.dispose(); @@ -478,8 +477,7 @@ return gen.getPlatformKind(phi.stamp()); } - private Value operandForPhi(PhiNode phi) { - assert phi.type() == PhiType.Value : "wrong phi type: " + phi; + private Value operandForPhi(ValuePhiNode phi) { Value result = getOperand(phi); if (result == null) { // allocate a variable for this phi diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/PhiResolver.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/PhiResolver.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/PhiResolver.java Fri Apr 04 18:32:32 2014 +0200 @@ -32,7 +32,7 @@ import com.oracle.graal.nodes.*; /** - * Converts {@link PhiNode} instructions into moves. + * Converts {@link ValuePhiNode} instructions into moves. * * Resolves cycles: * diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java Fri Apr 04 18:32:32 2014 +0200 @@ -192,7 +192,7 @@ } else if (block.isPhiAtMerge(currentValue)) { if (otherValue == null || otherValue.isDeleted() || currentValue.getKind() != otherValue.getKind()) { - propagateDelete((PhiNode) currentValue); + propagateDelete((ValuePhiNode) currentValue); return null; } ((PhiNode) currentValue).addInput(otherValue); @@ -204,7 +204,7 @@ return null; } - PhiNode phi = graph.addWithoutUnique(new PhiNode(currentValue.stamp().unrestricted(), block)); + ValuePhiNode phi = graph.addWithoutUnique(new ValuePhiNode(currentValue.stamp().unrestricted(), block)); for (int i = 0; i < block.phiPredecessorCount(); i++) { phi.addInput(currentValue); } @@ -218,16 +218,16 @@ } private void propagateDelete(FloatingNode node) { - assert node instanceof PhiNode || node instanceof ProxyNode; + assert node instanceof ValuePhiNode || node instanceof ProxyNode; if (node.isDeleted()) { return; } // Collect all phi functions that use this phi so that we can delete them recursively (after // we delete ourselves to avoid circles). - List propagateUsages = node.usages().filter(FloatingNode.class).filter(isA(PhiNode.class).or(ProxyNode.class)).snapshot(); + List propagateUsages = node.usages().filter(FloatingNode.class).filter(isA(ValuePhiNode.class).or(ProxyNode.class)).snapshot(); // Remove the phi function from all FrameStates where it is used and then delete it. - assert node.usages().filter(isNotA(FrameState.class).nor(PhiNode.class).nor(ProxyNode.class)).isEmpty() : "phi function that gets deletes must only be used in frame states"; + assert node.usages().filter(isNotA(FrameState.class).nor(ValuePhiNode.class).nor(ProxyNode.class)).isEmpty() : "phi function that gets deletes must only be used in frame states"; node.replaceAtUsages(null); node.safeDelete(); @@ -296,13 +296,13 @@ } } - private PhiNode createLoopPhi(MergeNode block, ValueNode value) { + private ValuePhiNode createLoopPhi(MergeNode block, ValueNode value) { if (value == null) { return null; } assert !block.isPhiAtMerge(value) : "phi function for this block already created"; - PhiNode phi = graph.addWithoutUnique(new PhiNode(value.stamp().unrestricted(), block)); + ValuePhiNode phi = graph.addWithoutUnique(new ValuePhiNode(value.stamp().unrestricted(), block)); phi.addInput(value); return phi; } @@ -310,7 +310,7 @@ public void cleanupDeletedPhis() { for (int i = 0; i < localsSize(); i++) { if (localAt(i) != null && localAt(i).isDeleted()) { - assert localAt(i) instanceof PhiNode || localAt(i) instanceof ProxyNode : "Only phi and value proxies can be deleted during parsing: " + localAt(i); + assert localAt(i) instanceof ValuePhiNode || localAt(i) instanceof ProxyNode : "Only phi and value proxies can be deleted during parsing: " + localAt(i); storeLocal(i, null); } } diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java Fri Apr 04 18:32:32 2014 +0200 @@ -29,12 +29,12 @@ public class BasicInductionVariable extends InductionVariable { - private PhiNode phi; + private ValuePhiNode phi; private ValueNode init; private ValueNode rawStride; private IntegerArithmeticNode op; - public BasicInductionVariable(LoopEx loop, PhiNode phi, ValueNode init, ValueNode rawStride, IntegerArithmeticNode op) { + public BasicInductionVariable(LoopEx loop, ValuePhiNode phi, ValueNode init, ValueNode rawStride, IntegerArithmeticNode op) { super(loop); this.phi = phi; this.init = init; @@ -71,7 +71,7 @@ } @Override - public PhiNode valueNode() { + public ValuePhiNode valueNode() { return phi; } diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java Fri Apr 04 18:32:32 2014 +0200 @@ -54,7 +54,7 @@ } ValueNode stride = addSub(backValue, phi); if (stride != null) { - BasicInductionVariable biv = new BasicInductionVariable(loop, phi, phi.valueAt(forwardEnd), stride, (IntegerArithmeticNode) backValue); + BasicInductionVariable biv = new BasicInductionVariable(loop, (ValuePhiNode) phi, phi.valueAt(forwardEnd), stride, (IntegerArithmeticNode) backValue); ivs.put(phi, biv); bivs.add(biv); } diff -r cd9404a8216b -r e302df8bf51c 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 Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java Fri Apr 04 18:32:32 2014 +0200 @@ -330,18 +330,14 @@ ProxyNode newVpn = getDuplicatedNode(vpn); if (newVpn != null) { PhiNode phi; - switch (vpn.type()) { - case Value: - phi = graph.addWithoutUnique(new PhiNode(vpn.stamp(), 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(); + if (vpn instanceof ValueProxyNode) { + phi = graph.addWithoutUnique(new ValuePhiNode(vpn.stamp(), merge)); + } else if (vpn instanceof GuardProxyNode) { + phi = graph.addWithoutUnique(new GuardPhiNode(merge)); + } else if (vpn instanceof MemoryProxyNode) { + phi = graph.addWithoutUnique(new MemoryPhiNode(merge, ((MemoryProxyNode) vpn).getLocationIdentity())); + } else { + throw GraalInternalError.shouldNotReachHere(); } phi.addInput(vpn); phi.addInput(newVpn); diff -r cd9404a8216b -r e302df8bf51c 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 Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java Fri Apr 04 18:32:32 2014 +0200 @@ -24,11 +24,10 @@ import java.util.*; +import com.oracle.graal.graph.*; import com.oracle.graal.graph.Graph.DuplicationReplacement; -import com.oracle.graal.graph.*; 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.util.*; @@ -41,7 +40,7 @@ * peeling case. In the unrolling case they will be used as the value that replace the loop-phis * of the duplicated inside fragment */ - private Map mergedInitializers; + private Map mergedInitializers; private final DuplicationReplacement dataFixBefore = new DuplicationReplacement() { @Override @@ -168,18 +167,14 @@ private static PhiNode patchPhi(StructuredGraph graph, PhiNode phi, MergeNode merge) { PhiNode ret; - switch (phi.type()) { - case Value: - ret = new PhiNode(phi.stamp(), 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(); + if (phi instanceof ValuePhiNode) { + ret = new ValuePhiNode(phi.stamp(), merge); + } else if (phi instanceof GuardPhiNode) { + ret = new GuardPhiNode(merge); + } else if (phi instanceof MemoryPhiNode) { + ret = new MemoryPhiNode(merge, ((MemoryPhiNode) phi).getLocationIdentity()); + } else { + throw GraalInternalError.shouldNotReachHere(); } return graph.addWithoutUnique(ret); } @@ -219,7 +214,7 @@ for (int i = 0; i < phi.valueCount(); i++) { ValueNode v = phi.valueAt(i); if (loopBegin.isPhiAtMerge(v)) { - PhiNode newV = peel.getDuplicatedNode((PhiNode) v); + PhiNode newV = peel.getDuplicatedNode((ValuePhiNode) v); if (newV != null) { phi.setValueAt(i, newV); } @@ -230,7 +225,7 @@ /** * Gets the corresponding value in this fragment. - * + * * @param b original value * @return corresponding value in the peel */ @@ -308,7 +303,7 @@ } }); } - mergedInitializers.put(phi, initializer); + mergedInitializers.put((ValuePhiNode) phi, initializer); } } return newExit; diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardPhiNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardPhiNode.java Fri Apr 04 18:32:32 2014 +0200 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2009, 2014, 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.graph.*; +import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.nodes.type.*; + +@NodeInfo(nameTemplate = "GuardPhi({i#values})") +public class GuardPhiNode extends PhiNode implements GuardingNode { + + @Input final NodeInputList values = new NodeInputList<>(this); + + public GuardPhiNode(MergeNode merge) { + super(StampFactory.dependency(), merge); + } + + @Override + public NodeInputList values() { + return values; + } +} diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardProxyNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardProxyNode.java Fri Apr 04 18:32:32 2014 +0200 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2012, 2014, 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.nodes.extended.*; +import com.oracle.graal.nodes.type.*; + +public class GuardProxyNode extends ProxyNode implements GuardingNode { + + @Input private ValueNode value; + + public GuardProxyNode(ValueNode value, AbstractBeginNode proxyPoint) { + super(StampFactory.dependency(), proxyPoint); + this.value = value; + } + + @Override + public ValueNode value() { + return value; + } +} diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Fri Apr 04 18:32:32 2014 +0200 @@ -31,7 +31,6 @@ import com.oracle.graal.graph.*; import com.oracle.graal.graph.iterators.*; import com.oracle.graal.graph.spi.*; -import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; @@ -514,12 +513,12 @@ return false; } Node singleUsage = mergeUsages.first(); - if (!(singleUsage instanceof PhiNode) || (singleUsage != compare.x() && singleUsage != compare.y())) { + if (!(singleUsage instanceof ValuePhiNode) || (singleUsage != compare.x() && singleUsage != compare.y())) { return false; } // Ensure phi is used by at most the comparison and the merge's frame state (if any) - PhiNode phi = (PhiNode) singleUsage; + ValuePhiNode phi = (ValuePhiNode) singleUsage; NodeIterable phiUsages = phi.usages(); if (phiUsages.count() > 2) { return false; @@ -650,7 +649,7 @@ // removed MergeNode newMerge = graph().add(new MergeNode()); PhiNode oldPhi = (PhiNode) oldMerge.usages().first(); - PhiNode newPhi = graph().addWithoutUnique(new PhiNode(oldPhi.stamp(), newMerge)); + PhiNode newPhi = graph().addWithoutUnique(new ValuePhiNode(oldPhi.stamp(), newMerge)); for (AbstractEndNode end : ends) { newPhi.addInput(phiValues.get(end)); @@ -687,7 +686,7 @@ if (node instanceof PhiNode) { PhiNode phi = (PhiNode) node; - if (phi.merge() == merge && phi.type() == PhiType.Value && phi.valueCount() == merge.forwardEndCount()) { + if (phi.merge() == merge && phi instanceof ValuePhiNode && phi.valueCount() == merge.forwardEndCount()) { Constant[] result = new Constant[merge.forwardEndCount()]; int i = 0; for (ValueNode n : phi.values()) { diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryPhiNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryPhiNode.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryPhiNode.java Fri Apr 04 18:32:32 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, 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 @@ -23,22 +23,25 @@ package com.oracle.graal.nodes; import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.nodes.type.*; /** * The {@code PhiNode} represents the merging of dataflow in the memory graph. */ public class MemoryPhiNode extends PhiNode implements MemoryNode { - private final LocationIdentity identity; + @Input final NodeInputList values = new NodeInputList<>(this); + private final LocationIdentity locationIdentity; - public MemoryPhiNode(MergeNode merge, LocationIdentity identity) { - super(PhiType.Memory, merge); - this.identity = identity; + public MemoryPhiNode(MergeNode merge, LocationIdentity locationIdentity) { + super(StampFactory.dependency(), merge); + this.locationIdentity = locationIdentity; } public LocationIdentity getLocationIdentity() { - return identity; + return locationIdentity; } public MemoryCheckpoint asMemoryCheckpoint() { @@ -48,4 +51,9 @@ public MemoryPhiNode asMemoryPhi() { return this; } + + @Override + public NodeInputList values() { + return values; + } } diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryProxyNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryProxyNode.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryProxyNode.java Fri Apr 04 18:32:32 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, 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 @@ -23,20 +23,27 @@ package com.oracle.graal.nodes; import com.oracle.graal.api.meta.*; -import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; public class MemoryProxyNode extends ProxyNode implements MemoryProxy, LIRLowerable { + @Input private ValueNode value; private final LocationIdentity identity; public MemoryProxyNode(ValueNode value, AbstractBeginNode exit, LocationIdentity identity) { - super(value, exit, PhiType.Memory); + super(StampFactory.dependency(), exit); + this.value = value; assert value instanceof MemoryNode; this.identity = identity; } + @Override + public ValueNode value() { + return value; + } + public LocationIdentity getLocationIdentity() { return identity; } @@ -47,14 +54,10 @@ @Override public boolean verify() { - assert value() instanceof MemoryNode; + assert value() instanceof MemoryNode : this + " " + value(); return super.verify(); } - public static MemoryProxyNode forMemory(MemoryNode value, AbstractBeginNode exit, LocationIdentity location, StructuredGraph graph) { - return graph.unique(new MemoryProxyNode(ValueNodeUtil.asNode(value), exit, location)); - } - public MemoryNode getOriginalMemoryNode() { return (MemoryNode) value(); } diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MergeNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MergeNode.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MergeNode.java Fri Apr 04 18:32:32 2014 +0200 @@ -210,7 +210,7 @@ } } - PhiNode returnValuePhi = returnNode.result() == null || !isPhiAtMerge(returnNode.result()) ? null : (PhiNode) returnNode.result(); + ValuePhiNode returnValuePhi = returnNode.result() == null || !isPhiAtMerge(returnNode.result()) ? null : (ValuePhiNode) returnNode.result(); List endNodes = forwardEnds().snapshot(); for (AbstractEndNode end : endNodes) { ReturnNode newReturn = graph().add(new ReturnNode(returnValuePhi == null ? returnNode.result() : returnValuePhi.valueAt(end))); diff -r cd9404a8216b -r e302df8bf51c 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 Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java Fri Apr 04 18:32:32 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, 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 @@ -25,61 +25,18 @@ import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.calc.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.type.*; -/** - * The {@code PhiNode} represents the merging of dataflow in the graph. It refers to a merge and a - * variable. - */ -@NodeInfo(nameTemplate = "{p#type/s}Phi({i#values})") -public class PhiNode extends FloatingNode implements Canonicalizable, GuardingNode { - - public static enum PhiType { - Value(null), // normal value phis - Guard(StampFactory.dependency()), - Memory(StampFactory.dependency()); - - public final Stamp stamp; - - PhiType(Stamp stamp) { - this.stamp = stamp; - } - } +public abstract class PhiNode extends FloatingNode { @Input(notDataflow = true) private MergeNode merge; - @Input private final NodeInputList values = new NodeInputList<>(this); - private final PhiType type; - /** - * Create a value phi ({@link PhiType#Value}) with the specified stamp. - * - * @param stamp the stamp of the value - * @param merge the merge that the new phi belongs to - */ - public PhiNode(Stamp stamp, MergeNode merge) { + protected PhiNode(Stamp stamp, MergeNode merge) { super(stamp); - assert stamp != StampFactory.forVoid(); - this.type = PhiType.Value; this.merge = merge; } - /** - * Create a non-value phi ({@link PhiType#Memory} with the specified kind. - * - * @param type the type of the new phi - * @param merge the merge that the new phi belongs to - */ - public PhiNode(PhiType type, MergeNode merge) { - super(type.stamp); - assert type.stamp != null : merge + " " + type; - this.type = type; - this.merge = merge; - } - - public PhiType type() { - return type; - } + public abstract NodeInputList values(); public MergeNode merge() { return merge; @@ -90,23 +47,6 @@ merge = x; } - public NodeInputList values() { - return values; - } - - @Override - public boolean inferStamp() { - if (type == PhiType.Value) { - return inferPhiStamp(); - } else { - return false; - } - } - - public boolean inferPhiStamp() { - return updateStamp(StampTool.meet(values())); - } - @Override public boolean verify() { assertTrue(merge() != null, "missing merge"); @@ -117,29 +57,29 @@ /** * Get the instruction that produces the value associated with the i'th predecessor of the * merge. - * + * * @param i the index of the predecessor * @return the instruction that produced the value in the i'th predecessor */ public ValueNode valueAt(int i) { - return values.get(i); + return values().get(i); } /** * Sets the value at the given index and makes sure that the values list is large enough. - * + * * @param i the index at which to set the value * @param x the new phi input value for the given location */ public void initializeValueAt(int i, ValueNode x) { while (values().size() <= i) { - values.add(null); + values().add(null); } - values.set(i, x); + values().set(i, x); } public void setValueAt(int i, ValueNode x) { - values.set(i, x); + values().set(i, x); } public ValueNode valueAt(AbstractEndNode pred) { @@ -148,15 +88,15 @@ /** * Get the number of inputs to this phi (i.e. the number of predecessors to the merge). - * + * * @return the number of inputs in this phi */ public int valueCount() { - return values.size(); + return values().size(); } public void clearValues() { - values.clear(); + values().clear(); } @Override @@ -169,24 +109,20 @@ } str.append(valueAt(i) == null ? "-" : valueAt(i).toString(Verbosity.Id)); } - if (type == PhiType.Value) { - return super.toString(Verbosity.Name) + "(" + str + ")"; - } else { - return type + super.toString(Verbosity.Name) + "(" + str + ")"; - } + return super.toString(Verbosity.Name) + "(" + str + ")"; } else { return super.toString(verbosity); } } public void addInput(ValueNode x) { - assert !(x instanceof PhiNode) || ((PhiNode) x).merge() instanceof LoopBeginNode || ((PhiNode) x).merge() != this.merge(); - assert x.stamp().isCompatible(stamp()) || type != PhiType.Value; - values.add(x); + assert !(x instanceof ValuePhiNode) || ((ValuePhiNode) x).merge() instanceof LoopBeginNode || ((ValuePhiNode) x).merge() != this.merge(); + assert !(this instanceof ValuePhiNode) || x.stamp().isCompatible(stamp()); + values().add(x); } public void removeInput(int index) { - values.remove(index); + values().remove(index); } public ValueNode singleValue() { diff -r cd9404a8216b -r e302df8bf51c 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 Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ProxyNode.java Fri Apr 04 18:32:32 2014 +0200 @@ -22,87 +22,56 @@ */ 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.*; -import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; /** - * A value proxy that is inserted in the frame state of a loop exit for any value that is created - * inside the loop (i.e. was not live on entry to the loop) and is (potentially) used after the - * loop. + * A proxy is inserted at loop exits for any value that is created inside the loop (i.e. was not + * live on entry to the loop) and is (potentially) used after the loop. */ -@NodeInfo(nameTemplate = "{p#type/s}Proxy") -public class ProxyNode extends FloatingNode implements IterableNodeType, ValueNumberable, Canonicalizable, Virtualizable, ValueAndStampProxy, GuardingNode { +public abstract class ProxyNode extends FloatingNode implements IterableNodeType, ValueNumberable, ValueAndStampProxy { @Input(notDataflow = true) private AbstractBeginNode proxyPoint; - @Input private ValueNode value; - private final PhiType type; - public ProxyNode(ValueNode value, AbstractBeginNode exit, PhiType type) { - super(type == PhiType.Value ? value.stamp() : type.stamp); - this.type = type; - assert exit != null; - this.proxyPoint = exit; - this.value = value; + public ProxyNode(Stamp stamp, AbstractBeginNode proxyPoint) { + super(stamp); + assert proxyPoint != null; + this.proxyPoint = proxyPoint; } - public ValueNode value() { - return value; - } - - @Override - public boolean inferStamp() { - return updateStamp(value.stamp()); - } + public abstract ValueNode value(); public AbstractBeginNode proxyPoint() { return proxyPoint; } - public PhiType type() { - return type; - } - @Override public boolean verify() { - assert value != null; + assert value() != null; assert proxyPoint != null; - assert !(value instanceof ProxyNode) || ((ProxyNode) value).proxyPoint != proxyPoint; + assert !(value() instanceof ProxyNode) || ((ProxyNode) value()).proxyPoint != proxyPoint; return super.verify(); } @Override - public Node canonical(CanonicalizerTool tool) { - if (type == PhiType.Value && value.isConstant()) { - return value; - } - return this; + public ValueNode getOriginalValue() { + return value(); + } + + public static MemoryProxyNode forMemory(MemoryNode value, AbstractBeginNode exit, LocationIdentity location, StructuredGraph graph) { + return graph.unique(new MemoryProxyNode(ValueNodeUtil.asNode(value), exit, location)); } - @Override - public void virtualize(VirtualizerTool tool) { - if (type == PhiType.Value) { - State state = tool.getObjectState(value); - if (state != null && state.getState() == EscapeState.Virtual) { - tool.replaceWithVirtual(state.getVirtualObject()); - } - } + public static ValueProxyNode forValue(ValueNode value, AbstractBeginNode exit, StructuredGraph graph) { + return graph.unique(new ValueProxyNode(value, exit)); } - public static ProxyNode forGuard(ValueNode value, AbstractBeginNode exit, StructuredGraph graph) { - 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)); - } - - @Override - public ValueNode getOriginalValue() { - return value; + public static GuardProxyNode forGuard(ValueNode value, AbstractBeginNode exit, StructuredGraph graph) { + return graph.unique(new GuardProxyNode(value, exit)); } } diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValuePhiNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValuePhiNode.java Fri Apr 04 18:32:32 2014 +0200 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2009, 2014, 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.graph.*; +import com.oracle.graal.graph.spi.*; +import com.oracle.graal.nodes.type.*; + +/** + * The {@code PhiNode} represents the merging of dataflow in the graph. It refers to a merge and a + * variable. + */ +@NodeInfo(nameTemplate = "ValuePhi({i#values})") +public class ValuePhiNode extends PhiNode implements Canonicalizable { + + @Input final NodeInputList values = new NodeInputList<>(this); + + /** + * Create a value phi with the specified stamp. + * + * @param stamp the stamp of the value + * @param merge the merge that the new phi belongs to + */ + public ValuePhiNode(Stamp stamp, MergeNode merge) { + super(stamp, merge); + assert stamp != StampFactory.forVoid(); + } + + @Override + public NodeInputList values() { + return values; + } + + @Override + public boolean inferStamp() { + return inferPhiStamp(); + } + + public boolean inferPhiStamp() { + return updateStamp(StampTool.meet(values())); + } +} diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueProxyNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueProxyNode.java Fri Apr 04 18:32:32 2014 +0200 @@ -0,0 +1,63 @@ +/* + * 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.graph.*; +import com.oracle.graal.graph.spi.*; +import com.oracle.graal.nodes.spi.*; + +public class ValueProxyNode extends ProxyNode implements Canonicalizable, Virtualizable { + + @Input private ValueNode value; + + public ValueProxyNode(ValueNode value, AbstractBeginNode proxyPoint) { + super(value.stamp(), proxyPoint); + this.value = value; + } + + @Override + public ValueNode value() { + return value; + } + + @Override + public boolean inferStamp() { + return updateStamp(value.stamp()); + } + + @Override + public Node canonical(CanonicalizerTool tool) { + if (value.isConstant()) { + return value; + } + return this; + } + + @Override + public void virtualize(VirtualizerTool tool) { + State state = tool.getObjectState(value); + if (state != null && state.getState() == EscapeState.Virtual) { + tool.replaceWithVirtual(state.getVirtualObject()); + } + } +} diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadFieldNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadFieldNode.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadFieldNode.java Fri Apr 04 18:32:32 2014 +0200 @@ -41,7 +41,7 @@ /** * Creates a new LoadFieldNode instance. - * + * * @param object the receiver object * @param field the compiler interface field */ @@ -97,7 +97,7 @@ } private PhiNode asPhi(MetaAccessProvider metaAccess) { - if (!isStatic() && Modifier.isFinal(field.getModifiers()) && object() instanceof PhiNode && ((PhiNode) object()).values().filter(NodePredicates.isNotA(ConstantNode.class)).isEmpty()) { + if (!isStatic() && Modifier.isFinal(field.getModifiers()) && object() instanceof ValuePhiNode && ((ValuePhiNode) object()).values().filter(NodePredicates.isNotA(ConstantNode.class)).isEmpty()) { PhiNode phi = (PhiNode) object(); Constant[] constants = new Constant[phi.valueCount()]; for (int i = 0; i < phi.valueCount(); i++) { @@ -107,7 +107,7 @@ } constants[i] = constantValue; } - PhiNode newPhi = graph().addWithoutUnique(new PhiNode(stamp(), phi.merge())); + PhiNode newPhi = graph().addWithoutUnique(new ValuePhiNode(stamp(), phi.merge())); for (int i = 0; i < phi.valueCount(); i++) { newPhi.addInput(ConstantNode.forConstant(constants[i], metaAccess, graph())); } diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/Stamp.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/Stamp.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/Stamp.java Fri Apr 04 18:32:32 2014 +0200 @@ -52,15 +52,15 @@ public abstract Kind getStackKind(); /** - * Gets a platform dependend {@link PlatformKind} that can be used to store a value of this + * Gets a platform dependent {@link PlatformKind} that can be used to store a value of this * stamp. */ public abstract PlatformKind getPlatformKind(LIRTypeTool tool); /** * Returns the union of this stamp and the given stamp. Typically used to create stamps for - * {@link PhiNode}s. - * + * {@link ValuePhiNode}s. + * * @param other The stamp that will enlarge this stamp. * @return The union of this stamp and the given stamp. */ @@ -68,7 +68,7 @@ /** * Returns the intersection of this stamp and the given stamp. - * + * * @param other The stamp that will tighten this stamp. * @return The intersection of this stamp and the given stamp. */ @@ -94,7 +94,7 @@ /** * If this stamp represents a single value, the methods returns this single value. It returns * null otherwise. - * + * * @return the constant corresponding to the single value of this stamp and null if this stamp * can represent less or more than one value. */ diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Fri Apr 04 18:32:32 2014 +0200 @@ -30,7 +30,6 @@ import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; @@ -197,7 +196,7 @@ // this piece of code handles phis if (!(merge instanceof LoopBeginNode)) { for (PhiNode phi : merge.phis()) { - if (phi.type() == PhiType.Value && phi.getKind() == Kind.Object) { + if (phi instanceof ValuePhiNode && phi.getKind() == Kind.Object) { ValueNode firstValue = phi.valueAt(0); ResolvedJavaType type = getNodeType(firstValue); boolean nonNull = knownNonNull.contains(firstValue); diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DeoptimizationGroupingPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DeoptimizationGroupingPhase.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DeoptimizationGroupingPhase.java Fri Apr 04 18:32:32 2014 +0200 @@ -56,8 +56,8 @@ if (target instanceof AbstractDeoptimizeNode) { merge = graph.add(new MergeNode()); EndNode firstEnd = graph.add(new EndNode()); - reasonActionPhi = graph.addWithoutUnique(new PhiNode(StampFactory.forKind(Kind.Int), merge)); - speculationPhi = graph.addWithoutUnique(new PhiNode(StampFactory.forKind(Kind.Object), merge)); + reasonActionPhi = graph.addWithoutUnique(new ValuePhiNode(StampFactory.forKind(Kind.Int), merge)); + speculationPhi = graph.addWithoutUnique(new ValuePhiNode(StampFactory.forKind(Kind.Object), merge)); merge.addForwardEnd(firstEnd); reasonActionPhi.addInput(((AbstractDeoptimizeNode) target).getActionAndReason(context.getMetaAccess())); speculationPhi.addInput(((AbstractDeoptimizeNode) target).getSpeculation(context.getMetaAccess())); diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Fri Apr 04 18:32:32 2014 +0200 @@ -628,7 +628,7 @@ PhiNode returnValuePhi = null; if (invoke.asNode().getKind() != Kind.Void) { - returnValuePhi = graph.addWithoutUnique(new PhiNode(invoke.asNode().stamp().unrestricted(), returnMerge)); + returnValuePhi = graph.addWithoutUnique(new ValuePhiNode(invoke.asNode().stamp().unrestricted(), returnMerge)); } MergeNode exceptionMerge = null; @@ -641,7 +641,7 @@ FixedNode exceptionSux = exceptionEdge.next(); graph.addBeforeFixed(exceptionSux, exceptionMerge); - exceptionObjectPhi = graph.addWithoutUnique(new PhiNode(StampFactory.forKind(Kind.Object), exceptionMerge)); + exceptionObjectPhi = graph.addWithoutUnique(new ValuePhiNode(StampFactory.forKind(Kind.Object), exceptionMerge)); exceptionMerge.setStateAfter(exceptionEdge.stateAfter().duplicateModified(invoke.stateAfter().bci, true, Kind.Object, exceptionObjectPhi)); } @@ -1489,7 +1489,7 @@ if (returnNode.result() != null) { if (returnValuePhi == null) { - returnValuePhi = merge.graph().addWithoutUnique(new PhiNode(returnNode.result().stamp().unrestricted(), merge)); + returnValuePhi = merge.graph().addWithoutUnique(new ValuePhiNode(returnNode.result().stamp().unrestricted(), merge)); } returnValuePhi.addInput(returnNode.result()); } diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ReadEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ReadEliminationPhase.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ReadEliminationPhase.java Fri Apr 04 18:32:32 2014 +0200 @@ -60,9 +60,9 @@ WriteNode other = (WriteNode) lastLocationAccess; return other.object() == n.object() && other.location() == n.location(); } - if (lastLocationAccess instanceof PhiNode) { + if (lastLocationAccess instanceof MemoryPhiNode) { visited.mark(ValueNodeUtil.asNode(lastLocationAccess)); - for (ValueNode value : ((PhiNode) lastLocationAccess).values()) { + for (ValueNode value : ((MemoryPhiNode) lastLocationAccess).values()) { if (!isWrites(n, (MemoryNode) value, visited)) { return false; } @@ -85,9 +85,9 @@ if (lastLocationAccess instanceof WriteNode) { return ((WriteNode) lastLocationAccess).value(); } - if (lastLocationAccess instanceof PhiNode) { - PhiNode phi = (PhiNode) lastLocationAccess; - PhiNode newPhi = phi.graph().addWithoutUnique(new PhiNode(n.stamp().unrestricted(), phi.merge())); + if (lastLocationAccess instanceof MemoryPhiNode) { + MemoryPhiNode phi = (MemoryPhiNode) lastLocationAccess; + ValuePhiNode newPhi = phi.graph().addWithoutUnique(new ValuePhiNode(n.stamp().unrestricted(), phi.merge())); nodeMap.set(phi, newPhi); for (ValueNode value : phi.values()) { newPhi.addInput(getValue(n, (MemoryNode) value, nodeMap)); diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/RemoveValueProxyPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/RemoveValueProxyPhase.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/RemoveValueProxyPhase.java Fri Apr 04 18:32:32 2014 +0200 @@ -23,7 +23,6 @@ package com.oracle.graal.phases.common; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.PhiNode.*; import com.oracle.graal.phases.*; public class RemoveValueProxyPhase extends Phase { @@ -31,7 +30,7 @@ @Override protected void run(StructuredGraph graph) { for (ProxyNode vpn : graph.getNodes(ProxyNode.class)) { - if (vpn.type() == PhiType.Value) { + if (vpn instanceof ValueProxyNode) { graph.replaceFloating(vpn, vpn.value()); } } diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java Fri Apr 04 18:32:32 2014 +0200 @@ -486,7 +486,7 @@ // introduce a new phi PhiNode newPhi = bottomPhis.get(node); if (newPhi == null) { - newPhi = graph.addWithoutUnique(new PhiNode(node.stamp().unrestricted(), newBottomMerge)); + newPhi = graph.addWithoutUnique(new ValuePhiNode(node.stamp().unrestricted(), newBottomMerge)); bottomPhis.put(node, newPhi); newPhi.addInput(node); } diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/InferStamps.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/InferStamps.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/InferStamps.java Fri Apr 04 18:32:32 2014 +0200 @@ -47,7 +47,7 @@ * when the phi function performs the "meet" operator on its input stamps. */ for (Node n : graph.getNodes()) { - if (n instanceof PhiNode || n instanceof ValueAndStampProxy) { + if (n instanceof ValuePhiNode || n instanceof ValueAndStampProxy) { ValueNode node = (ValueNode) n; if (ObjectStamp.isObject(node.stamp())) { assert !(node.stamp() instanceof IllegalStamp) : "We assume all Phi and Proxy stamps are legal before the analysis"; @@ -84,7 +84,7 @@ private static boolean checkNoIllegalStamp(StructuredGraph graph) { for (Node n : graph.getNodes()) { - if (n instanceof PhiNode || n instanceof ValueAndStampProxy) { + if (n instanceof ValuePhiNode || n instanceof ValueAndStampProxy) { ValueNode node = (ValueNode) n; assert !(node.stamp() instanceof IllegalStamp) : "Stamp is illegal after analysis. This is not necessarily an error, but a condition that we want to investigate (and then maybe relax or remove the assertion)."; } diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java Fri Apr 04 18:32:32 2014 +0200 @@ -159,7 +159,7 @@ } private void scheduleInputs(Node node, Block nodeBlock) { - if (node instanceof PhiNode) { + if (node instanceof ValuePhiNode) { PhiNode phi = (PhiNode) node; assert nodeBlock.getBeginNode() == phi.merge(); for (Block pred : nodeBlock.getPredecessors()) { @@ -289,7 +289,7 @@ assert !printedNodes.isMarked(node); printedNodes.mark(node); - if (!(node instanceof PhiNode)) { + if (!(node instanceof ValuePhiNode)) { for (Node input : node.inputs()) { if (!inFixedSchedule(input) && !printedNodes.isMarked(input)) { printNode(input, true); diff -r cd9404a8216b -r e302df8bf51c 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 Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java Fri Apr 04 18:32:32 2014 +0200 @@ -32,9 +32,10 @@ import com.oracle.graal.debug.*; import com.oracle.graal.debug.internal.*; import com.oracle.graal.graph.*; -import com.oracle.graal.graph.Node.*; +import com.oracle.graal.graph.Node.ConstantNodeParameter; +import com.oracle.graal.graph.Node.InjectedNodeParameter; +import com.oracle.graal.graph.Node.NodeIntrinsic; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; @@ -387,8 +388,8 @@ } } 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)); + assert proxy instanceof ValueProxyNode; + ProxyNode newProxy = ProxyNode.forValue((ValueNode) intrinsifiedNode, proxy.proxyPoint(), graph); for (Node proxyUsage : usage.usages().snapshot()) { checkCheckCastUsage(graph, newProxy, proxy, proxyUsage); } diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Fri Apr 04 18:32:32 2014 +0200 @@ -1110,7 +1110,7 @@ private void propagateStamp(Node node) { if (node instanceof PhiNode) { PhiNode phi = (PhiNode) node; - if (phi.inferPhiStamp()) { + if (phi.inferStamp()) { for (Node usage : node.usages()) { propagateStamp(usage); } diff -r cd9404a8216b -r e302df8bf51c 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 Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java Fri Apr 04 18:32:32 2014 +0200 @@ -30,7 +30,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; @@ -114,7 +113,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); + ProxyNode proxy = new ValueProxyNode(value, exitNode); effects.addFloatingNode(proxy, "readCacheProxy"); entry.setValue(proxy); } diff -r cd9404a8216b -r e302df8bf51c 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 Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java Fri Apr 04 18:32:32 2014 +0200 @@ -29,7 +29,6 @@ import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.VirtualState.NodeClosure; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.extended.*; @@ -248,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); + ProxyNode proxy = new ValueProxyNode(value, exitNode); obj.setEntry(i, proxy); effects.addFloatingNode(proxy, "virtualProxy"); } @@ -258,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); + proxy = new ValueProxyNode(obj.getMaterializedValue(), exitNode); effects.addFloatingNode(proxy, "proxy"); } else { effects.replaceFirstInput(proxy, proxy.value(), obj.getMaterializedValue()); @@ -281,34 +280,34 @@ protected class MergeProcessor extends EffectsClosure.MergeProcessor { - private final HashMap materializedPhis = new HashMap<>(); - private final IdentityHashMap valuePhis = new IdentityHashMap<>(); - private final IdentityHashMap valueObjectVirtuals = new IdentityHashMap<>(); + private final HashMap materializedPhis = new HashMap<>(); + private final IdentityHashMap valuePhis = new IdentityHashMap<>(); + private final IdentityHashMap valueObjectVirtuals = new IdentityHashMap<>(); public MergeProcessor(Block mergeBlock) { super(mergeBlock); } protected PhiNode getCachedPhi(T virtual, Stamp stamp) { - PhiNode result = materializedPhis.get(virtual); + ValuePhiNode result = materializedPhis.get(virtual); if (result == null) { - result = new PhiNode(stamp, merge); + result = new ValuePhiNode(stamp, merge); materializedPhis.put(virtual, result); } return result; } private PhiNode[] getValuePhis(ValueNode key, int entryCount) { - PhiNode[] result = valuePhis.get(key); + ValuePhiNode[] result = valuePhis.get(key); if (result == null) { - result = new PhiNode[entryCount]; + result = new ValuePhiNode[entryCount]; valuePhis.put(key, result); } assert result.length == entryCount; return result; } - private VirtualObjectNode getValueObjectVirtual(PhiNode phi, VirtualObjectNode virtual) { + private VirtualObjectNode getValueObjectVirtual(ValuePhiNode phi, VirtualObjectNode virtual) { VirtualObjectNode result = valueObjectVirtuals.get(phi); if (result == null) { result = virtual.duplicate(); @@ -380,8 +379,8 @@ } for (PhiNode phi : merge.phis()) { - if (usages.isMarked(phi) && phi.type() == PhiType.Value) { - materialized |= processPhi(phi, states, virtualObjTemp); + if (usages.isMarked(phi) && phi instanceof ValuePhiNode) { + materialized |= processPhi((ValuePhiNode) phi, states, virtualObjTemp); } } if (materialized) { @@ -466,7 +465,7 @@ for (int i = 1; i < objStates.length; i++) { ValueNode[] fields = objStates[i].getEntries(); if (phis[valueIndex] == null && values[valueIndex] != fields[valueIndex]) { - phis[valueIndex] = new PhiNode(values[valueIndex].stamp().unrestricted(), merge); + phis[valueIndex] = new ValuePhiNode(values[valueIndex].stamp().unrestricted(), merge); } } if (twoSlotKinds != null && twoSlotKinds[valueIndex] != null) { @@ -556,7 +555,7 @@ * and therefore also exist in the merged state * @return true if materialization happened during the merge, false otherwise */ - private boolean processPhi(PhiNode phi, List states, Set mergedVirtualObjects) { + private boolean processPhi(ValuePhiNode phi, List states, Set mergedVirtualObjects) { aliases.set(phi, null); assert states.size() == phi.valueCount(); diff -r cd9404a8216b -r e302df8bf51c 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 Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java Fri Apr 04 18:32:32 2014 +0200 @@ -29,7 +29,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.PhiNode.PhiType; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; @@ -175,7 +174,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); + ProxyNode proxy = new ValueProxyNode(exitState.getCacheEntry(entry.getKey()), exitNode); effects.addFloatingNode(proxy, "readCacheProxy"); entry.setValue(proxy); } @@ -194,16 +193,16 @@ private class ReadEliminationMergeProcessor extends EffectsClosure.MergeProcessor { - private final HashMap materializedPhis = new HashMap<>(); + private final HashMap materializedPhis = new HashMap<>(); public ReadEliminationMergeProcessor(Block mergeBlock) { super(mergeBlock); } protected PhiNode getCachedPhi(T virtual, Stamp stamp) { - PhiNode result = materializedPhis.get(virtual); + ValuePhiNode result = materializedPhis.get(virtual); if (result == null) { - result = new PhiNode(stamp, merge); + result = new ValuePhiNode(stamp, merge); materializedPhis.put(virtual, result); } return result; diff -r cd9404a8216b -r e302df8bf51c graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeVerificationPhase.java --- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeVerificationPhase.java Fri Apr 04 18:23:55 2014 +0200 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeVerificationPhase.java Fri Apr 04 18:32:32 2014 +0200 @@ -90,9 +90,9 @@ verify(!isWord(node) || ((ObjectEqualsNode) usage).y() != node, node, usage, "cannot use word type in comparison"); } else if (usage instanceof ArrayLengthNode) { verify(!isWord(node) || ((ArrayLengthNode) usage).array() != node, node, usage, "cannot get array length from word value"); - } else if (usage instanceof PhiNode) { + } else if (usage instanceof ValuePhiNode) { if (!(node instanceof MergeNode)) { - PhiNode phi = (PhiNode) usage; + ValuePhiNode phi = (ValuePhiNode) usage; for (ValueNode input : phi.values()) { verify(isWord(node) == isWord(input), node, input, "cannot merge word and non-word values"); }