Mercurial > hg > truffle
comparison test/compiler/whitebox/CompilerWhiteBoxTest.java @ 20605:564d97997064
8060454: [TESTBUG] Whitebox tests fail with -XX:CompileThreshold=100
Summary: Move the call to 'waitAndDeoptimize' from the warmup methods to the osr triggering methods to make sure that no non-osr compilation is in the queue after warmup.
Reviewed-by: kvn
author | thartmann |
---|---|
date | Fri, 17 Oct 2014 10:04:45 +0200 |
parents | c88a4554854c |
children | d1e732bbe4e5 |
comparison
equal
deleted
inserted
replaced
20604:c88a4554854c | 20605:564d97997064 |
---|---|
539 * compilation finished. | 539 * compilation finished. |
540 * | 540 * |
541 * @param e Executable | 541 * @param e Executable |
542 * @throws Exception | 542 * @throws Exception |
543 */ | 543 */ |
544 private static void waitAndDeoptimize(Executable e) throws Exception { | 544 private static void waitAndDeoptimize(Executable e) { |
545 CompilerWhiteBoxTest.waitBackgroundCompilation(e); | 545 CompilerWhiteBoxTest.waitBackgroundCompilation(e); |
546 if (WhiteBox.getWhiteBox().isMethodQueuedForCompilation(e)) { | 546 if (WhiteBox.getWhiteBox().isMethodQueuedForCompilation(e)) { |
547 throw new RuntimeException(e + " must not be in queue"); | 547 throw new RuntimeException(e + " must not be in queue"); |
548 } | 548 } |
549 // Deoptimize non-osr versions of executable | 549 // Deoptimize non-osr versions of executable |
563 Helper helper = new Helper(); | 563 Helper helper = new Helper(); |
564 int result = 0; | 564 int result = 0; |
565 for (long i = 0; i < CompilerWhiteBoxTest.OSR_WARMUP; ++i) { | 565 for (long i = 0; i < CompilerWhiteBoxTest.OSR_WARMUP; ++i) { |
566 result += (int)m.invoke(helper, 1); | 566 result += (int)m.invoke(helper, 1); |
567 } | 567 } |
568 // Deoptimize non-osr versions | |
569 waitAndDeoptimize(m); | |
570 return result; | 568 return result; |
571 } | 569 } |
572 | 570 |
573 /** | 571 /** |
574 * Executes the constructor multiple times to make sure we | 572 * Executes the constructor multiple times to make sure we |
582 private static int warmup(Constructor c) throws Exception { | 580 private static int warmup(Constructor c) throws Exception { |
583 int result = 0; | 581 int result = 0; |
584 for (long i = 0; i < CompilerWhiteBoxTest.OSR_WARMUP; ++i) { | 582 for (long i = 0; i < CompilerWhiteBoxTest.OSR_WARMUP; ++i) { |
585 result += c.newInstance(null, 1).hashCode(); | 583 result += c.newInstance(null, 1).hashCode(); |
586 } | 584 } |
587 // Deoptimize non-osr versions | |
588 waitAndDeoptimize(c); | |
589 return result; | 585 return result; |
590 } | 586 } |
591 | 587 |
592 private static final Constructor CONSTRUCTOR; | 588 private static final Constructor CONSTRUCTOR; |
593 private static final Constructor OSR_CONSTRUCTOR; | 589 private static final Constructor OSR_CONSTRUCTOR; |
632 private int method() { | 628 private int method() { |
633 return 42; | 629 return 42; |
634 } | 630 } |
635 | 631 |
636 private static int osrStaticMethod(long limit) { | 632 private static int osrStaticMethod(long limit) { |
633 if (limit != 1) { | |
634 // Make sure there is no compiled version after warmup | |
635 waitAndDeoptimize(OSR_STATIC); | |
636 } | |
637 // Trigger osr compilation | |
637 int result = 0; | 638 int result = 0; |
638 for (long i = 0; i < limit; ++i) { | 639 for (long i = 0; i < limit; ++i) { |
639 result += staticMethod(); | 640 result += staticMethod(); |
640 } | 641 } |
641 return result; | 642 return result; |
642 } | 643 } |
643 | 644 |
644 private int osrMethod(long limit) { | 645 private int osrMethod(long limit) { |
646 if (limit != 1) { | |
647 // Make sure there is no compiled version after warmup | |
648 waitAndDeoptimize(OSR_METHOD); | |
649 } | |
650 // Trigger osr compilation | |
645 int result = 0; | 651 int result = 0; |
646 for (long i = 0; i < limit; ++i) { | 652 for (long i = 0; i < limit; ++i) { |
647 result += method(); | 653 result += method(); |
648 } | 654 } |
649 return result; | 655 return result; |
656 x = 0; | 662 x = 0; |
657 } | 663 } |
658 | 664 |
659 // for OSR constructor test case | 665 // for OSR constructor test case |
660 private Helper(Object o, long limit) { | 666 private Helper(Object o, long limit) { |
667 if (limit != 1) { | |
668 // Make sure there is no compiled version after warmup | |
669 waitAndDeoptimize(OSR_CONSTRUCTOR); | |
670 } | |
671 // Trigger osr compilation | |
661 int result = 0; | 672 int result = 0; |
662 for (long i = 0; i < limit; ++i) { | 673 for (long i = 0; i < limit; ++i) { |
663 result += method(); | 674 result += method(); |
664 } | 675 } |
665 x = result; | 676 x = result; |