changeset 11446:124662d7d103

PushThroughPi: extend test for ReadNodes
author Bernhard Urban <bernhard.urban@jku.at>
date Wed, 28 Aug 2013 21:28:58 +0200
parents 5fbd1ba4a5f3
children 3653d3a66d3b
files graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java
diffstat 1 files changed, 15 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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);
             }