Mercurial > hg > graal-compiler
changeset 15073:d44e138f7020
UnsafeCastNode: enable inference of more precise stamp
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Fri, 11 Apr 2014 17:41:27 +0200 |
parents | 7b3175685d19 |
children | d8e0e684f7f5 |
files | graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java |
diffstat | 1 files changed, 11 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- 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