comparison test/compiler/whitebox/IsMethodCompilableTest.java @ 9080:b84fd7d73702

8007288: Additional WB API for compiler's testing Reviewed-by: kvn, vlivanov
author iignatyev
date Tue, 09 Apr 2013 09:54:17 -0700
parents 4efac99a998b
children 4b2eebe03f93
comparison
equal deleted inserted replaced
9079:f67065f02409 9080:b84fd7d73702
43 } 43 }
44 } 44 }
45 45
46 public static void main(String[] args) throws Exception { 46 public static void main(String[] args) throws Exception {
47 // to prevent inlining #method into #compile() 47 // to prevent inlining #method into #compile()
48 WHITE_BOX.setDontInlineMethod(METHOD, true); 48 WHITE_BOX.testSetDontInlineMethod(METHOD, true);
49 new IsMethodCompilableTest().runTest(); 49 new IsMethodCompilableTest().runTest();
50 } 50 }
51 51
52 protected void test() throws Exception { 52 protected void test() throws Exception {
53 if (!WHITE_BOX.isMethodCompilable(METHOD)) { 53 if (!WHITE_BOX.isMethodCompilable(METHOD)) {
58 if (PER_METHOD_RECOMPILATION_CUTOFF == -1) { 58 if (PER_METHOD_RECOMPILATION_CUTOFF == -1) {
59 System.err.println( 59 System.err.println(
60 "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf"); 60 "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf");
61 return; 61 return;
62 } 62 }
63 boolean madeNotCompilable = false;
64 63
65 for (long i = 0; i < PER_METHOD_RECOMPILATION_CUTOFF; ++i) { 64 // deoptimze 'PerMethodRecompilationCutoff' times and clear state
66 compile(); 65 for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) {
67 waitBackgroundCompilation(METHOD); 66 compileAndDeoptimaze();
68 WHITE_BOX.deoptimizeMethod(METHOD);
69 if (!WHITE_BOX.isMethodCompilable(METHOD)) {
70 madeNotCompilable = true;
71 break;
72 }
73 } 67 }
74 if (!madeNotCompilable) { 68 if (!WHITE_BOX.isMethodCompilable(METHOD)) {
69 throw new RuntimeException(METHOD + " is not compilable after "
70 + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations");
71 }
72 WHITE_BOX.clearMethodState(METHOD);
73
74 // deoptimze 'PerMethodRecompilationCutoff' + 1 times
75 long i;
76 for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF
77 && WHITE_BOX.isMethodCompilable(METHOD); ++i) {
78 compileAndDeoptimaze();
79 }
80 if (i != PER_METHOD_RECOMPILATION_CUTOFF) {
81 throw new RuntimeException(METHOD + " is not compilable after "
82 + i + " iterations, but must only after "
83 + PER_METHOD_RECOMPILATION_CUTOFF);
84 }
85 if (WHITE_BOX.isMethodCompilable(METHOD)) {
75 throw new RuntimeException(METHOD + " is still compilable after " 86 throw new RuntimeException(METHOD + " is still compilable after "
76 + PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); 87 + PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
77 } 88 }
78 compile(); 89 compile();
79 if (WHITE_BOX.isMethodCompiled(METHOD)) { 90 checkNotCompiled(METHOD);
80 printInfo(METHOD); 91
81 throw new RuntimeException( 92 WHITE_BOX.clearMethodState(METHOD);
82 METHOD + " is not compilable but compiled"); 93 if (!WHITE_BOX.isMethodCompilable(METHOD)) {
94 throw new RuntimeException(METHOD
95 + " is compilable after clearMethodState()");
83 } 96 }
97 compile();
98 checkCompiled(METHOD);
99 }
100
101 private void compileAndDeoptimaze() throws Exception {
102 compile();
103 waitBackgroundCompilation(METHOD);
104 WHITE_BOX.deoptimizeMethod(METHOD);
84 } 105 }
85 } 106 }