Mercurial > hg > truffle
changeset 10918:3736fb3dcc56
checkcastnode: fix comment and scope in unittest
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Thu, 01 Aug 2013 17:23:28 +0200 |
parents | 92fc1db20ad9 |
children | 2cf0785957fb |
files | graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java |
diffstat | 2 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java Thu Aug 01 16:40:59 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java Thu Aug 01 17:23:28 2013 +0200 @@ -106,11 +106,11 @@ } private StructuredGraph compileSnippet(final String snippet, final int checkcasts, final int afterCanon) { - return Debug.scope(snippet, new Callable<StructuredGraph>() { + final StructuredGraph graph = parse(snippet); + return Debug.scope("NestedCheckCastsTest", graph, new Callable<StructuredGraph>() { @Override public StructuredGraph call() throws Exception { - StructuredGraph graph = parse(snippet); Debug.dump(graph, "After parsing: " + snippet); Assert.assertEquals(checkcasts, graph.getNodes().filter(CheckCastNode.class).count()); new CanonicalizerPhase.Instance(runtime(), new Assumptions(false), true).apply(graph);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Thu Aug 01 16:40:59 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Thu Aug 01 17:23:28 2013 +0200 @@ -146,7 +146,8 @@ return object(); } - // remove checkcast if next node is a more specific checkcast + // if the previous node is also a checkcast, with a less precise and compatible type, + // replace both with one checkcast checking the more specific type. if (predecessor() instanceof CheckCastNode) { CheckCastNode ccn = (CheckCastNode) predecessor(); if (ccn != null && ccn.type != null && ccn == object && ccn.forStoreCheck == forStoreCheck && ccn.type.isAssignableFrom(type)) {