Mercurial > hg > graal-jvmci-8
changeset 16422:7f20dee1be60
ensure instanceof and null check stay dependent
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Mon, 07 Jul 2014 20:27:20 -0700 |
parents | c158f653275e |
children | a9b85fe36dbc |
files | graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Mon Jul 07 20:26:31 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Mon Jul 07 20:27:20 2014 -0700 @@ -103,6 +103,7 @@ stamp = ((ObjectStamp) object().stamp()).castTo((ObjectStamp) stamp); } ValueNode condition; + ValueNode theValue = object; if (stamp instanceof IllegalStamp) { // This is a check cast that will always fail condition = LogicConstantNode.contradiction(graph()); @@ -116,6 +117,12 @@ InstanceOfNode typeTest = graph().addWithoutUnique(new InstanceOfNode(type, nullGuarded, profile)); graph().addBeforeFixed(this, nullCheck); condition = typeTest; + /* + * The PiNode is injecting an extra guard into the type so make sure it's used in + * the GuardingPi, otherwise we can lose the null guard if the InstanceOf is + * optimized away. + */ + theValue = nullGuarded; stamp = stamp.join(StampFactory.objectNonNull()); nullCheck.lower(tool); } else { @@ -125,7 +132,7 @@ condition = LogicNode.or(graph().unique(new IsNullNode(object)), typeTest, shortCircuitProbability); } } - GuardingPiNode checkedObject = graph().add(new GuardingPiNode(object, condition, false, forStoreCheck ? ArrayStoreException : ClassCastException, InvalidateReprofile, stamp)); + GuardingPiNode checkedObject = graph().add(new GuardingPiNode(theValue, condition, false, forStoreCheck ? ArrayStoreException : ClassCastException, InvalidateReprofile, stamp)); graph().replaceFixedWithFixed(this, checkedObject); checkedObject.lower(tool); }