# HG changeset patch # User Michael Van De Vanter # Date 1398882479 25200 # Node ID 625f779255a73391af07dde2c3e757986df4a5f6 # Parent 3774b6f4319b16566d4e4b412e42ee45c04721b0# Parent cb2eef41371c7e61e16c0076b0a1ad855dab86cc Merge with cb2eef41371c7e61e16c0076b0a1ad855dab86cc diff -r 3774b6f4319b -r 625f779255a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java Tue Apr 29 12:43:27 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java Wed Apr 30 11:27:59 2014 -0700 @@ -74,6 +74,9 @@ if (stamp() == StampFactory.forNodeIntrinsic()) { return false; } + if (stamp() instanceof ObjectStamp && object.stamp() instanceof ObjectStamp) { + return updateStamp(((ObjectStamp) object.stamp()).castTo((ObjectStamp) stamp())); + } return updateStamp(stamp().join(object().stamp())); } diff -r 3774b6f4319b -r 625f779255a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java Tue Apr 29 12:43:27 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java Wed Apr 30 11:27:59 2014 -0700 @@ -60,21 +60,30 @@ } @Override - public boolean inferStamp() { - if (stamp() instanceof ObjectStamp && object.stamp() instanceof ObjectStamp) { - return updateStamp(((ObjectStamp) object.stamp()).castTo((ObjectStamp) stamp())); - } - return updateStamp(object.stamp().join(stamp())); - } - - @Override public Node canonical(CanonicalizerTool tool) { assert getKind() == Kind.Object && object.getKind() == Kind.Object; - if (stamp().equals(object.stamp())) { - return object; - } else { + + ObjectStamp my = (ObjectStamp) stamp(); + ObjectStamp other = (ObjectStamp) object.stamp(); + + if (my.type() == null || other.type() == null) { + return this; + } + if (my.isExactType() && !other.isExactType()) { return this; } + if (my.nonNull() && !other.nonNull()) { + return this; + } + if (!my.type().isAssignableFrom(other.type())) { + return this; + } + /* + * The unsafe cast does not add any new type information, so it can be removed. Note that + * this means that the unsafe cast cannot be used to "drop" type information (in which case + * it must not be canonicalized in any case). + */ + return object; } @Override diff -r 3774b6f4319b -r 625f779255a7 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeTypeCastMacroNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeTypeCastMacroNode.java Tue Apr 29 12:43:27 2014 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeTypeCastMacroNode.java Wed Apr 30 11:27:59 2014 -0700 @@ -29,7 +29,6 @@ import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; -import com.oracle.graal.nodes.extended.*; import com.oracle.graal.truffle.nodes.asserts.*; import com.oracle.truffle.api.*; @@ -62,7 +61,7 @@ } Stamp stamp = StampFactory.declared(lookupJavaType, nonNullArgument.asConstant().asInt() != 0); ConditionAnchorNode valueAnchorNode = graph().add(new ConditionAnchorNode(CompareNode.createCompareNode(graph(), Condition.EQ, conditionArgument, ConstantNode.forBoolean(true, graph())))); - UnsafeCastNode piCast = graph().unique(new UnsafeCastNode(objectArgument, stamp, valueAnchorNode)); + PiNode piCast = graph().unique(new PiNode(objectArgument, stamp, valueAnchorNode)); this.replaceAtUsages(piCast); return valueAnchorNode; }