# HG changeset patch # User Thomas Wuerthinger # Date 1379550046 -7200 # Node ID f12b418ebc74fadd1100f2cbbc2e2c54ccba4691 # Parent 8d8a7d7f0259612ca58446d212c02bbde64202d0 Allow only single input for value anchors. diff -r 8d8a7d7f0259 -r f12b418ebc74 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java Thu Sep 19 01:50:08 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java Thu Sep 19 02:20:46 2013 +0200 @@ -108,9 +108,9 @@ @Override public void lower(LoweringTool tool) { if (graph().getGuardsStage() == StructuredGraph.GuardsStage.FLOATING_GUARDS) { - GuardingNode guard = tool.createGuard(condition(), getReason(), getAction(), isNegated()); + ValueNode guard = tool.createGuard(condition(), getReason(), getAction(), isNegated()).asNode(); + this.replaceAtUsages(guard); ValueAnchorNode newAnchor = graph().add(new ValueAnchorNode(guard.asNode())); - this.replaceAtUsages(guard.asNode()); graph().replaceFixedWithFixed(this, newAnchor); } else { FixedNode next = next(); diff -r 8d8a7d7f0259 -r f12b418ebc74 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java Thu Sep 19 01:50:08 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java Thu Sep 19 02:20:46 2013 +0200 @@ -22,8 +22,6 @@ */ package com.oracle.graal.nodes.extended; -import static com.oracle.graal.graph.iterators.NodePredicates.*; - import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; @@ -34,11 +32,11 @@ */ public final class ValueAnchorNode extends FixedWithNextNode implements Canonicalizable, LIRLowerable, IterableNodeType, Virtualizable, GuardingNode { - @Input private final NodeInputList anchored; + @Input private ValueNode anchored; - public ValueAnchorNode(ValueNode... values) { + public ValueAnchorNode(ValueNode value) { super(StampFactory.dependency()); - this.anchored = new NodeInputList<>(this, values); + this.anchored = value; } @Override @@ -46,51 +44,39 @@ // Nothing to emit, since this node is used for structural purposes only. } - public void addAnchoredNode(ValueNode value) { - if (!anchored.contains(value)) { - this.anchored.add(value); - } - } - - public void removeAnchoredNode(ValueNode value) { - this.anchored.remove(value); - } - - public NodeInputList getAnchoredNodes() { + public ValueNode getAnchoredNode() { return anchored; } @Override public ValueNode canonical(CanonicalizerTool tool) { - if (this.predecessor() instanceof ValueAnchorNode) { - ValueAnchorNode previousAnchor = (ValueAnchorNode) this.predecessor(); - if (previousAnchor.usages().isEmpty()) { // avoid creating cycles - // transfer values and remove - for (ValueNode node : anchored.nonNull().distinct()) { - previousAnchor.addAnchoredNode(node); - } - return previousAnchor; - } + if (anchored != null && !anchored.isConstant()) { + // Found entry that needs this anchor. + return this; } - for (Node node : anchored.nonNull().and(isNotA(FixedNode.class))) { - if (!(node instanceof ConstantNode)) { - return this; // still necessary - } + + if (usages().isNotEmpty()) { + // A not uses this anchor => anchor is necessary. + return this; } - if (usages().isEmpty()) { - return null; // no node which require an anchor found - } - return this; + + // Anchor is not necessary any more => remove. + return null; } @Override public void virtualize(VirtualizerTool tool) { - for (ValueNode node : anchored.nonNull().and(isNotA(AbstractBeginNode.class))) { - State state = tool.getObjectState(node); + if (anchored != null && !(anchored instanceof AbstractBeginNode)) { + State state = tool.getObjectState(anchored); if (state == null || state.getState() != EscapeState.Virtual) { return; } } tool.delete(); } + + public void removeAnchoredNode() { + this.updateUsages(anchored, null); + this.anchored = null; + } } diff -r 8d8a7d7f0259 -r f12b418ebc74 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 Thu Sep 19 01:50:08 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Thu Sep 19 02:20:46 2013 +0200 @@ -505,7 +505,7 @@ } ValueAnchorNode anchor = null; if (replacementAnchor == null) { - anchor = graph.add(new ValueAnchorNode()); + anchor = graph.add(new ValueAnchorNode(null)); replacementAnchor = anchor; } PiNode piNode; diff -r 8d8a7d7f0259 -r f12b418ebc74 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 Thu Sep 19 01:50:08 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java Thu Sep 19 02:20:46 2013 +0200 @@ -309,7 +309,7 @@ * @return The new {@link ValueAnchorNode} that was created. */ private ValueAnchorNode addValueAnchor() { - ValueAnchorNode anchor = graph.add(new ValueAnchorNode()); + ValueAnchorNode anchor = graph.add(new ValueAnchorNode(null)); graph.addAfterFixed(merge, anchor); for (Node usage : merge.usages().snapshot()) { if (usage instanceof PhiNode && ((PhiNode) usage).merge() == merge) { diff -r 8d8a7d7f0259 -r f12b418ebc74 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ValueAnchorCleanupPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ValueAnchorCleanupPhase.java Thu Sep 19 01:50:08 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ValueAnchorCleanupPhase.java Thu Sep 19 02:20:46 2013 +0200 @@ -73,14 +73,15 @@ protected void node(FixedNode node) { if (node instanceof ValueAnchorNode) { ValueAnchorNode anchor = (ValueAnchorNode) node; - for (ValueNode anchored : anchor.getAnchoredNodes().snapshot()) { + ValueNode anchored = anchor.getAnchoredNode(); + if (anchored != null) { if (state.anchoredValues.contains(anchored)) { - anchor.removeAnchoredNode(anchored); + anchor.removeAnchoredNode(); } else { state.anchoredValues.add(anchored); } } - if (anchor.getAnchoredNodes().isEmpty() && anchor.usages().isEmpty()) { + if (anchor.getAnchoredNode() == null && anchor.usages().isEmpty()) { node.graph().removeFixed(anchor); } } diff -r 8d8a7d7f0259 -r f12b418ebc74 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 Thu Sep 19 01:50:08 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java Thu Sep 19 02:20:46 2013 +0200 @@ -302,7 +302,7 @@ private static void checkCheckCastUsage(StructuredGraph graph, Node intrinsifiedNode, Node input, Node usage) { if (usage instanceof ValueAnchorNode) { ValueAnchorNode valueAnchorNode = (ValueAnchorNode) usage; - valueAnchorNode.removeAnchoredNode((ValueNode) input); + valueAnchorNode.removeAnchoredNode(); Debug.log("%s: Removed a ValueAnchor input", Debug.contextSnapshot(JavaMethod.class)); } else if (usage instanceof UnboxNode) { UnboxNode unbox = (UnboxNode) usage; diff -r 8d8a7d7f0259 -r f12b418ebc74 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/TypeCastNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/TypeCastNode.java Thu Sep 19 01:50:08 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/TypeCastNode.java Thu Sep 19 02:20:46 2013 +0200 @@ -61,7 +61,7 @@ public void lower(LoweringTool tool) { if (graph().getGuardsStage() == StructuredGraph.GuardsStage.FLOATING_GUARDS) { - ValueAnchorNode valueAnchorNode = graph().add(new ValueAnchorNode()); + ValueAnchorNode valueAnchorNode = graph().add(new ValueAnchorNode(null)); UnsafeCastNode unsafeCast = graph().unique(new UnsafeCastNode(object, this.stamp(), (GuardingNode) valueAnchorNode)); this.replaceAtUsages(unsafeCast); graph().replaceFixedWithFixed(this, valueAnchorNode);