# HG changeset patch # User Gilles Duboscq # Date 1373386675 -7200 # Node ID 8d961f93725ccaf58afe1d608a39d800b4783073 # Parent fd53f9f7007b954b06fcc56cfdf11639edc3646f Use GuardedValueNode in the inlining diff -r fd53f9f7007b -r 8d961f93725c graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardedValueNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardedValueNode.java Thu Jul 11 13:09:28 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardedValueNode.java Tue Jul 09 18:17:55 2013 +0200 @@ -26,6 +26,7 @@ import com.oracle.graal.graph.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; /** * A node that changes the type of its input, usually narrowing it. For example, a GuardedValueNode @@ -37,13 +38,17 @@ @Input private ValueNode object; - public ValueNode object() { - return object; + public GuardedValueNode(ValueNode object, GuardingNode guard, Stamp stamp) { + super(stamp, guard); + this.object = object; } public GuardedValueNode(ValueNode object, GuardingNode guard) { - super(object.stamp(), guard); - this.object = object; + this(object, guard, object.stamp()); + } + + public ValueNode object() { + return object; } @Override @@ -68,7 +73,11 @@ public ValueNode canonical(CanonicalizerTool tool) { if (getGuard() == graph().start()) { - return object(); + if (stamp().equals(object().stamp())) { + return object(); + } else { + return graph().unique(new PiNode(object(), stamp())); + } } return this; } diff -r fd53f9f7007b -r 8d961f93725c 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 Thu Jul 11 13:09:28 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Tue Jul 09 18:17:55 2013 +0200 @@ -661,7 +661,7 @@ invoke.asNode().replaceAtUsages(returnValuePhi); invoke.asNode().replaceAndDelete(null); - ArrayList replacementNodes = new ArrayList<>(); + ArrayList replacementNodes = new ArrayList<>(); // do the actual inlining for every invoke for (int i = 0; i < numberOfMethods; i++) { @@ -677,7 +677,7 @@ ValueNode receiver = ((MethodCallTargetNode) invokeForInlining.callTarget()).receiver(); boolean exact = (getTypeCount(i) == 1 && !methodDispatch); - PiNode anchoredReceiver = createAnchoredReceiver(graph, node, commonType, receiver, exact); + GuardedValueNode anchoredReceiver = createAnchoredReceiver(graph, node, commonType, receiver, exact); invokeForInlining.callTarget().replaceFirstInput(receiver, anchoredReceiver); inline(invokeForInlining, methodAt(i), inlineableElementAt(i), assumptions, false); @@ -956,7 +956,7 @@ invocationEntry.setNext(invoke.asNode()); ValueNode receiver = ((MethodCallTargetNode) invoke.callTarget()).receiver(); - PiNode anchoredReceiver = createAnchoredReceiver(graph, invocationEntry, target.getDeclaringClass(), receiver, false); + GuardedValueNode anchoredReceiver = createAnchoredReceiver(graph, invocationEntry, target.getDeclaringClass(), receiver, false); invoke.callTarget().replaceFirstInput(receiver, anchoredReceiver); replaceInvokeCallTarget(invoke, graph, kind, target); } @@ -1216,13 +1216,13 @@ } } - private static PiNode createAnchoredReceiver(StructuredGraph graph, GuardingNode anchor, ResolvedJavaType commonType, ValueNode receiver, boolean exact) { + private static GuardedValueNode createAnchoredReceiver(StructuredGraph graph, GuardingNode anchor, ResolvedJavaType commonType, ValueNode receiver, boolean exact) { return createAnchoredReceiver(graph, anchor, receiver, exact ? StampFactory.exactNonNull(commonType) : StampFactory.declaredNonNull(commonType)); } - private static PiNode createAnchoredReceiver(StructuredGraph graph, GuardingNode anchor, ValueNode receiver, Stamp stamp) { + private static GuardedValueNode createAnchoredReceiver(StructuredGraph graph, GuardingNode anchor, ValueNode receiver, Stamp stamp) { // to avoid that floating reads on receiver fields float above the type check - return graph.unique(new PiNode(receiver, stamp, anchor)); + return graph.unique(new GuardedValueNode(receiver, anchor, stamp)); } // TODO (chaeubl): cleanup this method diff -r fd53f9f7007b -r 8d961f93725c 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 Jul 11 13:09:28 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java Tue Jul 09 18:17:55 2013 +0200 @@ -159,7 +159,7 @@ * {@link PiNode} in the duplicated branch that corresponds to the entry. * @param phaseContext */ - public static boolean tailDuplicate(MergeNode merge, TailDuplicationDecision decision, List replacements, PhaseContext phaseContext) { + public static boolean tailDuplicate(MergeNode merge, TailDuplicationDecision decision, List replacements, PhaseContext phaseContext) { assert !(merge instanceof LoopBeginNode); assert replacements == null || replacements.size() == merge.forwardEndCount(); FixedNode fixed = merge; @@ -188,7 +188,7 @@ private final StructuredGraph graph; private final HashMap bottomPhis = new HashMap<>(); - private final List replacements; + private final List replacements; /** * Initializes the tail duplication operation without actually performing any work. @@ -197,7 +197,7 @@ * @param replacements A list of replacement {@link PiNode}s, or null. If this is non-null, * then the size of the list needs to match the number of end nodes at the merge. */ - public DuplicationOperation(MergeNode merge, List replacements) { + public DuplicationOperation(MergeNode merge, List replacements) { this.merge = merge; this.replacements = replacements; this.graph = merge.graph();