--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/java/InstanceOfNode.java 2017-11-03 23:57:17.620842123 -0700 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/java/InstanceOfNode.java 2017-11-03 23:57:17.293827489 -0700 @@ -49,6 +49,8 @@ import jdk.vm.ci.meta.JavaTypeProfile; import jdk.vm.ci.meta.TriState; +import java.util.Objects; + /** * The {@code InstanceOfNode} represents an instanceof test. */ @@ -56,7 +58,7 @@ public class InstanceOfNode extends UnaryOpLogicNode implements Lowerable, Virtualizable { public static final NodeClass TYPE = NodeClass.create(InstanceOfNode.class); - protected final ObjectStamp checkedStamp; + private ObjectStamp checkedStamp; private JavaTypeProfile profile; @OptionalInput(Anchor) protected AnchoringNode anchor; @@ -126,7 +128,9 @@ // The check will always succeed, the union of the two stamps is equal to the // checked stamp. return LogicConstantNode.tautology(); - } else if (checkedStamp.type().equals(meetStamp.type()) && checkedStamp.isExactType() == meetStamp.isExactType() && checkedStamp.alwaysNull() == meetStamp.alwaysNull()) { + } else if (checkedStamp.alwaysNull()) { + return IsNullNode.create(object); + } else if (Objects.equals(checkedStamp.type(), meetStamp.type()) && checkedStamp.isExactType() == meetStamp.isExactType() && checkedStamp.alwaysNull() == meetStamp.alwaysNull()) { assert checkedStamp.nonNull() != inputStamp.nonNull(); // The only difference makes the null-ness of the value => simplify the check. if (checkedStamp.nonNull()) { @@ -135,8 +139,8 @@ return IsNullNode.create(object); } } + assert checkedStamp.type() != null; } - return null; } @@ -204,4 +208,13 @@ public AnchoringNode getAnchor() { return anchor; } + + public ObjectStamp getCheckedStamp() { + return checkedStamp; + } + + public void strengthenCheckedStamp(ObjectStamp newCheckedStamp) { + assert this.checkedStamp.join(newCheckedStamp).equals(newCheckedStamp) : "stamp can only improve"; + this.checkedStamp = newCheckedStamp; + } }