< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/java/InstanceOfNode.java
Print this page
@@ -47,18 +47,20 @@
import org.graalvm.compiler.nodes.type.StampTool;
import jdk.vm.ci.meta.JavaTypeProfile;
import jdk.vm.ci.meta.TriState;
+import java.util.Objects;
+
/**
* The {@code InstanceOfNode} represents an instanceof test.
*/
@NodeInfo(cycles = CYCLES_8, size = SIZE_8)
public class InstanceOfNode extends UnaryOpLogicNode implements Lowerable, Virtualizable {
public static final NodeClass<InstanceOfNode> TYPE = NodeClass.create(InstanceOfNode.class);
- protected final ObjectStamp checkedStamp;
+ private ObjectStamp checkedStamp;
private JavaTypeProfile profile;
@OptionalInput(Anchor) protected AnchoringNode anchor;
private InstanceOfNode(ObjectStamp checkedStamp, ValueNode object, JavaTypeProfile profile, AnchoringNode anchor) {
@@ -124,21 +126,23 @@
ObjectStamp meetStamp = (ObjectStamp) checkedStamp.meet(inputStamp);
if (checkedStamp.equals(meetStamp)) {
// 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()) {
return LogicNegationNode.create(IsNullNode.create(object));
} else {
return IsNullNode.create(object);
}
}
+ assert checkedStamp.type() != null;
}
-
return null;
}
/**
* Gets the type being tested.
@@ -202,6 +206,15 @@
}
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;
+ }
}
< prev index next >