comparison test/compiler/whitebox/IsMethodCompilableTest.java @ 12073:f99558245e5c

8022832: Add WB APIs for OSR compilation Reviewed-by: kvn
author iignatyev
date Wed, 14 Aug 2013 23:50:23 +0400
parents 11237ee74aae
children 303826f477c6
comparison
equal deleted inserted replaced
12072:6c72125a2f40 12073:f99558245e5c
21 * questions. 21 * questions.
22 */ 22 */
23 23
24 /* 24 /*
25 * @test IsMethodCompilableTest 25 * @test IsMethodCompilableTest
26 * @bug 8007270 26 * @bug 8007270 8006683 8007288 8022832
27 * @library /testlibrary /testlibrary/whitebox 27 * @library /testlibrary /testlibrary/whitebox
28 * @build IsMethodCompilableTest 28 * @build IsMethodCompilableTest
29 * @run main ClassFileInstaller sun.hotspot.WhiteBox 29 * @run main ClassFileInstaller sun.hotspot.WhiteBox
30 * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,TestCase$Helper::* IsMethodCompilableTest 30 * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,TestCase$Helper::* IsMethodCompilableTest
31 * @summary testing of WB::isMethodCompilable() 31 * @summary testing of WB::isMethodCompilable()
32 * @author igor.ignatyev@oracle.com 32 * @author igor.ignatyev@oracle.com
33 */ 33 */
34 public class IsMethodCompilableTest extends CompilerWhiteBoxTest { 34 public class IsMethodCompilableTest extends CompilerWhiteBoxTest {
35 /** 35 /**
66 * 66 *
67 * @throws Exception if one of the checks fails. 67 * @throws Exception if one of the checks fails.
68 */ 68 */
69 @Override 69 @Override
70 protected void test() throws Exception { 70 protected void test() throws Exception {
71 if (!WHITE_BOX.isMethodCompilable(method)) { 71 if (!isCompilable()) {
72 throw new RuntimeException(method + " must be compilable"); 72 throw new RuntimeException(method + " must be compilable");
73 } 73 }
74 System.out.println("PerMethodRecompilationCutoff = " 74 System.out.println("PerMethodRecompilationCutoff = "
75 + PER_METHOD_RECOMPILATION_CUTOFF); 75 + PER_METHOD_RECOMPILATION_CUTOFF);
76 if (PER_METHOD_RECOMPILATION_CUTOFF == -1) { 76 if (PER_METHOD_RECOMPILATION_CUTOFF == -1) {
81 81
82 // deoptimize 'PerMethodRecompilationCutoff' times and clear state 82 // deoptimize 'PerMethodRecompilationCutoff' times and clear state
83 for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) { 83 for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) {
84 compileAndDeoptimize(); 84 compileAndDeoptimize();
85 } 85 }
86 if (!WHITE_BOX.isMethodCompilable(method)) { 86 if (!testCase.isOsr && !isCompilable()) {
87 // in osr test case count of deopt maybe more than iterations
87 throw new RuntimeException(method + " is not compilable after " 88 throw new RuntimeException(method + " is not compilable after "
88 + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations"); 89 + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations");
89 } 90 }
90 WHITE_BOX.clearMethodState(method); 91 WHITE_BOX.clearMethodState(method);
91 92
92 // deoptimize 'PerMethodRecompilationCutoff' + 1 times 93 // deoptimize 'PerMethodRecompilationCutoff' + 1 times
93 long i; 94 long i;
94 for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF 95 for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF
95 && WHITE_BOX.isMethodCompilable(method); ++i) { 96 && isCompilable(); ++i) {
96 compileAndDeoptimize(); 97 compileAndDeoptimize();
97 } 98 }
98 if (i != PER_METHOD_RECOMPILATION_CUTOFF) { 99 if (!testCase.isOsr && i != PER_METHOD_RECOMPILATION_CUTOFF) {
100 // in osr test case count of deopt maybe more than iterations
99 throw new RuntimeException(method + " is not compilable after " 101 throw new RuntimeException(method + " is not compilable after "
100 + i + " iterations, but must only after " 102 + i + " iterations, but must only after "
101 + PER_METHOD_RECOMPILATION_CUTOFF); 103 + PER_METHOD_RECOMPILATION_CUTOFF);
102 } 104 }
103 if (WHITE_BOX.isMethodCompilable(method)) { 105 if (isCompilable()) {
104 throw new RuntimeException(method + " is still compilable after " 106 throw new RuntimeException(method + " is still compilable after "
105 + PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); 107 + PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
106 } 108 }
107 compile(); 109 compile();
108 checkNotCompiled(); 110 checkNotCompiled();
109 111
110 // WB.clearMethodState() must reset no-compilable flags 112 // WB.clearMethodState() must reset no-compilable flags
111 WHITE_BOX.clearMethodState(method); 113 WHITE_BOX.clearMethodState(method);
112 if (!WHITE_BOX.isMethodCompilable(method)) { 114 if (!isCompilable()) {
113 throw new RuntimeException(method 115 throw new RuntimeException(method
114 + " is not compilable after clearMethodState()"); 116 + " is not compilable after clearMethodState()");
115 } 117 }
116 compile(); 118 compile();
117 checkCompiled(); 119 checkCompiled();
118 } 120 }
119 121
120 private void compileAndDeoptimize() throws Exception { 122 private void compileAndDeoptimize() throws Exception {
121 compile(); 123 compile();
122 waitBackgroundCompilation(); 124 waitBackgroundCompilation();
123 WHITE_BOX.deoptimizeMethod(method); 125 deoptimize();
124 } 126 }
125 } 127 }