Mercurial > hg > graal-compiler
changeset 5417:791eb4f85b29
Use exact type for check cast canonicalization if available
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Fri, 18 May 2012 15:49:46 +0200 |
parents | bd5624f04067 |
children | 8dc11fe22eb1 |
files | graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Fri May 18 15:49:23 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Fri May 18 15:49:46 2012 +0200 @@ -74,10 +74,15 @@ public ValueNode canonical(CanonicalizerTool tool) { assert object() != null : this; - RiResolvedType objectDeclaredType = object().declaredType(); - if (objectDeclaredType != null && targetClass != null && objectDeclaredType.isSubtypeOf(targetClass)) { - // we don't have to check for null types here because they will also pass the checkcast. - return object(); + if (targetClass != null) { + RiResolvedType objectType = object().exactType(); + if (objectType == null) { + objectType = object().declaredType(); + } + if (objectType != null && objectType.isSubtypeOf(targetClass)) { + // we don't have to check for null types here because they will also pass the checkcast. + return object(); + } } CiConstant constant = object().asConstant();