comparison test/compiler/types/TypeSpeculation.java @ 18041:52b4284cb496

Merge with jdk8u20-b26
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 16:02:50 +0200
parents 4ca6dc0799b6 45b0159f30f2
children
comparison
equal deleted inserted replaced
17606:45d7b2c7029d 18041:52b4284cb496
23 23
24 /* 24 /*
25 * @test 25 * @test
26 * @bug 8024070 26 * @bug 8024070
27 * @summary Test that type speculation doesn't cause incorrect execution 27 * @summary Test that type speculation doesn't cause incorrect execution
28 * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:TypeProfileLevel=222 TypeSpeculation 28 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation TypeSpeculation
29 * 29 *
30 */ 30 */
31 31
32 public class TypeSpeculation { 32 public class TypeSpeculation {
33 33
396 } 396 }
397 } 397 }
398 return true; 398 return true;
399 } 399 }
400 400
401 // java/lang/Object:AnyNull:exact *,iid=top
402 // meets
403 // stable:bottom[int:max..0]:NotNull *
404 static void test10_4(Object o) {
405 }
406
407 static void test10_3(Object o, boolean b) {
408 if (b) {
409 test10_4(o);
410 }
411 }
412
413 static void test10_2(Object o, boolean b1, boolean b2) {
414 if (b1) {
415 test10_3(o, b2);
416 }
417 }
418
419 static void test10_1(B[] b, boolean b1, boolean b2) {
420 test10_2(b, b1, b2);
421 }
422
423 static boolean test10() {
424 Object o = new Object();
425 A[] a = new A[10];
426 B[] b = new B[10];
427 B[] c = new C[10];
428 for (int i = 0; i < 20000; i++) {
429 test10_1(b, false, false);
430 test10_1(c, false, false);
431 test10_2(a, true, false);
432 test10_3(o, true);
433 }
434 return true;
435 }
436
437 // stable:TypeSpeculation$B:TopPTR *,iid=top[int:max..0]:TopPTR *,iid=top
438 // meets
439 // java/lang/Object:AnyNull:exact *,iid=top
440 static void test11_3(Object o) {
441 }
442
443 static void test11_2(Object o, boolean b) {
444 if (b) {
445 test11_3(o);
446 }
447 }
448
449 static void test11_1(B[] b, boolean bb) {
450 test11_2(b, bb);
451 }
452
453 static boolean test11() {
454 Object o = new Object();
455 B[] b = new B[10];
456 B[] c = new C[10];
457 for (int i = 0; i < 20000; i++) {
458 test11_1(b, false);
459 test11_1(c, false);
460 test11_2(o, true);
461 }
462 return true;
463 }
464
465 // TypeSpeculation$I *
466 // meets
467 // java/lang/Object:AnyNull *,iid=top
468 static void test12_3(Object o) {
469 }
470
471 static void test12_2(Object o, boolean b) {
472 if (b) {
473 test12_3(o);
474 }
475 }
476
477 static void test12_1(I i, boolean b) {
478 test12_2(i, b);
479 }
480
481 static boolean test12() {
482 Object o = new Object();
483 B b = new B();
484 C c = new C();
485 for (int i = 0; i < 20000; i++) {
486 test12_1(b, false);
487 test12_1(c, false);
488 test12_2(o, true);
489 }
490 return true;
491 }
492
493 // stable:bottom[int:max..0]:NotNull *
494 // meets
495 // stable:TypeSpeculation$A:TopPTR *,iid=top[int:max..0]:AnyNull:exact *,iid=top
496 static Object test13_3(Object o, boolean b) {
497 Object oo;
498 if (b) {
499 oo = o;
500 } else {
501 oo = new A[10];
502 }
503 return oo;
504 }
505
506 static void test13_2(Object o, boolean b1, boolean b2) {
507 if (b1) {
508 test13_3(o, b2);
509 }
510 }
511
512 static void test13_1(B[] b, boolean b1, boolean b2) {
513 test13_2(b, b1, b2);
514 }
515
516 static boolean test13() {
517 A[] a = new A[10];
518 B[] b = new B[10];
519 B[] c = new C[10];
520 for (int i = 0; i < 20000; i++) {
521 test13_1(b, false, false);
522 test13_1(c, false, false);
523 test13_2(a, true, (i%2) == 0);
524 }
525 return true;
526 }
527
401 static public void main(String[] args) { 528 static public void main(String[] args) {
402 boolean success = true; 529 boolean success = true;
403 530
404 success = test1() && success; 531 success = test1() && success;
405 532
417 544
418 success = test8() && success; 545 success = test8() && success;
419 546
420 success = test9() && success; 547 success = test9() && success;
421 548
549 success = test10() && success;
550
551 success = test11() && success;
552
553 success = test12() && success;
554
555 success = test13() && success;
556
422 if (success) { 557 if (success) {
423 System.out.println("TEST PASSED"); 558 System.out.println("TEST PASSED");
424 } else { 559 } else {
425 throw new RuntimeException("TEST FAILED: erroneous bound check elimination"); 560 throw new RuntimeException("TEST FAILED: erroneous bound check elimination");
426 } 561 }