--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/PiNode.java 2019-03-12 08:09:48.427656494 +0100 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/PiNode.java 2019-03-12 08:09:48.059654108 +0100 @@ -32,6 +32,7 @@ import org.graalvm.compiler.core.common.type.Stamp; import org.graalvm.compiler.core.common.type.StampFactory; import org.graalvm.compiler.core.common.type.TypeReference; +import org.graalvm.compiler.debug.DebugContext; import org.graalvm.compiler.graph.IterableNodeType; import org.graalvm.compiler.graph.Node; import org.graalvm.compiler.graph.NodeClass; @@ -100,7 +101,7 @@ } public static ValueNode create(ValueNode object, Stamp stamp) { - ValueNode value = canonical(object, stamp, null); + ValueNode value = canonical(object, stamp, null, null); if (value != null) { return value; } @@ -108,7 +109,7 @@ } public static ValueNode create(ValueNode object, Stamp stamp, ValueNode guard) { - ValueNode value = canonical(object, stamp, (GuardingNode) guard); + ValueNode value = canonical(object, stamp, (GuardingNode) guard, null); if (value != null) { return value; } @@ -117,7 +118,7 @@ public static ValueNode create(ValueNode object, ValueNode guard) { Stamp stamp = AbstractPointerStamp.pointerNonNull(object.stamp(NodeView.DEFAULT)); - ValueNode value = canonical(object, stamp, (GuardingNode) guard); + ValueNode value = canonical(object, stamp, (GuardingNode) guard, null); if (value != null) { return value; } @@ -127,7 +128,7 @@ @SuppressWarnings("unused") public static boolean intrinsify(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode object, ValueNode guard) { Stamp stamp = AbstractPointerStamp.pointerNonNull(object.stamp(NodeView.DEFAULT)); - ValueNode value = canonical(object, stamp, (GuardingNode) guard); + ValueNode value = canonical(object, stamp, (GuardingNode) guard, null); if (value == null) { value = new PiNode(object, stamp, guard); } @@ -139,7 +140,7 @@ public static boolean intrinsify(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode object, ResolvedJavaType toType, boolean exactType, boolean nonNull) { Stamp stamp = StampFactory.object(exactType ? TypeReference.createExactTrusted(toType) : TypeReference.createWithoutAssumptions(toType), nonNull || StampTool.isPointerNonNull(object.stamp(NodeView.DEFAULT))); - ValueNode value = canonical(object, stamp, null); + ValueNode value = canonical(object, stamp, null, null); if (value == null) { value = new PiNode(object, stamp); } @@ -177,13 +178,16 @@ ValueNode alias = tool.getAlias(object()); if (alias instanceof VirtualObjectNode) { VirtualObjectNode virtual = (VirtualObjectNode) alias; - if (StampTool.typeOrNull(this) != null && StampTool.typeOrNull(this).isAssignableFrom(virtual.type())) { + ResolvedJavaType type = StampTool.typeOrNull(this, tool.getMetaAccess()); + if (type != null && type.isAssignableFrom(virtual.type())) { tool.replaceWithVirtual(virtual); + } else { + tool.getDebug().log(DebugContext.INFO_LEVEL, "could not virtualize Pi because of type mismatch: %s %s vs %s", this, type, virtual.type()); } } } - public static ValueNode canonical(ValueNode object, Stamp stamp, GuardingNode guard) { + public static ValueNode canonical(ValueNode object, Stamp stamp, GuardingNode guard, PiNode self) { // Use most up to date stamp. Stamp computedStamp = stamp.improveWith(object.stamp(NodeView.DEFAULT)); @@ -201,8 +205,9 @@ } } else { for (Node n : guard.asNode().usages()) { - if (n instanceof PiNode) { + if (n instanceof PiNode && n != self) { PiNode otherPi = (PiNode) n; + assert otherPi.guard == guard; if (object == otherPi.object() && computedStamp.equals(otherPi.stamp(NodeView.DEFAULT))) { /* * Two PiNodes with the same guard and same result, so return the one with @@ -221,7 +226,7 @@ @Override public Node canonical(CanonicalizerTool tool) { - Node value = canonical(object(), stamp(NodeView.DEFAULT), getGuard()); + Node value = canonical(object(), piStamp(), getGuard(), this); if (value != null) { return value; }