Mercurial > hg > graal-compiler
comparison test/compiler/whitebox/MakeMethodNotCompilableTest.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 MakeMethodNotCompilableTest | 25 * @test MakeMethodNotCompilableTest |
26 * @bug 8012322 | 26 * @bug 8012322 8006683 8007288 8022832 |
27 * @library /testlibrary /testlibrary/whitebox | 27 * @library /testlibrary /testlibrary/whitebox |
28 * @build MakeMethodNotCompilableTest | 28 * @build MakeMethodNotCompilableTest |
29 * @run main ClassFileInstaller sun.hotspot.WhiteBox | 29 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
30 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,TestCase$Helper::* MakeMethodNotCompilableTest | 30 * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,TestCase$Helper::* MakeMethodNotCompilableTest |
31 * @summary testing of WB::makeMethodNotCompilable() | 31 * @summary testing of WB::makeMethodNotCompilable() |
32 * @author igor.ignatyev@oracle.com | 32 * @author igor.ignatyev@oracle.com |
33 */ | 33 */ |
34 public class MakeMethodNotCompilableTest extends CompilerWhiteBoxTest { | 34 public class MakeMethodNotCompilableTest extends CompilerWhiteBoxTest { |
35 | 35 private int bci; |
36 public static void main(String[] args) throws Exception { | 36 public static void main(String[] args) throws Exception { |
37 if (args.length == 0) { | 37 if (args.length == 0) { |
38 for (TestCase test : TestCase.values()) { | 38 for (TestCase test : TestCase.values()) { |
39 new MakeMethodNotCompilableTest(test).runTest(); | 39 new MakeMethodNotCompilableTest(test).runTest(); |
40 } | 40 } |
61 * @throws Exception if one of the checks fails. | 61 * @throws Exception if one of the checks fails. |
62 */ | 62 */ |
63 @Override | 63 @Override |
64 protected void test() throws Exception { | 64 protected void test() throws Exception { |
65 checkNotCompiled(); | 65 checkNotCompiled(); |
66 if (!WHITE_BOX.isMethodCompilable(method)) { | 66 if (!isCompilable()) { |
67 throw new RuntimeException(method + " must be compilable"); | 67 throw new RuntimeException(method + " must be compilable"); |
68 } | 68 } |
69 | |
70 bci = getBci(); | |
69 | 71 |
70 if (TIERED_COMPILATION) { | 72 if (TIERED_COMPILATION) { |
71 final int tierLimit = TIERED_STOP_AT_LEVEL + 1; | 73 final int tierLimit = TIERED_STOP_AT_LEVEL + 1; |
72 for (int testedTier = 1; testedTier < tierLimit; ++testedTier) { | 74 for (int testedTier = 1; testedTier < tierLimit; ++testedTier) { |
73 testTier(testedTier); | 75 testTier(testedTier); |
74 } | 76 } |
75 for (int testedTier = 1; testedTier < tierLimit; ++testedTier) { | 77 for (int testedTier = 1; testedTier < tierLimit; ++testedTier) { |
76 WHITE_BOX.makeMethodNotCompilable(method, testedTier); | 78 makeNotCompilable(testedTier); |
77 if (WHITE_BOX.isMethodCompilable(method, testedTier)) { | 79 if (isCompilable(testedTier)) { |
78 throw new RuntimeException(method | 80 throw new RuntimeException(method |
79 + " must be not compilable at level" + testedTier); | 81 + " must be not compilable at level" + testedTier); |
80 } | 82 } |
81 WHITE_BOX.enqueueMethodForCompilation(method, testedTier); | 83 WHITE_BOX.enqueueMethodForCompilation(method, testedTier, bci); |
82 checkNotCompiled(); | 84 checkNotCompiled(); |
83 | 85 |
84 if (!WHITE_BOX.isMethodCompilable(method)) { | 86 if (!isCompilable()) { |
85 System.out.println(method | 87 System.out.println(method |
86 + " is not compilable after level " + testedTier); | 88 + " is not compilable after level " + testedTier); |
87 } | 89 } |
88 } | 90 } |
89 } else { | 91 } else { |
90 compile(); | 92 compile(); |
91 checkCompiled(); | 93 checkCompiled(); |
92 int compLevel = WHITE_BOX.getMethodCompilationLevel(method); | 94 int compLevel = getCompLevel(); |
93 WHITE_BOX.deoptimizeMethod(method); | 95 deoptimize(); |
94 WHITE_BOX.makeMethodNotCompilable(method, compLevel); | 96 makeNotCompilable(compLevel); |
95 if (WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY)) { | 97 if (isCompilable(COMP_LEVEL_ANY)) { |
96 throw new RuntimeException(method | 98 throw new RuntimeException(method |
97 + " must be not compilable at CompLevel::CompLevel_any," | 99 + " must be not compilable at CompLevel::CompLevel_any," |
98 + " after it is not compilable at " + compLevel); | 100 + " after it is not compilable at " + compLevel); |
99 } | 101 } |
102 | |
100 WHITE_BOX.clearMethodState(method); | 103 WHITE_BOX.clearMethodState(method); |
104 if (!isCompilable()) { | |
105 throw new RuntimeException(method | |
106 + " is not compilable after clearMethodState()"); | |
107 } | |
101 | 108 |
102 // nocompilable at opposite level must make no sense | 109 // nocompilable at opposite level must make no sense |
103 int oppositeLevel; | 110 int oppositeLevel; |
104 if (isC1Compile(compLevel)) { | 111 if (isC1Compile(compLevel)) { |
105 oppositeLevel = COMP_LEVEL_FULL_OPTIMIZATION; | 112 oppositeLevel = COMP_LEVEL_FULL_OPTIMIZATION; |
106 } else { | 113 } else { |
107 oppositeLevel = COMP_LEVEL_SIMPLE; | 114 oppositeLevel = COMP_LEVEL_SIMPLE; |
108 } | 115 } |
109 WHITE_BOX.makeMethodNotCompilable(method, oppositeLevel); | 116 makeNotCompilable(oppositeLevel); |
110 | 117 |
111 if (!WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY)) { | 118 if (!isCompilable(COMP_LEVEL_ANY)) { |
112 throw new RuntimeException(method | 119 throw new RuntimeException(method |
113 + " must be compilable at CompLevel::CompLevel_any," | 120 + " must be compilable at CompLevel::CompLevel_any," |
114 + " even it is not compilable at opposite level [" | 121 + " even it is not compilable at opposite level [" |
115 + compLevel + "]"); | 122 + compLevel + "]"); |
116 } | 123 } |
117 | 124 |
118 if (!WHITE_BOX.isMethodCompilable(method, compLevel)) { | 125 if (!isCompilable(compLevel)) { |
119 throw new RuntimeException(method | 126 throw new RuntimeException(method |
120 + " must be compilable at level " + compLevel | 127 + " must be compilable at level " + compLevel |
121 + ", even it is not compilable at opposite level [" | 128 + ", even it is not compilable at opposite level [" |
122 + compLevel + "]"); | 129 + compLevel + "]"); |
123 } | 130 } |
124 } | 131 } |
125 | 132 |
126 // clearing after tiered/non-tiered tests | 133 // clearing after tiered/non-tiered tests |
127 // WB.clearMethodState() must reset no-compilable flags | 134 // WB.clearMethodState() must reset no-compilable flags |
128 WHITE_BOX.clearMethodState(method); | 135 WHITE_BOX.clearMethodState(method); |
129 if (!WHITE_BOX.isMethodCompilable(method)) { | 136 if (!isCompilable()) { |
130 throw new RuntimeException(method | 137 throw new RuntimeException(method |
131 + " is not compilable after clearMethodState()"); | 138 + " is not compilable after clearMethodState()"); |
132 } | 139 } |
133 | 140 |
134 WHITE_BOX.makeMethodNotCompilable(method); | 141 makeNotCompilable(); |
135 if (WHITE_BOX.isMethodCompilable(method)) { | 142 if (isCompilable()) { |
136 throw new RuntimeException(method + " must be not compilable"); | 143 throw new RuntimeException(method + " must be not compilable"); |
137 } | 144 } |
138 | 145 |
139 compile(); | 146 compile(); |
140 checkNotCompiled(); | 147 checkNotCompiled(); |
141 if (WHITE_BOX.isMethodCompilable(method)) { | 148 if (isCompilable()) { |
142 throw new RuntimeException(method + " must be not compilable"); | 149 throw new RuntimeException(method + " must be not compilable"); |
143 } | 150 } |
144 // WB.clearMethodState() must reset no-compilable flags | 151 // WB.clearMethodState() must reset no-compilable flags |
145 WHITE_BOX.clearMethodState(method); | 152 WHITE_BOX.clearMethodState(method); |
146 if (!WHITE_BOX.isMethodCompilable(method)) { | 153 if (!isCompilable()) { |
147 throw new RuntimeException(method | 154 throw new RuntimeException(method |
148 + " is not compilable after clearMethodState()"); | 155 + " is not compilable after clearMethodState()"); |
149 } | 156 } |
150 compile(); | 157 compile(); |
151 checkCompiled(); | 158 checkCompiled(); |
152 } | 159 } |
153 | 160 |
154 // separately tests each tier | 161 // separately tests each tier |
155 private void testTier(int testedTier) { | 162 private void testTier(int testedTier) { |
156 if (!WHITE_BOX.isMethodCompilable(method, testedTier)) { | 163 if (!isCompilable(testedTier)) { |
157 throw new RuntimeException(method | 164 throw new RuntimeException(method |
158 + " is not compilable on start"); | 165 + " is not compilable on start"); |
159 } | 166 } |
160 WHITE_BOX.makeMethodNotCompilable(method, testedTier); | 167 makeNotCompilable(testedTier); |
161 | 168 |
162 // tests for all other tiers | 169 // tests for all other tiers |
163 for (int anotherTier = 1, tierLimit = TIERED_STOP_AT_LEVEL + 1; | 170 for (int anotherTier = 1, tierLimit = TIERED_STOP_AT_LEVEL + 1; |
164 anotherTier < tierLimit; ++anotherTier) { | 171 anotherTier < tierLimit; ++anotherTier) { |
165 boolean isCompilable = WHITE_BOX.isMethodCompilable(method, | 172 boolean isCompilable = isCompilable(anotherTier); |
166 anotherTier); | |
167 if (sameCompile(testedTier, anotherTier)) { | 173 if (sameCompile(testedTier, anotherTier)) { |
168 if (isCompilable) { | 174 if (isCompilable) { |
169 throw new RuntimeException(method | 175 throw new RuntimeException(method |
170 + " must be not compilable at level " + anotherTier | 176 + " must be not compilable at level " + anotherTier |
171 + ", if it is not compilable at " + testedTier); | 177 + ", if it is not compilable at " + testedTier); |
172 } | 178 } |
173 WHITE_BOX.enqueueMethodForCompilation(method, anotherTier); | 179 WHITE_BOX.enqueueMethodForCompilation(method, anotherTier, bci); |
174 checkNotCompiled(); | 180 checkNotCompiled(); |
175 } else { | 181 } else { |
176 if (!isCompilable) { | 182 if (!isCompilable) { |
177 throw new RuntimeException(method | 183 throw new RuntimeException(method |
178 + " must be compilable at level " + anotherTier | 184 + " must be compilable at level " + anotherTier |
179 + ", even if it is not compilable at " | 185 + ", even if it is not compilable at " |
180 + testedTier); | 186 + testedTier); |
181 } | 187 } |
182 WHITE_BOX.enqueueMethodForCompilation(method, anotherTier); | 188 WHITE_BOX.enqueueMethodForCompilation(method, anotherTier, bci); |
183 checkCompiled(); | 189 checkCompiled(); |
184 WHITE_BOX.deoptimizeMethod(method); | 190 deoptimize(); |
185 } | 191 } |
186 | 192 |
187 if (!WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY)) { | 193 if (!isCompilable(COMP_LEVEL_ANY)) { |
188 throw new RuntimeException(method | 194 throw new RuntimeException(method |
189 + " must be compilable at 'CompLevel::CompLevel_any'" | 195 + " must be compilable at 'CompLevel::CompLevel_any'" |
190 + ", if it is not compilable only at " + testedTier); | 196 + ", if it is not compilable only at " + testedTier); |
191 } | 197 } |
192 } | 198 } |
193 | 199 |
194 // clear state after test | 200 // clear state after test |
195 WHITE_BOX.clearMethodState(method); | 201 WHITE_BOX.clearMethodState(method); |
196 if (!WHITE_BOX.isMethodCompilable(method, testedTier)) { | 202 if (!isCompilable(testedTier)) { |
197 throw new RuntimeException(method | 203 throw new RuntimeException(method |
198 + " is not compilable after clearMethodState()"); | 204 + " is not compilable after clearMethodState()"); |
199 } | 205 } |
200 } | 206 } |
201 | 207 |
209 if (isC2Compile(level1) && isC2Compile(level2)) { | 215 if (isC2Compile(level1) && isC2Compile(level2)) { |
210 return true; | 216 return true; |
211 } | 217 } |
212 return false; | 218 return false; |
213 } | 219 } |
220 | |
221 private int getBci() { | |
222 compile(); | |
223 checkCompiled(); | |
224 int result = WHITE_BOX.getMethodEntryBci(method); | |
225 deoptimize(); | |
226 WHITE_BOX.clearMethodState(method); | |
227 return result; | |
228 } | |
214 } | 229 } |