|
1 /* |
|
2 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
|
3 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. |
|
4 * |
|
5 * |
|
6 * |
|
7 * |
|
8 * |
|
9 * |
|
10 * |
|
11 * |
|
12 * |
|
13 * |
|
14 * |
|
15 * |
|
16 * |
|
17 * |
|
18 * |
|
19 * |
|
20 * |
|
21 * |
|
22 * |
|
23 */ |
|
24 |
|
25 /* |
|
26 * @test |
|
27 * @bug 6689060 |
|
28 * @summary Escape Analysis does not work with Compressed Oops |
|
29 * @run main/othervm -Xbatch -XX:CompileCommand=exclude,Test.dummy -XX:+AggressiveOpts Test |
|
30 */ |
|
31 |
|
32 import java.lang.reflect.Array; |
|
33 |
|
34 class Point { |
|
35 int x; |
|
36 int y; |
|
37 Point next; |
|
38 int ax[]; |
|
39 int ay[]; |
|
40 Point pax[]; |
|
41 Point pay[]; |
|
42 public Point getNext() { |
|
43 return next; |
|
44 } |
|
45 } |
|
46 |
|
47 public class Test { |
|
48 |
|
49 void dummy() { |
|
50 // Empty method to verify correctness of DebugInfo. |
|
51 // Use -XX:CompileCommand=exclude,Test.dummy |
|
52 } |
|
53 |
|
54 int ival(int i) { |
|
55 return i*2; |
|
56 } |
|
57 |
|
58 int test80(int y, int l, int i) { |
|
59 Point p = new Point(); |
|
60 p.ax = new int[2]; |
|
61 p.ay = new int[2]; |
|
62 int x = 3; |
|
63 p.ax[0] = x; |
|
64 p.ay[1] = 3 * x + y; |
|
65 dummy(); |
|
66 return p.ax[0] * p.ay[1]; |
|
67 } |
|
68 |
|
69 int test81(int y, int l, int i) { |
|
70 Point p = new Point(); |
|
71 p.ax = new int[2]; |
|
72 p.ay = new int[2]; |
|
73 int x = 3; |
|
74 p.ax[0] = x; |
|
75 p.ay[1] = 3 * x + y; |
|
76 dummy(); |
|
77 return p.ax[0] * p.ay[1]; |
|
78 } |
|
79 |
|
80 |
|
81 int test44(int y) { |
|
82 Point p1 = new Point(); |
|
83 p1.x = ival(3); |
|
84 dummy(); |
|
85 p1.y = 3 * p1.x + y; |
|
86 return p1.y; |
|
87 } |
|
88 |
|
89 int test43(int y) { |
|
90 Point p1 = new Point(); |
|
91 if ( (y & 1) == 1 ) { |
|
92 p1.x = ival(3); |
|
93 } else { |
|
94 p1.x = ival(5); |
|
95 } |
|
96 dummy(); |
|
97 p1.y = 3 * p1.x + y; |
|
98 return p1.y; |
|
99 } |
|
100 |
|
101 int test42(int y) { |
|
102 Point p1 = new Point(); |
|
103 p1.x = 3; |
|
104 for (int i = 0; i < y; i++) { |
|
105 if ( (i & 1) == 1 ) { |
|
106 p1.x += 4; |
|
107 } |
|
108 } |
|
109 p1.y = 3 * y + p1.x; |
|
110 return p1.y; |
|
111 } |
|
112 |
|
113 int test40(int y) { |
|
114 Point p1 = new Point(); |
|
115 if ( (y & 1) == 1 ) { |
|
116 p1.x = 3; |
|
117 } else { |
|
118 p1.x = 5; |
|
119 } |
|
120 p1.y = 3 * p1.x + y; |
|
121 return p1.y; |
|
122 } |
|
123 |
|
124 int test41(int y) { |
|
125 Point p1 = new Point(); |
|
126 if ( (y & 1) == 1 ) { |
|
127 p1.x += 4; |
|
128 } else { |
|
129 p1.x += 5; |
|
130 } |
|
131 p1.y = 3 * p1.x + y; |
|
132 return p1.y; |
|
133 } |
|
134 |
|
135 Point test00(int y) { |
|
136 int x = 3; |
|
137 Point p = new Point(); |
|
138 p.x = x; |
|
139 p.y = 3 * x + y; |
|
140 return p; |
|
141 } |
|
142 |
|
143 Point test01(int y) { |
|
144 int x = 3; |
|
145 Point p = new Point(); |
|
146 p.x = x; |
|
147 p.y = 3 * x + y; |
|
148 dummy(); |
|
149 return p; |
|
150 } |
|
151 |
|
152 Point test02(int y) { |
|
153 int x = 3; |
|
154 Point p1 = null; |
|
155 for (int i = 0; i < y; i++) { |
|
156 Point p2 = new Point(); |
|
157 p2.x = x; |
|
158 p2.y = 3 * y + x; |
|
159 p2.next = p1; |
|
160 p1 = p2; |
|
161 } |
|
162 return p1; |
|
163 } |
|
164 |
|
165 Point test03(int y) { |
|
166 int x = 3; |
|
167 Point p1 = null; |
|
168 for (int i = 0; i < y; i++) { |
|
169 Point p2 = new Point(); |
|
170 p2.x = x; |
|
171 p2.y = 3 * y + x; |
|
172 p2.next = p1; |
|
173 p1 = p2; |
|
174 } |
|
175 dummy(); |
|
176 return p1; |
|
177 } |
|
178 |
|
179 Point test04(int y) { |
|
180 int x = 3; |
|
181 Point p1 = null; |
|
182 for (int i = 0; i < y; i++) { |
|
183 Point p2 = new Point(); |
|
184 p2.x = x; |
|
185 p2.y = 3 * y + x; |
|
186 p2.next = p1; |
|
187 dummy(); |
|
188 p1 = p2; |
|
189 } |
|
190 return p1; |
|
191 } |
|
192 |
|
193 int test05(int y) { |
|
194 int x = 3; |
|
195 Point p1 = new Point(); |
|
196 for (int i = 0; i < y; i++) { |
|
197 Point p2 = new Point(); |
|
198 p2.x = x; |
|
199 p2.y = 3 * y + x; |
|
200 p1.next = p2; |
|
201 p1 = p2; |
|
202 } |
|
203 return p1.y; |
|
204 } |
|
205 |
|
206 int test0(int y) { |
|
207 int x = 3; |
|
208 Point p = new Point(); |
|
209 p.x = x; |
|
210 p.y = 3 * x + y; |
|
211 dummy(); |
|
212 return p.x * p.y; |
|
213 } |
|
214 |
|
215 int test1(int y) { |
|
216 Point p = new Point(); |
|
217 if ( (y & 1) == 1 ) { |
|
218 p = new Point(); // Kill previous |
|
219 } |
|
220 int x = 3; |
|
221 p.x = x; |
|
222 p.y = 3 * x + y; |
|
223 dummy(); |
|
224 return p.x * p.y; |
|
225 } |
|
226 |
|
227 int test2(int y) { |
|
228 Point p1 = new Point(); |
|
229 Point p2 = new Point(); |
|
230 p1.x = 3; |
|
231 p2.x = 4; |
|
232 p1.y = 3 * p2.x + y; |
|
233 p2.y = 3 * p1.x + y; |
|
234 dummy(); |
|
235 return p1.y * p2.y; |
|
236 } |
|
237 |
|
238 int test3(int y, Point p1) { |
|
239 Point p2 = new Point(); |
|
240 p1.x = 3; |
|
241 p2.x = 4; |
|
242 p1.y = 3 * p2.x + y; |
|
243 p2.y = 3 * p1.x + y; |
|
244 dummy(); |
|
245 return p1.y * p2.y; |
|
246 } |
|
247 |
|
248 int test4(int y) { |
|
249 Point p1 = new Point(); |
|
250 Point p2 = new Point(); |
|
251 if ( (y & 1) == 1 ) { |
|
252 p1.x = 3; |
|
253 p2.x = 4; |
|
254 } else { |
|
255 p1.x = 5; |
|
256 p2.x = 6; |
|
257 } |
|
258 p1.y = 3 * p2.x + y; |
|
259 p2.y = 3 * p1.x + y; |
|
260 dummy(); |
|
261 return p1.y * p2.y; |
|
262 } |
|
263 |
|
264 int test5(int y, Point p1) { |
|
265 Point p2 = new Point(); |
|
266 if ( (y & 1) == 1 ) { |
|
267 p1.x = 3; |
|
268 p2.x = 4; |
|
269 } else { |
|
270 p1.x = 5; |
|
271 p2.x = 6; |
|
272 } |
|
273 p1.y = 3 * p2.x + y; |
|
274 p2.y = 3 * p1.x + y; |
|
275 dummy(); |
|
276 return p1.y * p2.y; |
|
277 } |
|
278 |
|
279 int test6(int y) { |
|
280 Point p1 = new Point(); |
|
281 Point p2 = new Point(); |
|
282 p1.next = p2; |
|
283 if ( (y & 1) == 1 ) { |
|
284 p1.x = 3; |
|
285 p1.getNext().x = 4; |
|
286 } else { |
|
287 p1.x = 5; |
|
288 p1.getNext().x = 6; |
|
289 } |
|
290 p1.y = 3 * p2.x + y; |
|
291 p2.y = 3 * p1.x + y; |
|
292 dummy(); |
|
293 return p1.y * p2.y; |
|
294 } |
|
295 |
|
296 int test7(int y, Point p1) { |
|
297 Point p2 = new Point(); |
|
298 p1.next = p2; |
|
299 if ( (y & 1) == 1 ) { |
|
300 p1.x = 3; |
|
301 p1.getNext().x = 4; |
|
302 } else { |
|
303 p1.x = 5; |
|
304 p1.getNext().x = 6; |
|
305 } |
|
306 p1.y = 3 * p2.x + y; |
|
307 p2.y = 3 * p1.x + y; |
|
308 dummy(); |
|
309 return p1.y * p2.y; |
|
310 } |
|
311 |
|
312 int test8(int y, int l, int i) { |
|
313 Point p = new Point(); |
|
314 p.ax = new int[l]; |
|
315 p.ay = new int[l]; |
|
316 int x = 3; |
|
317 p.ax[i] = x; |
|
318 p.ay[i] = 3 * x + y; |
|
319 dummy(); |
|
320 return p.ax[i] * p.ay[i]; |
|
321 } |
|
322 |
|
323 int test9(int y, int l, int i) { |
|
324 Point p = new Point(); |
|
325 p.pax = new Point[l]; |
|
326 p.pay = new Point[l]; |
|
327 p.pax[i] = new Point(); |
|
328 p.pay[i] = new Point(); |
|
329 p.pax[i].x = 3; |
|
330 p.pay[i].x = 4; |
|
331 p.pax[i].y = 3 * p.pay[i].x + y; |
|
332 p.pay[i].y = 3 * p.pax[i].x + y; |
|
333 dummy(); |
|
334 return p.pax[i].y * p.pay[i].y; |
|
335 } |
|
336 |
|
337 int test10(int y, int l, int i, Class cls) { |
|
338 Point p = new Point(); |
|
339 try { |
|
340 p.pax = (Point[])Array.newInstance(cls, l); |
|
341 p.pax[i] = (Point)cls.newInstance(); |
|
342 } |
|
343 catch(java.lang.InstantiationException ex) { |
|
344 return 0; |
|
345 } |
|
346 catch(java.lang.IllegalAccessException ex) { |
|
347 return 0; |
|
348 } |
|
349 p.pax[i].x = 3; |
|
350 p.pax[i].y = 3 * p.pax[i].x + y; |
|
351 dummy(); |
|
352 return p.pax[i].x * p.pax[i].y; |
|
353 } |
|
354 |
|
355 int test11(int y) { |
|
356 Point p1 = new Point(); |
|
357 Point p2 = new Point(); |
|
358 p1.next = p2; |
|
359 if ( (y & 1) == 1 ) { |
|
360 p1.x = 3; |
|
361 p1.next.x = 4; |
|
362 } else { |
|
363 p1.x = 5; |
|
364 p1.next.x = 6; |
|
365 } |
|
366 p1.y = 3 * p1.next.x + y; |
|
367 p1.next.y = 3 * p1.x + y; |
|
368 dummy(); |
|
369 return p1.y * p1.next.y; |
|
370 } |
|
371 |
|
372 int test12(int y) { |
|
373 Point p1 = new Point(); |
|
374 p1.next = p1; |
|
375 if ( (y & 1) == 1 ) { |
|
376 p1.x = 3; |
|
377 p1.next.x = 4; |
|
378 } else { |
|
379 p1.x = 5; |
|
380 p1.next.x = 6; |
|
381 } |
|
382 p1.y = 3 * p1.next.x + y; |
|
383 p1.next.y = 3 * p1.x + y; |
|
384 dummy(); |
|
385 return p1.y * p1.next.y; |
|
386 } |
|
387 |
|
388 |
|
389 public static void main(String args[]) { |
|
390 Test tsr = new Test(); |
|
391 Point p = new Point(); |
|
392 Point ptmp = p; |
|
393 Class cls = Point.class; |
|
394 int y = 0; |
|
395 for (int i=0; i<10000; i++) { |
|
396 ptmp.next = tsr.test00(1); |
|
397 ptmp.next = tsr.test01(1); |
|
398 ptmp.next = tsr.test02(1); |
|
399 ptmp.next = tsr.test03(1); |
|
400 ptmp.next = tsr.test04(1); |
|
401 |
|
402 y = tsr.test05(1); |
|
403 |
|
404 y = tsr.test80(y, 1, 0); |
|
405 y = tsr.test81(y, 1, 0); |
|
406 |
|
407 y = tsr.test44(y); |
|
408 y = tsr.test43(y); |
|
409 y = tsr.test42(y); |
|
410 y = tsr.test40(y); |
|
411 y = tsr.test41(y); |
|
412 |
|
413 y = tsr.test0(y); |
|
414 y = tsr.test1(y); |
|
415 y = tsr.test2(y); |
|
416 y = tsr.test3(y, p); |
|
417 y = tsr.test4(y); |
|
418 y = tsr.test5(y, p); |
|
419 y = tsr.test6(y); |
|
420 y = tsr.test7(y, p); |
|
421 y = tsr.test8(y, 1, 0); |
|
422 y = tsr.test9(y, 1, 0); |
|
423 y = tsr.test10(y, 1, 0, cls); |
|
424 y = tsr.test11(y); |
|
425 y = tsr.test12(y); |
|
426 } |
|
427 for (int i=0; i<10000; i++) { |
|
428 ptmp.next = tsr.test00(1); |
|
429 ptmp.next = tsr.test01(1); |
|
430 ptmp.next = tsr.test02(1); |
|
431 ptmp.next = tsr.test03(1); |
|
432 ptmp.next = tsr.test04(1); |
|
433 |
|
434 y = tsr.test05(1); |
|
435 |
|
436 y = tsr.test80(y, 1, 0); |
|
437 y = tsr.test81(y, 1, 0); |
|
438 |
|
439 y = tsr.test44(y); |
|
440 y = tsr.test43(y); |
|
441 y = tsr.test42(y); |
|
442 y = tsr.test40(y); |
|
443 y = tsr.test41(y); |
|
444 |
|
445 y = tsr.test0(y); |
|
446 y = tsr.test1(y); |
|
447 y = tsr.test2(y); |
|
448 y = tsr.test3(y, p); |
|
449 y = tsr.test4(y); |
|
450 y = tsr.test5(y, p); |
|
451 y = tsr.test6(y); |
|
452 y = tsr.test7(y, p); |
|
453 y = tsr.test8(y, 1, 0); |
|
454 y = tsr.test9(y, 1, 0); |
|
455 y = tsr.test10(y, 1, 0, cls); |
|
456 y = tsr.test11(y); |
|
457 y = tsr.test12(y); |
|
458 } |
|
459 for (int i=0; i<10000; i++) { |
|
460 ptmp.next = tsr.test00(1); |
|
461 ptmp.next = tsr.test01(1); |
|
462 ptmp.next = tsr.test02(1); |
|
463 ptmp.next = tsr.test03(1); |
|
464 ptmp.next = tsr.test04(1); |
|
465 |
|
466 y = tsr.test05(1); |
|
467 |
|
468 y = tsr.test80(y, 1, 0); |
|
469 y = tsr.test81(y, 1, 0); |
|
470 |
|
471 y = tsr.test44(y); |
|
472 y = tsr.test43(y); |
|
473 y = tsr.test42(y); |
|
474 y = tsr.test40(y); |
|
475 y = tsr.test41(y); |
|
476 |
|
477 y = tsr.test0(y); |
|
478 y = tsr.test1(y); |
|
479 y = tsr.test2(y); |
|
480 y = tsr.test3(y, p); |
|
481 y = tsr.test4(y); |
|
482 y = tsr.test5(y, p); |
|
483 y = tsr.test6(y); |
|
484 y = tsr.test7(y, p); |
|
485 y = tsr.test8(y, 1, 0); |
|
486 y = tsr.test9(y, 1, 0); |
|
487 y = tsr.test10(y, 1, 0, cls); |
|
488 y = tsr.test11(y); |
|
489 y = tsr.test12(y); |
|
490 } |
|
491 |
|
492 int z = 0; |
|
493 y = tsr.test80(0, 1, 0); |
|
494 z += y; |
|
495 System.out.println("After 'test80' y=" + y); |
|
496 y = tsr.test81(0, 1, 0); |
|
497 z += y; |
|
498 System.out.println("After 'test81' y=" + y); |
|
499 |
|
500 y = tsr.test44(0); |
|
501 z += y; |
|
502 System.out.println("After 'test44' y=" + y); |
|
503 y = tsr.test43(0); |
|
504 z += y; |
|
505 System.out.println("After 'test43' y=" + y); |
|
506 y = tsr.test42(0); |
|
507 z += y; |
|
508 System.out.println("After 'test42' y=" + y); |
|
509 y = tsr.test40(0); |
|
510 z += y; |
|
511 System.out.println("After 'test40' y=" + y); |
|
512 y = tsr.test41(0); |
|
513 z += y; |
|
514 System.out.println("After 'test41' y=" + y); |
|
515 |
|
516 ptmp.next = tsr.test00(1); |
|
517 z += y; |
|
518 System.out.println("After 'test00' p.y=" + ptmp.next.y); |
|
519 ptmp.next = tsr.test01(1); |
|
520 z += y; |
|
521 System.out.println("After 'test01' p.y=" + ptmp.next.y); |
|
522 ptmp.next = tsr.test02(1); |
|
523 z += y; |
|
524 System.out.println("After 'test02' p.y=" + ptmp.next.y); |
|
525 ptmp.next = tsr.test03(1); |
|
526 z += y; |
|
527 System.out.println("After 'test03' p.y=" + ptmp.next.y); |
|
528 ptmp.next = tsr.test04(1); |
|
529 z += y; |
|
530 System.out.println("After 'test04' p.y=" + ptmp.next.y); |
|
531 |
|
532 y = tsr.test05(1); |
|
533 z += y; |
|
534 System.out.println("After 'test05' y=" + y); |
|
535 |
|
536 y = tsr.test0(0); |
|
537 z += y; |
|
538 System.out.println("After 'test0' y=" + y); |
|
539 y = tsr.test1(0); |
|
540 z += y; |
|
541 System.out.println("After 'test1' y=" + y); |
|
542 y = tsr.test2(0); |
|
543 z += y; |
|
544 System.out.println("After 'test2' y=" + y); |
|
545 y = tsr.test3(0, new Point()); |
|
546 z += y; |
|
547 System.out.println("After 'test3' y=" + y); |
|
548 y = tsr.test4(0); |
|
549 z += y; |
|
550 System.out.println("After 'test4' y=" + y); |
|
551 y = tsr.test5(0, new Point()); |
|
552 z += y; |
|
553 System.out.println("After 'test5' y=" + y); |
|
554 y = tsr.test6(0); |
|
555 z += y; |
|
556 System.out.println("After 'test6' y=" + y); |
|
557 y = tsr.test7(0, new Point()); |
|
558 z += y; |
|
559 System.out.println("After 'test7' y=" + y); |
|
560 y = tsr.test8(0, 1, 0); |
|
561 z += y; |
|
562 System.out.println("After 'test8' y=" + y); |
|
563 y = tsr.test9(0, 1, 0); |
|
564 z += y; |
|
565 System.out.println("After 'test9' y=" + y); |
|
566 y = tsr.test10(0, 1, 0, cls); |
|
567 z += y; |
|
568 System.out.println("After 'test10' y=" + y); |
|
569 y = tsr.test11(0); |
|
570 z += y; |
|
571 System.out.println("After 'test11' y=" + y); |
|
572 y = tsr.test12(0); |
|
573 z += y; |
|
574 System.out.println("After 'test12' y=" + y); |
|
575 System.out.println("Sum of y =" + z); |
|
576 } |
|
577 } |