# HG changeset patch # User Bernhard Urban # Date 1375370608 -7200 # Node ID 3736fb3dcc56d96b1ad51db4e5c96eb5ad46f53a # Parent 92fc1db20ad95ccb1d7ee91a7b63b4c867560f97 checkcastnode: fix comment and scope in unittest diff -r 92fc1db20ad9 -r 3736fb3dcc56 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java --- 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() { + final StructuredGraph graph = parse(snippet); + return Debug.scope("NestedCheckCastsTest", graph, new Callable() { @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); diff -r 92fc1db20ad9 -r 3736fb3dcc56 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java --- 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)) {