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 // If the class check succeeds, the flattened array check that 2245 // precedes will never succeed and the flat array branch should 2246 // trigger an uncommon trap. 2247 @Test 2248 @Warmup(10000) 2249 public Object test92(Object[] array) { 2250 Object v = array[0]; 2251 if (v instanceof Integer) { 2252 } 2253 return v; 2254 } 2255 2256 @DontCompile 2257 public void test92_verifier(boolean warmup) { 2258 if (warmup) { 2259 Object[] array = new Object[1]; 2260 array[0] = 0x42; 2261 Object result = test92(array); 2262 Asserts.assertEquals(result, 0x42); 2263 } else { 2264 Object[] array = new Test92Value[1]; 2265 Method m = tests.get("TestLWorld::test92"); 2266 int extra = 2; 2267 for (int j = 0; j < extra; j++) { 2268 for (int i = 0; i < 10; i++) { 2269 test92(array); 2270 } 2271 boolean compiled = isCompiledByC2(m); 2272 Asserts.assertTrue(!USE_COMPILER || XCOMP || compiled == (j == extra-1)); 2273 if (!compiled) { 2274 enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION); 2275 } 2276 } 2277 } 2278 } 2279 } |