< prev index next >

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

Print this page




2072     }
2073 
2074     @Test
2075     @Warmup(10000)
2076     public void test83(Object[] dst, Object v, boolean flag) {
2077         if (dst == null) { // null check
2078         }
2079         if (flag) {
2080             if (dst.getClass() == MyValue1[].class) { // trigger split if
2081             }
2082         } else {
2083             dst = new MyValue2[1]; // constant null free property
2084         }
2085         dst[0] = v;
2086     }
2087 
2088     @DontCompile
2089     public void test83_verifier(boolean warmup) {
2090         MyValue2[] dst = new MyValue2[1];
2091         test83(dst, testValue2, false);

2092         if (!warmup) {
2093             try {
2094                 test83(dst, null, true);
2095                 throw new RuntimeException("No ArrayStoreException thrown");
2096             } catch (NullPointerException e) {
2097                 // Expected
2098             }
2099         }
2100     }
2101 
2102     // Following: should make 2 copies of the loop, one for non
2103     // flattened arrays, one for other cases
2104     @Test(match = { COUNTEDLOOP }, matchCount = { 4 } )
2105     public void test84(Object[] src, Object[] dst) {
2106         for (int i = 0; i < src.length; i++) {
2107             dst[i] = src[i];
2108         }
2109     }
2110 
2111     @DontCompile
2112     public void test84_verifier(boolean warmup) {
2113         MyValue2[] src = new MyValue2[100];
2114         Arrays.fill(src, testValue2);
2115         MyValue2[] dst = new MyValue2[100];
2116         test84(src, dst);
2117         Asserts.assertTrue(Arrays.equals(src, dst));
2118     }
2119 
2120     @Test(valid = G1GCOn, match = { COUNTEDLOOP }, matchCount = { 2 } )
2121     @Test(valid = G1GCOff, match = { COUNTEDLOOP }, matchCount = { 3 } )
2122     public void test85(Object[] src, Object[] dst) {
2123         for (int i = 0; i < src.length; i++) {
2124             dst[i] = src[i];
2125         }
2126     }
2127 
2128     @DontCompile
2129     public void test85_verifier(boolean warmup) {
2130         Object[] src = new Object[100];
2131         Arrays.fill(src, new Object());
2132         src[0] = null;
2133         Object[] dst = new Object[100];
2134         test85(src, dst);
2135         Asserts.assertTrue(Arrays.equals(src, dst));
2136     }
2137 
2138     @Test(valid = G1GCOn, match = { COUNTEDLOOP }, matchCount = { 2 } )
2139     @Test(valid = G1GCOff, match = { COUNTEDLOOP }, matchCount = { 3 } )
2140     public void test86(Object[] src, Object[] dst) {
2141         for (int i = 0; i < src.length; i++) {


2215         try {
2216             test90(new Object());
2217             throw new RuntimeException("ClassCastException expected");
2218         } catch (ClassCastException e) {
2219             // Expected
2220         }
2221     }
2222 
2223     // Same as test89 but bit clearing can not be removed because
2224     // we are comparing to a inline type array klass.
2225     @Test(match = {STORAGE_PROPERTY_CLEARING}, matchCount = { 1 })
2226     public boolean test91(Object obj) {
2227         return obj.getClass() == MyValue2[].class;
2228     }
2229 
2230     @DontCompile
2231     public void test91_verifier(boolean warmup) {
2232         Asserts.assertTrue(test91(new MyValue2[1]));
2233         Asserts.assertFalse(test91(new Object()));
2234     }





























































































2235 }


2072     }
2073 
2074     @Test
2075     @Warmup(10000)
2076     public void test83(Object[] dst, Object v, boolean flag) {
2077         if (dst == null) { // null check
2078         }
2079         if (flag) {
2080             if (dst.getClass() == MyValue1[].class) { // trigger split if
2081             }
2082         } else {
2083             dst = new MyValue2[1]; // constant null free property
2084         }
2085         dst[0] = v;
2086     }
2087 
2088     @DontCompile
2089     public void test83_verifier(boolean warmup) {
2090         MyValue2[] dst = new MyValue2[1];
2091         test83(dst, testValue2, false);
2092         test83(dst, testValue2, true);
2093         if (!warmup) {
2094             try {
2095                 test83(dst, null, true);
2096                 throw new RuntimeException("No ArrayStoreException thrown");
2097             } catch (NullPointerException e) {
2098                 // Expected
2099             }
2100         }
2101     }
2102 
2103     // Following: should make 2 copies of the loop, one for non
2104     // flattened arrays, one for other cases
2105     @Test(match = { COUNTEDLOOP }, matchCount = { 4 } )
2106     public void test84(Object[] src, Object[] dst) {
2107         for (int i = 0; i < src.length; i++) {
2108             dst[i] = src[i];
2109         }
2110     }
2111 
2112     @DontCompile
2113     public void test84_verifier(boolean warmup) {
2114         MyValue2[] src = new MyValue2[100];
2115         Arrays.fill(src, testValue2);
2116         MyValue2[] dst = new MyValue2[100];
2117         test84(src, dst);
2118         Asserts.assertTrue(Arrays.equals(src, dst));
2119     }
2120 
2121     @Test(valid = G1GCOn, match = { COUNTEDLOOP, LOAD_UNKNOWN_VALUE }, matchCount = { 2, 1 } )
2122     @Test(valid = G1GCOff, match = { COUNTEDLOOP, LOAD_UNKNOWN_VALUE }, matchCount = { 3, 4 } )
2123     public void test85(Object[] src, Object[] dst) {
2124         for (int i = 0; i < src.length; i++) {
2125             dst[i] = src[i];
2126         }
2127     }
2128 
2129     @DontCompile
2130     public void test85_verifier(boolean warmup) {
2131         Object[] src = new Object[100];
2132         Arrays.fill(src, new Object());
2133         src[0] = null;
2134         Object[] dst = new Object[100];
2135         test85(src, dst);
2136         Asserts.assertTrue(Arrays.equals(src, dst));
2137     }
2138 
2139     @Test(valid = G1GCOn, match = { COUNTEDLOOP }, matchCount = { 2 } )
2140     @Test(valid = G1GCOff, match = { COUNTEDLOOP }, matchCount = { 3 } )
2141     public void test86(Object[] src, Object[] dst) {
2142         for (int i = 0; i < src.length; i++) {


2216         try {
2217             test90(new Object());
2218             throw new RuntimeException("ClassCastException expected");
2219         } catch (ClassCastException e) {
2220             // Expected
2221         }
2222     }
2223 
2224     // Same as test89 but bit clearing can not be removed because
2225     // we are comparing to a inline type array klass.
2226     @Test(match = {STORAGE_PROPERTY_CLEARING}, matchCount = { 1 })
2227     public boolean test91(Object obj) {
2228         return obj.getClass() == MyValue2[].class;
2229     }
2230 
2231     @DontCompile
2232     public void test91_verifier(boolean warmup) {
2233         Asserts.assertTrue(test91(new MyValue2[1]));
2234         Asserts.assertFalse(test91(new Object()));
2235     }
2236 
2237     static inline class Test92Value {
2238         final int field;
2239         public Test92Value() {
2240             field = 0x42;
2241         }
2242     }
2243 
2244     @Warmup(10000)
2245     @Test(match = { CLASS_CHECK_TRAP }, matchCount = { 1 }, failOn = LOAD_UNKNOWN_VALUE + ALLOC_G)
2246     public Object test92(Object[] array) {
2247         // Dummy loops to ensure we run enough passes of split if
2248         for (int i = 0; i < 2; i++) {
2249             for (int j = 0; j < 2; j++) {
2250             }
2251         }
2252         
2253         Object v = array[0];
2254         if (v instanceof Integer) {
2255         }
2256         return v;
2257     }
2258 
2259     @DontCompile
2260     public void test92_verifier(boolean warmup) {
2261         Object[] array = new Object[1];
2262         array[0] = 0x42;
2263         Object result = test92(array);
2264         Asserts.assertEquals(result, 0x42);
2265     }
2266 
2267     // If the class check succeeds, the flattened array check that
2268     // precedes will never succeed and the flat array branch should
2269     // trigger an uncommon trap.
2270     @Test
2271     @Warmup(10000)
2272     public Object test93(Object[] array) {
2273         for (int i = 0; i < 2; i++) {
2274             for (int j = 0; j < 2; j++) {
2275             }
2276         }
2277         
2278         Object v = array[0];
2279         if (v instanceof Integer) {
2280         }
2281         return v;
2282     }
2283 
2284     @DontCompile
2285     public void test93_verifier(boolean warmup) {
2286         if (warmup) {
2287             Object[] array = new Object[1];
2288             array[0] = 0x42;
2289             Object result = test93(array);
2290             Asserts.assertEquals(result, 0x42);
2291         } else {
2292             Object[] array = new Test92Value[1];
2293             Method m = tests.get("TestLWorld::test93");
2294             int extra = 2;
2295             for (int j = 0; j < extra; j++) {
2296                 for (int i = 0; i < 10; i++) {
2297                     test93(array);
2298                 }
2299                 boolean compiled = isCompiledByC2(m);
2300                 Asserts.assertTrue(!USE_COMPILER || XCOMP || TEST_C1 || compiled == (j == extra-1));
2301                 if (!compiled) {
2302                     enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION);
2303                 }
2304             }
2305         }
2306     }
2307 
2308     @Warmup(10000)
2309     @Test(match = { CLASS_CHECK_TRAP, LOOP }, matchCount = { 1, 1 }, failOn = LOAD_UNKNOWN_VALUE + ALLOC_G)
2310     public int test94(Object[] array) {
2311         int res = 0;
2312         for (int i = 1; i < 4; i *= 2) {
2313             Object v = array[i];
2314             res += (Integer)v;
2315         }
2316         return res;
2317     }
2318 
2319     @DontCompile
2320     public void test94_verifier(boolean warmup) {
2321         Object[] array = new Object[4];
2322         array[0] = 0x42;
2323         array[1] = 0x42;
2324         array[2] = 0x42;
2325         array[3] = 0x42;
2326         int result = test94(array);
2327         Asserts.assertEquals(result, 0x42 * 2);
2328     }
2329 }
< prev index next >