# HG changeset patch # User Andreas Woess # Date 1397230887 -7200 # Node ID d44e138f7020f8121e560e3e0b8d7f59592692ea # Parent 7b3175685d197521476267e8cc7fa71d9d8c5ecf UnsafeCastNode: enable inference of more precise stamp diff -r 7b3175685d19 -r d44e138f7020 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 Fri Apr 11 16:41:56 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java Fri Apr 11 17:41:27 2014 +0200 @@ -59,30 +59,21 @@ } @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; - - ObjectStamp my = (ObjectStamp) stamp(); - ObjectStamp other = (ObjectStamp) object.stamp(); - - if (my.type() == null || other.type() == null) { - return this; - } - if (my.isExactType() && !other.isExactType()) { + if (stamp().equals(object.stamp())) { + return object; + } else { 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