# HG changeset patch # User Andreas Woess # Date 1398879504 -7200 # Node ID 951647e16782432751362c4bc368bfbeaadc1059 # Parent 2f684eda1938cc92a72a35461c8d00f1871fe389 Backed out changeset: d44e138f7020 diff -r 2f684eda1938 -r 951647e16782 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 19:30:38 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java Wed Apr 30 19:38:24 2014 +0200 @@ -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