< prev index next >

test/hotspot/jtreg/compiler/valhalla/valuetypes/TestNullableArrays.java

Print this page




  68     }
  69 
  70     public static void main(String[] args) throws Throwable {
  71         TestNullableArrays test = new TestNullableArrays();
  72         test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class);
  73     }
  74 
  75     // Helper methods
  76 
  77     protected long hash() {
  78         return hash(rI, rL);
  79     }
  80 
  81     protected long hash(int x, long y) {
  82         return MyValue1.createWithFieldsInline(x, y).hash();
  83     }
  84 
  85     private static final MyValue1 testValue1 = MyValue1.createWithFieldsInline(rI, rL);
  86 
  87     // Test nullable value type array creation and initialization
  88     @Test(valid = ValueTypeArrayFlattenOff, failOn = LOAD)
  89     @Test(valid = ValueTypeArrayFlattenOn)

  90     public MyValue1?[] test1(int len) {
  91         MyValue1?[] va = new MyValue1?[len];
  92         if (len > 0) {
  93             va[0] = null;
  94         }
  95         for (int i = 1; i < len; ++i) {
  96             va[i] = MyValue1.createWithFieldsDontInline(rI, rL);
  97         }
  98         return va;
  99     }
 100 
 101     @DontCompile
 102     public void test1_verifier(boolean warmup) {
 103         int len = Math.abs(rI % 10);
 104         MyValue1?[] va = test1(len);
 105         if (len > 0) {
 106             Asserts.assertEQ(va[0], null);
 107         }
 108         for (int i = 1; i < len; ++i) {
 109             Asserts.assertEQ(va[i].hash(), hash());
 110         }
 111     }
 112 
 113     // Test creation of a value type array and element access
 114     @Test()
 115 // TODO fix
 116 //    @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP)
 117     public long test2() {
 118         MyValue1?[] va = new MyValue1?[1];
 119         va[0] = MyValue1.createWithFieldsInline(rI, rL);
 120         return va[0].hash();
 121     }
 122 
 123     @DontCompile
 124     public void test2_verifier(boolean warmup) {
 125         long result = test2();
 126         Asserts.assertEQ(result, hash());
 127     }
 128 
 129     // Test receiving a value type array from the interpreter,
 130     // updating its elements in a loop and computing a hash.
 131     @Test(failOn = ALLOCA)
 132     public long test3(MyValue1?[] va) {
 133         long result = 0;
 134         for (int i = 0; i < 10; ++i) {
 135             if (va[i] != null) {
 136                 result += va[i].hash();


 205 
 206     @DontCompile
 207     public void test5_verifier(boolean warmup) {
 208         MyValue1?[] va = test5(true);
 209         Asserts.assertEQ(va.length, 5);
 210         Asserts.assertEQ(va[0].hash(), hash(rI, hash()));
 211         for (int i = 1; i < 4; ++i) {
 212             Asserts.assertEQ(va[i].hash(), hash());
 213         }
 214         Asserts.assertEQ(va[4], null);
 215         va = test5(false);
 216         Asserts.assertEQ(va.length, 10);
 217         Asserts.assertEQ(va[0].hash(), hash(rI + 1, hash(rI, rL) + 1));
 218         for (int i = 1; i < 9; ++i) {
 219             Asserts.assertEQ(va[i].hash(), hash(rI + i, rL + i));
 220         }
 221         Asserts.assertEQ(va[9], null);
 222     }
 223 
 224     // Test creation of value type array with single element
 225     @Test(failOn = ALLOCA + LOOP + LOAD + TRAP)
 226     public MyValue1? test6() {
 227         MyValue1?[] va = new MyValue1?[1];
 228         return va[0];
 229     }
 230 
 231     @DontCompile
 232     public void test6_verifier(boolean warmup) {
 233         MyValue1?[] va = new MyValue1?[1];
 234         MyValue1? v = test6();
 235         Asserts.assertEQ(v, null);
 236     }
 237 
 238     // Test default initialization of value type arrays
 239     @Test(failOn = LOAD)
 240     public MyValue1?[] test7(int len) {
 241         return new MyValue1?[len];
 242     }
 243 
 244     @DontCompile
 245     public void test7_verifier(boolean warmup) {


 847         }
 848         test27(src1, dst1);
 849         test27(src2, dst2);
 850         test27(src3, dst3);
 851         test27(src4, dst4);
 852         for (int i = 0; i < 2; ++i) {
 853             Asserts.assertEQ(dst1[i], null);
 854             Asserts.assertEQ(dst2[i].hash(), MyValue1.default.hash());
 855             Asserts.assertEQ(dst3[i], null);
 856             Asserts.assertEQ(dst4[i].hash(), MyValue1.default.hash());
 857         }
 858         for (int i = 2; i < 8; ++i) {
 859             Asserts.assertEQ(src1[i].hash(), dst1[i].hash());
 860             Asserts.assertEQ(src2[i].hash(), dst2[i].hash());
 861             Asserts.assertEQ(src3[i].hash(), dst3[i].hash());
 862             Asserts.assertEQ(src4[i].hash(), dst4[i].hash());
 863         }
 864     }
 865 
 866     // non escaping allocations
 867 // TODO fix
 868 //    @Test(failOn = ALLOCA + LOOP + LOAD + TRAP)
 869     public MyValue2? test28() {
 870         MyValue2?[] src = new MyValue2?[10];
 871         src[0] = null;
 872         MyValue2?[] dst = (MyValue2?[])src.clone();
 873         return dst[0];
 874     }
 875 
 876     @DontCompile
 877     public void test28_verifier(boolean warmup) {
 878         MyValue2 v = MyValue2.createWithFieldsInline(rI, false);
 879         MyValue2? result = test28();
 880         Asserts.assertEQ(result, null);
 881     }
 882 
 883     // non escaping allocations

 884     @Test(failOn = ALLOCA + LOOP + TRAP)
 885     public MyValue2? test29(MyValue2?[] src) {
 886         MyValue2?[] dst = new MyValue2?[10];
 887         System.arraycopy(src, 0, dst, 0, 10);
 888         return dst[0];
 889     }
 890 
 891     @DontCompile
 892     public void test29_verifier(boolean warmup) {
 893         MyValue2?[] src = new MyValue2?[10];
 894         for (int i = 0; i < 10; ++i) {
 895             src[i] = MyValue2.createWithFieldsInline(rI, (i % 2) == 0);
 896         }
 897         MyValue2? v = test29(src);
 898         Asserts.assertEQ(src[0].hash(), v.hash());
 899     }
 900 
 901     // non escaping allocation with uncommon trap that needs
 902     // eliminated value type array element as debug info
 903     @Test
 904     @Warmup(10000)
 905     public MyValue2? test30(MyValue2?[] src, boolean flag) {
 906         MyValue2?[] dst = new MyValue2?[10];
 907         System.arraycopy(src, 0, dst, 0, 10);
 908         if (flag) { }
 909         return dst[0];
 910     }
 911 
 912     @DontCompile
 913     public void test30_verifier(boolean warmup) {
 914         MyValue2?[] src = new MyValue2?[10];
 915         for (int i = 0; i < 10; ++i) {
 916             src[i] = MyValue2.createWithFieldsInline(rI, (i % 2) == 0);
 917         }
 918         MyValue2? v = test30(src, false);
 919         Asserts.assertEQ(src[0].hash(), v.hash());
 920     }
 921 
 922     // non escaping allocation with memory phi
 923     @Test()
 924 // TODO fix
 925 //    @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + TRAP)
 926     public long test31(boolean b, boolean deopt) {
 927         MyValue2?[] src = new MyValue2?[1];
 928         if (b) {
 929             src[0] = MyValue2.createWithFieldsInline(rI, true);
 930         } else {
 931             src[0] = MyValue2.createWithFieldsInline(rI, false);
 932         }
 933         if (deopt) {
 934             // uncommon trap
 935             WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test31"));
 936         }
 937         return src[0].hash();
 938     }
 939 
 940     @DontCompile
 941     public void test31_verifier(boolean warmup) {
 942         MyValue2 v1 = MyValue2.createWithFieldsInline(rI, true);
 943         long result1 = test31(true, !warmup);
 944         Asserts.assertEQ(result1, v1.hash());
 945         MyValue2 v2 = MyValue2.createWithFieldsInline(rI, false);


2095         MyValue1?[] vba_r = new MyValue1?[42];
2096         vba_r[0] = vt;
2097         Object[] result = test78(vva, vba, vt, out, 0);
2098         verify(result, vva_r);
2099         Asserts.assertEQ(out[0], vva_r[1]);
2100         result = test78(vva, vba, vt, out, 1);
2101         verify(result, vba_r);
2102         Asserts.assertEQ(out[0], vba_r[1]);
2103         result = test78(vva, vba, vt, out, 2);
2104         verify(result, vva_r);
2105         Asserts.assertEQ(out[0], vva_r[1]);
2106         result = test78(vva, vba, vt, out, 3);
2107         verify(result, vba_r);
2108         Asserts.assertEQ(out[0], vba_r[1]);
2109         result = test78(vva, vba, i, out, 4);
2110         Asserts.assertEQ(result[0], i);
2111         Asserts.assertEQ(out[0], null);
2112     }
2113 
2114     // Test widening conversions from [Q to [L
2115     @Test(failOn = ALLOC + ALLOCA + STORE)
2116     public static MyValue1?[] test79(MyValue1[] va) {
2117         return va;
2118     }
2119 
2120     @DontCompile
2121     public void test79_verifier(boolean warmup) {
2122         MyValue1[] va = new MyValue1[1];
2123         va[0] = testValue1;
2124         MyValue1?[] res = test79(va);
2125         Asserts.assertEquals(res[0].hash(), testValue1.hash());
2126         try {
2127             res[0] = null;
2128             throw new RuntimeException("NullPointerException expected");
2129         } catch (NullPointerException npe) {
2130             // Expected
2131         }
2132         res[0] = testValue1;
2133         test79(null); // Should not throw NPE
2134     }
2135 
2136     // Same as test79 but with explicit cast and Object return
2137     @Test(failOn = ALLOC + ALLOCA + STORE)
2138     public static Object[] test80(MyValue1[] va) {
2139         return (MyValue1?[])va;
2140     }
2141 
2142     @DontCompile
2143     public void test80_verifier(boolean warmup) {
2144         MyValue1[] va = new MyValue1[1];
2145         va[0] = testValue1;
2146         Object[] res = test80(va);
2147         Asserts.assertEquals(((MyValue1)res[0]).hash(), testValue1.hash());
2148         try {
2149             res[0] = null;
2150             throw new RuntimeException("NullPointerException expected");
2151         } catch (NullPointerException npe) {
2152             // Expected
2153         }
2154         res[0] = testValue1;
2155         test80(null); // Should not throw NPE
2156     }
2157 


2231         Asserts.assertEquals(res, testValue1.hash());
2232         res = test82(va, va, testValue1, null, 3, true);
2233         Asserts.assertEquals(va[0].hash(), testValue1.hash());
2234         Asserts.assertEquals(res, testValue1.hash());
2235     }
2236 
2237     @Test(failOn = ALLOC + ALLOCA + STORE)
2238     public static long test83(MyValue1[] va) {
2239         MyValue1?[] result = va;
2240         return result[0].hash();
2241     }
2242 
2243     @DontCompile
2244     public void test83_verifier(boolean warmup) {
2245         MyValue1[] va = new MyValue1[42];
2246         va[0] = testValue1;
2247         long res = test83(va);
2248         Asserts.assertEquals(res, testValue1.hash());
2249     }
2250 
2251     @Test(failOn = ALLOC + ALLOCA + STORE)

2252     public static MyValue1?[] test84(MyValue1 vt1, MyValue1? vt2) {
2253         MyValue1?[] result = new MyValue1[2];
2254         result[0] = vt1;
2255         result[1] = vt2;
2256         return result;
2257     }
2258 
2259     @DontCompile
2260     public void test84_verifier(boolean warmup) {
2261         MyValue1?[] res = test84(testValue1, testValue1);
2262         Asserts.assertEquals(res[0].hash(), testValue1.hash());
2263         Asserts.assertEquals(res[1].hash(), testValue1.hash());
2264         try {
2265             test84(testValue1, null);
2266             throw new RuntimeException("NullPointerException expected");
2267         } catch (NullPointerException npe) {
2268             // Expected
2269         }
2270     }
2271 


2317         res = test86(vab, null);
2318         Asserts.assertEquals(res, testValue1.hash());
2319         Asserts.assertEquals(vab[0], null);
2320     }
2321 
2322     // Test initialization of nullable array with constant
2323     @Test()
2324     public long test87() {
2325         MyValue1?[] va = new MyValue1?[1];
2326         va[0] = testValue1;
2327         return va[0].hash();
2328     }
2329 
2330     @DontCompile
2331     public void test87_verifier(boolean warmup) {
2332         long result = test87();
2333         Asserts.assertEQ(result, hash());
2334     }
2335 
2336     // Test narrowing conversion from [L to [Q
2337     @Test(failOn = ALLOC + ALLOCA + STORE)
2338     public static MyValue1[] test88(MyValue1?[] va) {
2339         return (MyValue1[])va;
2340     }
2341 
2342     @DontCompile
2343     public void test88_verifier(boolean warmup) {
2344         MyValue1[] va = new MyValue1[1];
2345         va[0] = testValue1;
2346         MyValue1[] res = test88(va);
2347         Asserts.assertEquals(res[0].hash(), testValue1.hash());
2348         res[0] = testValue1;
2349         test88(null); // Should not throw NPE
2350         try {
2351             test88(new MyValue1?[1]);
2352             throw new RuntimeException("ClassCastException expected");
2353         } catch (ClassCastException cce) {
2354             // Expected
2355         }
2356     }
2357 
2358     // Same as test88 but with explicit cast and Object argument
2359     @Test(failOn = ALLOC + ALLOCA + STORE)
2360     public static MyValue1[] test89(Object[] va) {
2361         return (MyValue1[])va;
2362     }
2363 
2364     @DontCompile
2365     public void test89_verifier(boolean warmup) {
2366         MyValue1[] va = new MyValue1[1];
2367         va[0] = testValue1;
2368         MyValue1[] res = test89(va);
2369         Asserts.assertEquals(((MyValue1)res[0]).hash(), testValue1.hash());
2370         res[0] = testValue1;
2371         test89(null); // Should not throw NPE
2372         try {
2373             test89(new MyValue1?[1]);
2374             throw new RuntimeException("ClassCastException expected");
2375         } catch (ClassCastException cce) {
2376             // Expected
2377         }
2378     }
2379 




  68     }
  69 
  70     public static void main(String[] args) throws Throwable {
  71         TestNullableArrays test = new TestNullableArrays();
  72         test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class);
  73     }
  74 
  75     // Helper methods
  76 
  77     protected long hash() {
  78         return hash(rI, rL);
  79     }
  80 
  81     protected long hash(int x, long y) {
  82         return MyValue1.createWithFieldsInline(x, y).hash();
  83     }
  84 
  85     private static final MyValue1 testValue1 = MyValue1.createWithFieldsInline(rI, rL);
  86 
  87     // Test nullable value type array creation and initialization

  88     @Test(valid = ValueTypeArrayFlattenOn)
  89     @Test(valid = ValueTypeArrayFlattenOff, failOn = LOAD)
  90     public MyValue1?[] test1(int len) {
  91         MyValue1?[] va = new MyValue1?[len];
  92         if (len > 0) {
  93             va[0] = null;
  94         }
  95         for (int i = 1; i < len; ++i) {
  96             va[i] = MyValue1.createWithFieldsDontInline(rI, rL);
  97         }
  98         return va;
  99     }
 100 
 101     @DontCompile
 102     public void test1_verifier(boolean warmup) {
 103         int len = Math.abs(rI % 10);
 104         MyValue1?[] va = test1(len);
 105         if (len > 0) {
 106             Asserts.assertEQ(va[0], null);
 107         }
 108         for (int i = 1; i < len; ++i) {
 109             Asserts.assertEQ(va[i].hash(), hash());
 110         }
 111     }
 112 
 113     // Test creation of a value type array and element access
 114     @Test
 115     // TODO 8227588
 116     // @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP)
 117     public long test2() {
 118         MyValue1?[] va = new MyValue1?[1];
 119         va[0] = MyValue1.createWithFieldsInline(rI, rL);
 120         return va[0].hash();
 121     }
 122 
 123     @DontCompile
 124     public void test2_verifier(boolean warmup) {
 125         long result = test2();
 126         Asserts.assertEQ(result, hash());
 127     }
 128 
 129     // Test receiving a value type array from the interpreter,
 130     // updating its elements in a loop and computing a hash.
 131     @Test(failOn = ALLOCA)
 132     public long test3(MyValue1?[] va) {
 133         long result = 0;
 134         for (int i = 0; i < 10; ++i) {
 135             if (va[i] != null) {
 136                 result += va[i].hash();


 205 
 206     @DontCompile
 207     public void test5_verifier(boolean warmup) {
 208         MyValue1?[] va = test5(true);
 209         Asserts.assertEQ(va.length, 5);
 210         Asserts.assertEQ(va[0].hash(), hash(rI, hash()));
 211         for (int i = 1; i < 4; ++i) {
 212             Asserts.assertEQ(va[i].hash(), hash());
 213         }
 214         Asserts.assertEQ(va[4], null);
 215         va = test5(false);
 216         Asserts.assertEQ(va.length, 10);
 217         Asserts.assertEQ(va[0].hash(), hash(rI + 1, hash(rI, rL) + 1));
 218         for (int i = 1; i < 9; ++i) {
 219             Asserts.assertEQ(va[i].hash(), hash(rI + i, rL + i));
 220         }
 221         Asserts.assertEQ(va[9], null);
 222     }
 223 
 224     // Test creation of value type array with single element
 225     @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP)
 226     public MyValue1? test6() {
 227         MyValue1?[] va = new MyValue1?[1];
 228         return va[0];
 229     }
 230 
 231     @DontCompile
 232     public void test6_verifier(boolean warmup) {
 233         MyValue1?[] va = new MyValue1?[1];
 234         MyValue1? v = test6();
 235         Asserts.assertEQ(v, null);
 236     }
 237 
 238     // Test default initialization of value type arrays
 239     @Test(failOn = LOAD)
 240     public MyValue1?[] test7(int len) {
 241         return new MyValue1?[len];
 242     }
 243 
 244     @DontCompile
 245     public void test7_verifier(boolean warmup) {


 847         }
 848         test27(src1, dst1);
 849         test27(src2, dst2);
 850         test27(src3, dst3);
 851         test27(src4, dst4);
 852         for (int i = 0; i < 2; ++i) {
 853             Asserts.assertEQ(dst1[i], null);
 854             Asserts.assertEQ(dst2[i].hash(), MyValue1.default.hash());
 855             Asserts.assertEQ(dst3[i], null);
 856             Asserts.assertEQ(dst4[i].hash(), MyValue1.default.hash());
 857         }
 858         for (int i = 2; i < 8; ++i) {
 859             Asserts.assertEQ(src1[i].hash(), dst1[i].hash());
 860             Asserts.assertEQ(src2[i].hash(), dst2[i].hash());
 861             Asserts.assertEQ(src3[i].hash(), dst3[i].hash());
 862             Asserts.assertEQ(src4[i].hash(), dst4[i].hash());
 863         }
 864     }
 865 
 866     // non escaping allocations
 867     @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP)

 868     public MyValue2? test28() {
 869         MyValue2?[] src = new MyValue2?[10];
 870         src[0] = null;
 871         MyValue2?[] dst = (MyValue2?[])src.clone();
 872         return dst[0];
 873     }
 874 
 875     @DontCompile
 876     public void test28_verifier(boolean warmup) {
 877         MyValue2 v = MyValue2.createWithFieldsInline(rI, false);
 878         MyValue2? result = test28();
 879         Asserts.assertEQ(result, null);
 880     }
 881 
 882     // non escaping allocations
 883     // TODO 8227588: shouldn't this have the same IR matching rules as test6?
 884     @Test(failOn = ALLOCA + LOOP + TRAP)
 885     public MyValue2? test29(MyValue2?[] src) {
 886         MyValue2?[] dst = new MyValue2?[10];
 887         System.arraycopy(src, 0, dst, 0, 10);
 888         return dst[0];
 889     }
 890 
 891     @DontCompile
 892     public void test29_verifier(boolean warmup) {
 893         MyValue2?[] src = new MyValue2?[10];
 894         for (int i = 0; i < 10; ++i) {
 895             src[i] = MyValue2.createWithFieldsInline(rI, (i % 2) == 0);
 896         }
 897         MyValue2? v = test29(src);
 898         Asserts.assertEQ(src[0].hash(), v.hash());
 899     }
 900 
 901     // non escaping allocation with uncommon trap that needs
 902     // eliminated value type array element as debug info
 903     @Test
 904     @Warmup(10000)
 905     public MyValue2? test30(MyValue2?[] src, boolean flag) {
 906         MyValue2?[] dst = new MyValue2?[10];
 907         System.arraycopy(src, 0, dst, 0, 10);
 908         if (flag) { }
 909         return dst[0];
 910     }
 911 
 912     @DontCompile
 913     public void test30_verifier(boolean warmup) {
 914         MyValue2?[] src = new MyValue2?[10];
 915         for (int i = 0; i < 10; ++i) {
 916             src[i] = MyValue2.createWithFieldsInline(rI, (i % 2) == 0);
 917         }
 918         MyValue2? v = test30(src, false);
 919         Asserts.assertEQ(src[0].hash(), v.hash());
 920     }
 921 
 922     // non escaping allocation with memory phi
 923     @Test()
 924     // TODO 8227588
 925     // @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP)
 926     public long test31(boolean b, boolean deopt) {
 927         MyValue2?[] src = new MyValue2?[1];
 928         if (b) {
 929             src[0] = MyValue2.createWithFieldsInline(rI, true);
 930         } else {
 931             src[0] = MyValue2.createWithFieldsInline(rI, false);
 932         }
 933         if (deopt) {
 934             // uncommon trap
 935             WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test31"));
 936         }
 937         return src[0].hash();
 938     }
 939 
 940     @DontCompile
 941     public void test31_verifier(boolean warmup) {
 942         MyValue2 v1 = MyValue2.createWithFieldsInline(rI, true);
 943         long result1 = test31(true, !warmup);
 944         Asserts.assertEQ(result1, v1.hash());
 945         MyValue2 v2 = MyValue2.createWithFieldsInline(rI, false);


2095         MyValue1?[] vba_r = new MyValue1?[42];
2096         vba_r[0] = vt;
2097         Object[] result = test78(vva, vba, vt, out, 0);
2098         verify(result, vva_r);
2099         Asserts.assertEQ(out[0], vva_r[1]);
2100         result = test78(vva, vba, vt, out, 1);
2101         verify(result, vba_r);
2102         Asserts.assertEQ(out[0], vba_r[1]);
2103         result = test78(vva, vba, vt, out, 2);
2104         verify(result, vva_r);
2105         Asserts.assertEQ(out[0], vva_r[1]);
2106         result = test78(vva, vba, vt, out, 3);
2107         verify(result, vba_r);
2108         Asserts.assertEQ(out[0], vba_r[1]);
2109         result = test78(vva, vba, i, out, 4);
2110         Asserts.assertEQ(result[0], i);
2111         Asserts.assertEQ(out[0], null);
2112     }
2113 
2114     // Test widening conversions from [Q to [L
2115     @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP)
2116     public static MyValue1?[] test79(MyValue1[] va) {
2117         return va;
2118     }
2119 
2120     @DontCompile
2121     public void test79_verifier(boolean warmup) {
2122         MyValue1[] va = new MyValue1[1];
2123         va[0] = testValue1;
2124         MyValue1?[] res = test79(va);
2125         Asserts.assertEquals(res[0].hash(), testValue1.hash());
2126         try {
2127             res[0] = null;
2128             throw new RuntimeException("NullPointerException expected");
2129         } catch (NullPointerException npe) {
2130             // Expected
2131         }
2132         res[0] = testValue1;
2133         test79(null); // Should not throw NPE
2134     }
2135 
2136     // Same as test79 but with explicit cast and Object return
2137     @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP)
2138     public static Object[] test80(MyValue1[] va) {
2139         return (MyValue1?[])va;
2140     }
2141 
2142     @DontCompile
2143     public void test80_verifier(boolean warmup) {
2144         MyValue1[] va = new MyValue1[1];
2145         va[0] = testValue1;
2146         Object[] res = test80(va);
2147         Asserts.assertEquals(((MyValue1)res[0]).hash(), testValue1.hash());
2148         try {
2149             res[0] = null;
2150             throw new RuntimeException("NullPointerException expected");
2151         } catch (NullPointerException npe) {
2152             // Expected
2153         }
2154         res[0] = testValue1;
2155         test80(null); // Should not throw NPE
2156     }
2157 


2231         Asserts.assertEquals(res, testValue1.hash());
2232         res = test82(va, va, testValue1, null, 3, true);
2233         Asserts.assertEquals(va[0].hash(), testValue1.hash());
2234         Asserts.assertEquals(res, testValue1.hash());
2235     }
2236 
2237     @Test(failOn = ALLOC + ALLOCA + STORE)
2238     public static long test83(MyValue1[] va) {
2239         MyValue1?[] result = va;
2240         return result[0].hash();
2241     }
2242 
2243     @DontCompile
2244     public void test83_verifier(boolean warmup) {
2245         MyValue1[] va = new MyValue1[42];
2246         va[0] = testValue1;
2247         long res = test83(va);
2248         Asserts.assertEquals(res, testValue1.hash());
2249     }
2250 
2251     @Test(valid = ValueTypeArrayFlattenOn, failOn = ALLOC + ALLOCA + LOOP + STORE + TRAP)
2252     @Test(valid = ValueTypeArrayFlattenOff)
2253     public static MyValue1?[] test84(MyValue1 vt1, MyValue1? vt2) {
2254         MyValue1?[] result = new MyValue1[2];
2255         result[0] = vt1;
2256         result[1] = vt2;
2257         return result;
2258     }
2259 
2260     @DontCompile
2261     public void test84_verifier(boolean warmup) {
2262         MyValue1?[] res = test84(testValue1, testValue1);
2263         Asserts.assertEquals(res[0].hash(), testValue1.hash());
2264         Asserts.assertEquals(res[1].hash(), testValue1.hash());
2265         try {
2266             test84(testValue1, null);
2267             throw new RuntimeException("NullPointerException expected");
2268         } catch (NullPointerException npe) {
2269             // Expected
2270         }
2271     }
2272 


2318         res = test86(vab, null);
2319         Asserts.assertEquals(res, testValue1.hash());
2320         Asserts.assertEquals(vab[0], null);
2321     }
2322 
2323     // Test initialization of nullable array with constant
2324     @Test()
2325     public long test87() {
2326         MyValue1?[] va = new MyValue1?[1];
2327         va[0] = testValue1;
2328         return va[0].hash();
2329     }
2330 
2331     @DontCompile
2332     public void test87_verifier(boolean warmup) {
2333         long result = test87();
2334         Asserts.assertEQ(result, hash());
2335     }
2336 
2337     // Test narrowing conversion from [L to [Q
2338     @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP)
2339     public static MyValue1[] test88(MyValue1?[] va) {
2340         return (MyValue1[])va;
2341     }
2342 
2343     @DontCompile
2344     public void test88_verifier(boolean warmup) {
2345         MyValue1[] va = new MyValue1[1];
2346         va[0] = testValue1;
2347         MyValue1[] res = test88(va);
2348         Asserts.assertEquals(res[0].hash(), testValue1.hash());
2349         res[0] = testValue1;
2350         test88(null); // Should not throw NPE
2351         try {
2352             test88(new MyValue1?[1]);
2353             throw new RuntimeException("ClassCastException expected");
2354         } catch (ClassCastException cce) {
2355             // Expected
2356         }
2357     }
2358 
2359     // Same as test88 but with explicit cast and Object argument
2360     @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP)
2361     public static MyValue1[] test89(Object[] va) {
2362         return (MyValue1[])va;
2363     }
2364 
2365     @DontCompile
2366     public void test89_verifier(boolean warmup) {
2367         MyValue1[] va = new MyValue1[1];
2368         va[0] = testValue1;
2369         MyValue1[] res = test89(va);
2370         Asserts.assertEquals(((MyValue1)res[0]).hash(), testValue1.hash());
2371         res[0] = testValue1;
2372         test89(null); // Should not throw NPE
2373         try {
2374             test89(new MyValue1?[1]);
2375             throw new RuntimeException("ClassCastException expected");
2376         } catch (ClassCastException cce) {
2377             // Expected
2378         }
2379     }
2380 


< prev index next >