# HG changeset patch # User Bernhard Urban # Date 1377718138 -7200 # Node ID 124662d7d103a4877bff97ad5f108ed019bb1705 # Parent 5fbd1ba4a5f3514cdb9448dd1033d56b0fac4439 PushThroughPi: extend test for ReadNodes diff -r 5fbd1ba4a5f3 -r 124662d7d103 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java Wed Aug 28 18:45:32 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java Wed Aug 28 21:28:58 2013 +0200 @@ -47,12 +47,18 @@ public long y = 10; } + public static class C extends B { + + public long z = 5; + } + public static long test1Snippet(A a) { - B b = (B) a; - long ret = b.x; // this can be moved before the checkcast - ret += b.y; + C c = (C) a; + long ret = c.x; // this can be pushed before the checkcast + ret += c.y; // not allowed to push + ret += c.z; // not allowed to push // the null-check should be canonicalized with the null-check of the checkcast - ret += b != null ? 100 : 200; + ret += c != null ? 100 : 200; return ret; } @@ -64,24 +70,20 @@ public void run() { StructuredGraph graph = compileTestSnippet(snippet); - int counter = 0; for (ReadNode rn : graph.getNodes().filter(ReadNode.class)) { if (rn.location() instanceof ConstantLocationNode && rn.object().stamp() instanceof ObjectStamp) { long disp = ((ConstantLocationNode) rn.location()).getDisplacement(); ResolvedJavaType receiverType = ObjectStamp.typeOrNull(rn.object()); ResolvedJavaField field = receiverType.findInstanceFieldWithOffset(disp); - if (field != null) { - if (field.getName().equals("x")) { - Assert.assertTrue(rn.object() instanceof LocalNode); - } else { - Assert.assertTrue(rn.object().toString(), rn.object() instanceof PiNode); - } - counter++; + assert field != null : "Node " + rn + " tries to access a field which doesn't exists for this type"; + if (field.getName().equals("x")) { + Assert.assertTrue(rn.object() instanceof LocalNode); + } else { + Assert.assertTrue(rn.object().toString(), rn.object() instanceof PiNode); } } } - Assert.assertEquals(2, counter); Assert.assertTrue(graph.getNodes().filter(IsNullNode.class).count() == 1); }