author | iignatyev |
Mon, 18 Feb 2019 09:31:07 -0800 | |
changeset 53791 | bec6c8739833 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
21099 | 1 |
/* |
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* @test |
|
26 |
* @bug 8024070 |
|
27 |
* @summary Test that type speculation doesn't cause incorrect execution |
|
28 |
* |
|
40059 | 29 |
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseOnStackReplacement |
30 |
* -XX:-BackgroundCompilation -XX:TypeProfileLevel=222 |
|
31 |
* -XX:+UseTypeSpeculation |
|
32 |
* compiler.types.TypeSpeculation |
|
21099 | 33 |
*/ |
34 |
||
40059 | 35 |
package compiler.types; |
36 |
||
21099 | 37 |
public class TypeSpeculation { |
38 |
||
39 |
interface I { |
|
40 |
} |
|
41 |
||
42 |
static class A { |
|
43 |
int m() { |
|
44 |
return 1; |
|
45 |
} |
|
46 |
} |
|
47 |
||
48 |
static class B extends A implements I { |
|
49 |
int m() { |
|
50 |
return 2; |
|
51 |
} |
|
52 |
} |
|
53 |
||
54 |
static class C extends B { |
|
55 |
int m() { |
|
56 |
return 3; |
|
57 |
} |
|
58 |
} |
|
59 |
||
60 |
static int test1_invokevirtual(A a) { |
|
61 |
return a.m(); |
|
62 |
} |
|
63 |
||
64 |
static int test1_1(A a) { |
|
65 |
return test1_invokevirtual(a); |
|
66 |
} |
|
67 |
||
68 |
static boolean test1() { |
|
69 |
A a = new A(); |
|
70 |
B b = new B(); |
|
71 |
C c = new C(); |
|
72 |
||
73 |
// pollute profile at test1_invokevirtual to make sure the |
|
74 |
// compiler cannot rely on it |
|
75 |
for (int i = 0; i < 5000; i++) { |
|
76 |
test1_invokevirtual(a); |
|
77 |
test1_invokevirtual(b); |
|
78 |
test1_invokevirtual(c); |
|
79 |
} |
|
80 |
||
81 |
// profiling + speculation should make test1_invokevirtual |
|
82 |
// inline A.m() with a guard |
|
83 |
for (int i = 0; i < 20000; i++) { |
|
84 |
int res = test1_1(b); |
|
85 |
if (res != b.m()) { |
|
86 |
System.out.println("test1 failed with class B"); |
|
87 |
return false; |
|
88 |
} |
|
89 |
} |
|
90 |
// check that the guard works as expected by passing a |
|
91 |
// different type |
|
92 |
int res = test1_1(a); |
|
93 |
if (res != a.m()) { |
|
94 |
System.out.println("test1 failed with class A"); |
|
95 |
return false; |
|
96 |
} |
|
97 |
return true; |
|
98 |
} |
|
99 |
||
100 |
static int test2_invokevirtual(A a) { |
|
101 |
return a.m(); |
|
102 |
} |
|
103 |
||
104 |
static int test2_1(A a, boolean t) { |
|
105 |
A aa; |
|
106 |
if (t) { |
|
107 |
aa = (B)a; |
|
108 |
} else { |
|
109 |
aa = a; |
|
110 |
} |
|
111 |
// if a of type B is passed to test2_1, the static type of aa |
|
112 |
// here is no better than A but the profiled type is B so this |
|
113 |
// should inline |
|
114 |
return test2_invokevirtual(aa); |
|
115 |
} |
|
116 |
||
117 |
static boolean test2() { |
|
118 |
A a = new A(); |
|
119 |
B b = new B(); |
|
120 |
C c = new C(); |
|
121 |
||
122 |
// pollute profile at test2_invokevirtual to make sure the |
|
123 |
// compiler cannot rely on it |
|
124 |
for (int i = 0; i < 5000; i++) { |
|
125 |
test2_invokevirtual(a); |
|
126 |
test2_invokevirtual(b); |
|
127 |
test2_invokevirtual(c); |
|
128 |
} |
|
129 |
||
130 |
// profiling + speculation should make test2_invokevirtual |
|
131 |
// inline A.m() with a guard |
|
132 |
for (int i = 0; i < 20000; i++) { |
|
133 |
int res = test2_1(b, (i % 2) == 0); |
|
134 |
if (res != b.m()) { |
|
135 |
System.out.println("test2 failed with class B"); |
|
136 |
return false; |
|
137 |
} |
|
138 |
} |
|
139 |
// check that the guard works as expected by passing a |
|
140 |
// different type |
|
141 |
int res = test2_1(a, false); |
|
142 |
if (res != a.m()) { |
|
143 |
System.out.println("test2 failed with class A"); |
|
144 |
return false; |
|
145 |
} |
|
146 |
return true; |
|
147 |
} |
|
148 |
||
149 |
static int test3_invokevirtual(A a) { |
|
150 |
return a.m(); |
|
151 |
} |
|
152 |
||
153 |
static void test3_2(A a) { |
|
154 |
} |
|
155 |
||
156 |
static int test3_1(A a, int i) { |
|
157 |
if (i == 0) { |
|
158 |
return 0; |
|
159 |
} |
|
160 |
// If we come here and a is of type B but parameter profiling |
|
161 |
// is polluted, both branches of the if below should have |
|
162 |
// profiling that tell us and inlining of the virtual call |
|
163 |
// should happen |
|
164 |
if (i == 1) { |
|
165 |
test3_2(a); |
|
166 |
} else { |
|
167 |
test3_2(a); |
|
168 |
} |
|
169 |
return test3_invokevirtual(a); |
|
170 |
} |
|
171 |
||
172 |
static boolean test3() { |
|
173 |
A a = new A(); |
|
174 |
B b = new B(); |
|
175 |
C c = new C(); |
|
176 |
||
177 |
// pollute profile at test3_invokevirtual and test3_1 to make |
|
178 |
// sure the compiler cannot rely on it |
|
179 |
for (int i = 0; i < 3000; i++) { |
|
180 |
test3_invokevirtual(a); |
|
181 |
test3_invokevirtual(b); |
|
182 |
test3_invokevirtual(c); |
|
183 |
test3_1(a, 0); |
|
184 |
test3_1(b, 0); |
|
185 |
} |
|
186 |
||
187 |
// profiling + speculation should make test3_invokevirtual |
|
188 |
// inline A.m() with a guard |
|
189 |
for (int i = 0; i < 20000; i++) { |
|
190 |
int res = test3_1(b, (i % 2) + 1); |
|
191 |
if (res != b.m()) { |
|
192 |
System.out.println("test3 failed with class B"); |
|
193 |
return false; |
|
194 |
} |
|
195 |
} |
|
196 |
// check that the guard works as expected by passing a |
|
197 |
// different type |
|
198 |
int res = test3_1(a, 1); |
|
199 |
if (res != a.m()) { |
|
200 |
System.out.println("test3 failed with class A"); |
|
201 |
return false; |
|
202 |
} |
|
203 |
return true; |
|
204 |
} |
|
205 |
||
206 |
// Mix 2 incompatible profiled types |
|
207 |
static int test4_invokevirtual(A a) { |
|
208 |
return a.m(); |
|
209 |
} |
|
210 |
||
211 |
static void test4_2(A a) { |
|
212 |
} |
|
213 |
||
214 |
static int test4_1(A a, boolean b) { |
|
215 |
if (b) { |
|
216 |
test4_2(a); |
|
217 |
} else { |
|
218 |
test4_2(a); |
|
219 |
} |
|
220 |
// shouldn't inline |
|
221 |
return test4_invokevirtual(a); |
|
222 |
} |
|
223 |
||
224 |
static boolean test4() { |
|
225 |
A a = new A(); |
|
226 |
B b = new B(); |
|
227 |
C c = new C(); |
|
228 |
||
229 |
// pollute profile at test3_invokevirtual and test3_1 to make |
|
230 |
// sure the compiler cannot rely on it |
|
231 |
for (int i = 0; i < 3000; i++) { |
|
232 |
test4_invokevirtual(a); |
|
233 |
test4_invokevirtual(b); |
|
234 |
test4_invokevirtual(c); |
|
235 |
} |
|
236 |
||
237 |
for (int i = 0; i < 20000; i++) { |
|
238 |
if ((i % 2) == 0) { |
|
239 |
int res = test4_1(a, true); |
|
240 |
if (res != a.m()) { |
|
241 |
System.out.println("test4 failed with class A"); |
|
242 |
return false; |
|
243 |
} |
|
244 |
} else { |
|
245 |
int res = test4_1(b, false); |
|
246 |
if (res != b.m()) { |
|
247 |
System.out.println("test4 failed with class B"); |
|
248 |
return false; |
|
249 |
} |
|
250 |
} |
|
251 |
} |
|
252 |
return true; |
|
253 |
} |
|
254 |
||
255 |
// Mix one profiled type with an incompatible type |
|
256 |
static int test5_invokevirtual(A a) { |
|
257 |
return a.m(); |
|
258 |
} |
|
259 |
||
260 |
static void test5_2(A a) { |
|
261 |
} |
|
262 |
||
263 |
static int test5_1(A a, boolean b) { |
|
264 |
if (b) { |
|
265 |
test5_2(a); |
|
266 |
} else { |
|
267 |
A aa = (B)a; |
|
268 |
} |
|
269 |
// shouldn't inline |
|
270 |
return test5_invokevirtual(a); |
|
271 |
} |
|
272 |
||
273 |
static boolean test5() { |
|
274 |
A a = new A(); |
|
275 |
B b = new B(); |
|
276 |
C c = new C(); |
|
277 |
||
278 |
// pollute profile at test3_invokevirtual and test3_1 to make |
|
279 |
// sure the compiler cannot rely on it |
|
280 |
for (int i = 0; i < 3000; i++) { |
|
281 |
test5_invokevirtual(a); |
|
282 |
test5_invokevirtual(b); |
|
283 |
test5_invokevirtual(c); |
|
284 |
} |
|
285 |
||
286 |
for (int i = 0; i < 20000; i++) { |
|
287 |
if ((i % 2) == 0) { |
|
288 |
int res = test5_1(a, true); |
|
289 |
if (res != a.m()) { |
|
290 |
System.out.println("test5 failed with class A"); |
|
291 |
return false; |
|
292 |
} |
|
293 |
} else { |
|
294 |
int res = test5_1(b, false); |
|
295 |
if (res != b.m()) { |
|
296 |
System.out.println("test5 failed with class B"); |
|
297 |
return false; |
|
298 |
} |
|
299 |
} |
|
300 |
} |
|
301 |
return true; |
|
302 |
} |
|
303 |
||
304 |
// Mix incompatible profiled types |
|
305 |
static void test6_2(Object o) { |
|
306 |
} |
|
307 |
||
308 |
static Object test6_1(Object o, boolean b) { |
|
309 |
if (b) { |
|
310 |
test6_2(o); |
|
311 |
} else { |
|
312 |
test6_2(o); |
|
313 |
} |
|
314 |
return o; |
|
315 |
} |
|
316 |
||
317 |
static boolean test6() { |
|
318 |
A a = new A(); |
|
319 |
A[] aa = new A[10]; |
|
320 |
||
321 |
for (int i = 0; i < 20000; i++) { |
|
322 |
if ((i % 2) == 0) { |
|
323 |
test6_1(a, true); |
|
324 |
} else { |
|
325 |
test6_1(aa, false); |
|
326 |
} |
|
327 |
} |
|
328 |
return true; |
|
329 |
} |
|
330 |
||
331 |
// Mix a profiled type with an incompatible type |
|
332 |
static void test7_2(Object o) { |
|
333 |
} |
|
334 |
||
335 |
static Object test7_1(Object o, boolean b) { |
|
336 |
if (b) { |
|
337 |
test7_2(o); |
|
338 |
} else { |
|
339 |
Object oo = (A[])o; |
|
340 |
} |
|
341 |
return o; |
|
342 |
} |
|
343 |
||
344 |
static boolean test7() { |
|
345 |
A a = new A(); |
|
346 |
A[] aa = new A[10]; |
|
347 |
||
348 |
for (int i = 0; i < 20000; i++) { |
|
349 |
if ((i % 2) == 0) { |
|
350 |
test7_1(a, true); |
|
351 |
} else { |
|
352 |
test7_1(aa, false); |
|
353 |
} |
|
354 |
} |
|
355 |
return true; |
|
356 |
} |
|
357 |
||
358 |
// Mix a profiled type with an interface |
|
359 |
static void test8_2(Object o) { |
|
360 |
} |
|
361 |
||
362 |
static I test8_1(Object o) { |
|
363 |
test8_2(o); |
|
364 |
return (I)o; |
|
365 |
} |
|
366 |
||
367 |
static boolean test8() { |
|
368 |
A a = new A(); |
|
369 |
B b = new B(); |
|
370 |
C c = new C(); |
|
371 |
||
372 |
for (int i = 0; i < 20000; i++) { |
|
373 |
test8_1(b); |
|
374 |
} |
|
375 |
return true; |
|
376 |
} |
|
377 |
||
378 |
// Mix a profiled type with a constant |
|
379 |
static void test9_2(Object o) { |
|
380 |
} |
|
381 |
||
382 |
static Object test9_1(Object o, boolean b) { |
|
383 |
Object oo; |
|
384 |
if (b) { |
|
385 |
test9_2(o); |
|
386 |
oo = o; |
|
387 |
} else { |
|
388 |
oo = "some string"; |
|
389 |
} |
|
390 |
return oo; |
|
391 |
} |
|
392 |
||
393 |
static boolean test9() { |
|
394 |
A a = new A(); |
|
395 |
||
396 |
for (int i = 0; i < 20000; i++) { |
|
397 |
if ((i % 2) == 0) { |
|
398 |
test9_1(a, true); |
|
399 |
} else { |
|
400 |
test9_1(a, false); |
|
401 |
} |
|
402 |
} |
|
403 |
return true; |
|
404 |
} |
|
405 |
||
22237
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
406 |
// java/lang/Object:AnyNull:exact *,iid=top |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
407 |
// meets |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
408 |
// stable:bottom[int:max..0]:NotNull * |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
409 |
static void test10_4(Object o) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
410 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
411 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
412 |
static void test10_3(Object o, boolean b) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
413 |
if (b) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
414 |
test10_4(o); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
415 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
416 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
417 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
418 |
static void test10_2(Object o, boolean b1, boolean b2) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
419 |
if (b1) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
420 |
test10_3(o, b2); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
421 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
422 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
423 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
424 |
static void test10_1(B[] b, boolean b1, boolean b2) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
425 |
test10_2(b, b1, b2); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
426 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
427 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
428 |
static boolean test10() { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
429 |
Object o = new Object(); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
430 |
A[] a = new A[10]; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
431 |
B[] b = new B[10]; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
432 |
B[] c = new C[10]; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
433 |
for (int i = 0; i < 20000; i++) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
434 |
test10_1(b, false, false); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
435 |
test10_1(c, false, false); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
436 |
test10_2(a, true, false); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
437 |
test10_3(o, true); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
438 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
439 |
return true; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
440 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
441 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
442 |
// stable:TypeSpeculation$B:TopPTR *,iid=top[int:max..0]:TopPTR *,iid=top |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
443 |
// meets |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
444 |
// java/lang/Object:AnyNull:exact *,iid=top |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
445 |
static void test11_3(Object o) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
446 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
447 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
448 |
static void test11_2(Object o, boolean b) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
449 |
if (b) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
450 |
test11_3(o); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
451 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
452 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
453 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
454 |
static void test11_1(B[] b, boolean bb) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
455 |
test11_2(b, bb); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
456 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
457 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
458 |
static boolean test11() { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
459 |
Object o = new Object(); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
460 |
B[] b = new B[10]; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
461 |
B[] c = new C[10]; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
462 |
for (int i = 0; i < 20000; i++) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
463 |
test11_1(b, false); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
464 |
test11_1(c, false); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
465 |
test11_2(o, true); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
466 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
467 |
return true; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
468 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
469 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
470 |
// TypeSpeculation$I * |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
471 |
// meets |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
472 |
// java/lang/Object:AnyNull *,iid=top |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
473 |
static void test12_3(Object o) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
474 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
475 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
476 |
static void test12_2(Object o, boolean b) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
477 |
if (b) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
478 |
test12_3(o); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
479 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
480 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
481 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
482 |
static void test12_1(I i, boolean b) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
483 |
test12_2(i, b); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
484 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
485 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
486 |
static boolean test12() { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
487 |
Object o = new Object(); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
488 |
B b = new B(); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
489 |
C c = new C(); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
490 |
for (int i = 0; i < 20000; i++) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
491 |
test12_1(b, false); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
492 |
test12_1(c, false); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
493 |
test12_2(o, true); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
494 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
495 |
return true; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
496 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
497 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
498 |
// stable:bottom[int:max..0]:NotNull * |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
499 |
// meets |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
500 |
// stable:TypeSpeculation$A:TopPTR *,iid=top[int:max..0]:AnyNull:exact *,iid=top |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
501 |
static Object test13_3(Object o, boolean b) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
502 |
Object oo; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
503 |
if (b) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
504 |
oo = o; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
505 |
} else { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
506 |
oo = new A[10]; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
507 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
508 |
return oo; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
509 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
510 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
511 |
static void test13_2(Object o, boolean b1, boolean b2) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
512 |
if (b1) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
513 |
test13_3(o, b2); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
514 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
515 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
516 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
517 |
static void test13_1(B[] b, boolean b1, boolean b2) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
518 |
test13_2(b, b1, b2); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
519 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
520 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
521 |
static boolean test13() { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
522 |
A[] a = new A[10]; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
523 |
B[] b = new B[10]; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
524 |
B[] c = new C[10]; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
525 |
for (int i = 0; i < 20000; i++) { |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
526 |
test13_1(b, false, false); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
527 |
test13_1(c, false, false); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
528 |
test13_2(a, true, (i%2) == 0); |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
529 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
530 |
return true; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
531 |
} |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
532 |
|
21099 | 533 |
static public void main(String[] args) { |
534 |
boolean success = true; |
|
535 |
||
536 |
success = test1() && success; |
|
537 |
||
538 |
success = test2() && success; |
|
539 |
||
540 |
success = test3() && success; |
|
541 |
||
542 |
success = test4() && success; |
|
543 |
||
544 |
success = test5() && success; |
|
545 |
||
546 |
success = test6() && success; |
|
547 |
||
548 |
success = test7() && success; |
|
549 |
||
550 |
success = test8() && success; |
|
551 |
||
552 |
success = test9() && success; |
|
553 |
||
22237
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
554 |
success = test10() && success; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
555 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
556 |
success = test11() && success; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
557 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
558 |
success = test12() && success; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
559 |
|
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
560 |
success = test13() && success; |
e9d7daf0d91b
8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents:
21099
diff
changeset
|
561 |
|
21099 | 562 |
if (success) { |
563 |
System.out.println("TEST PASSED"); |
|
564 |
} else { |
|
565 |
throw new RuntimeException("TEST FAILED: erroneous bound check elimination"); |
|
566 |
} |
|
567 |
} |
|
568 |
} |