Mercurial > hg > truffle
diff graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java @ 19239:637ca4d37bca
Extensions and fixes to inline and canonicalize during parsing.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 10 Feb 2015 15:10:46 +0100 |
parents | ec0733b5a90a |
children | 8ab925a6f724 |
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Fri Feb 06 16:49:34 2015 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Tue Feb 10 15:10:46 2015 +0100 @@ -62,6 +62,14 @@ this.forStoreCheck = forStoreCheck; } + public static ValueNode create(ResolvedJavaType type, ValueNode object, JavaTypeProfile profile, boolean forStoreCheck) { + ValueNode synonym = findSynonym(type, object); + if (synonym != null) { + return synonym; + } + return new CheckCastNode(type, object, profile, forStoreCheck); + } + public boolean isForStoreCheck() { return forStoreCheck; } @@ -144,15 +152,9 @@ @Override public Node canonical(CanonicalizerTool tool) { - ResolvedJavaType objectType = StampTool.typeOrNull(object()); - if (objectType != null && type.isAssignableFrom(objectType)) { - // we don't have to check for null types here because they will also pass the - // checkcast. - return object(); - } - - if (StampTool.isPointerAlwaysNull(object())) { - return object(); + ValueNode synonym = findSynonym(type, object()); + if (synonym != null) { + return synonym; } if (tool.assumptions() != null && tool.assumptions().useOptimisticAssumptions()) { @@ -167,6 +169,20 @@ return this; } + private static ValueNode findSynonym(ResolvedJavaType type, ValueNode object) { + ResolvedJavaType objectType = StampTool.typeOrNull(object); + if (objectType != null && type.isAssignableFrom(objectType)) { + // we don't have to check for null types here because they will also pass the + // checkcast. + return object; + } + + if (StampTool.isPointerAlwaysNull(object)) { + return object; + } + return null; + } + @Override public void simplify(SimplifierTool tool) { // if the previous node is also a checkcast, with a less precise and compatible type,