< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/PiNode.java

Print this page

        

*** 30,39 **** --- 30,40 ---- import org.graalvm.compiler.core.common.type.AbstractPointerStamp; import org.graalvm.compiler.core.common.type.ObjectStamp; 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; import org.graalvm.compiler.graph.spi.Canonicalizable; import org.graalvm.compiler.graph.spi.CanonicalizerTool;
*** 98,135 **** this(object, StampFactory.object(exactType ? TypeReference.createExactTrusted(toType) : TypeReference.createWithoutAssumptions(toType), nonNull || StampTool.isPointerNonNull(object.stamp(NodeView.DEFAULT)))); } public static ValueNode create(ValueNode object, Stamp stamp) { ! ValueNode value = canonical(object, stamp, null); if (value != null) { return value; } return new PiNode(object, stamp); } public static ValueNode create(ValueNode object, Stamp stamp, ValueNode guard) { ! ValueNode value = canonical(object, stamp, (GuardingNode) guard); if (value != null) { return value; } return new PiNode(object, stamp, guard); } public static ValueNode create(ValueNode object, ValueNode guard) { Stamp stamp = AbstractPointerStamp.pointerNonNull(object.stamp(NodeView.DEFAULT)); ! ValueNode value = canonical(object, stamp, (GuardingNode) guard); if (value != null) { return value; } return new PiNode(object, stamp, guard); } @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); if (value == null) { value = new PiNode(object, stamp, guard); } b.push(JavaKind.Object, b.append(value)); return true; --- 99,136 ---- this(object, StampFactory.object(exactType ? TypeReference.createExactTrusted(toType) : TypeReference.createWithoutAssumptions(toType), nonNull || StampTool.isPointerNonNull(object.stamp(NodeView.DEFAULT)))); } public static ValueNode create(ValueNode object, Stamp stamp) { ! ValueNode value = canonical(object, stamp, null, null); if (value != null) { return value; } return new PiNode(object, stamp); } public static ValueNode create(ValueNode object, Stamp stamp, ValueNode guard) { ! ValueNode value = canonical(object, stamp, (GuardingNode) guard, null); if (value != null) { return value; } return new PiNode(object, stamp, guard); } public static ValueNode create(ValueNode object, ValueNode guard) { Stamp stamp = AbstractPointerStamp.pointerNonNull(object.stamp(NodeView.DEFAULT)); ! ValueNode value = canonical(object, stamp, (GuardingNode) guard, null); if (value != null) { return value; } return new PiNode(object, stamp, guard); } @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, null); if (value == null) { value = new PiNode(object, stamp, guard); } b.push(JavaKind.Object, b.append(value)); return true;
*** 137,147 **** @SuppressWarnings("unused") 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); if (value == null) { value = new PiNode(object, stamp); } b.push(JavaKind.Object, b.append(value)); return true; --- 138,148 ---- @SuppressWarnings("unused") 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, null); if (value == null) { value = new PiNode(object, stamp); } b.push(JavaKind.Object, b.append(value)); return true;
*** 175,191 **** @Override public void virtualize(VirtualizerTool tool) { ValueNode alias = tool.getAlias(object()); if (alias instanceof VirtualObjectNode) { VirtualObjectNode virtual = (VirtualObjectNode) alias; ! if (StampTool.typeOrNull(this) != null && StampTool.typeOrNull(this).isAssignableFrom(virtual.type())) { tool.replaceWithVirtual(virtual); } } } ! public static ValueNode canonical(ValueNode object, Stamp stamp, GuardingNode guard) { // Use most up to date stamp. Stamp computedStamp = stamp.improveWith(object.stamp(NodeView.DEFAULT)); // The pi node does not give any additional information => skip it. if (computedStamp.equals(object.stamp(NodeView.DEFAULT))) { --- 176,195 ---- @Override public void virtualize(VirtualizerTool tool) { ValueNode alias = tool.getAlias(object()); if (alias instanceof VirtualObjectNode) { VirtualObjectNode virtual = (VirtualObjectNode) alias; ! 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, PiNode self) { // Use most up to date stamp. Stamp computedStamp = stamp.improveWith(object.stamp(NodeView.DEFAULT)); // The pi node does not give any additional information => skip it. if (computedStamp.equals(object.stamp(NodeView.DEFAULT))) {
*** 199,210 **** readNode.setStamp(readNode.stamp(NodeView.DEFAULT).improveWith(stamp)); return readNode; } } else { for (Node n : guard.asNode().usages()) { ! if (n instanceof PiNode) { PiNode otherPi = (PiNode) n; if (object == otherPi.object() && computedStamp.equals(otherPi.stamp(NodeView.DEFAULT))) { /* * Two PiNodes with the same guard and same result, so return the one with * the more precise piStamp. */ --- 203,215 ---- readNode.setStamp(readNode.stamp(NodeView.DEFAULT).improveWith(stamp)); return readNode; } } else { for (Node n : guard.asNode().usages()) { ! 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 * the more precise piStamp. */
*** 219,229 **** return null; } @Override public Node canonical(CanonicalizerTool tool) { ! Node value = canonical(object(), stamp(NodeView.DEFAULT), getGuard()); if (value != null) { return value; } return this; } --- 224,234 ---- return null; } @Override public Node canonical(CanonicalizerTool tool) { ! Node value = canonical(object(), piStamp(), getGuard(), this); if (value != null) { return value; } return this; }
< prev index next >