Mercurial > hg > truffle
comparison test/compiler/whitebox/MakeMethodNotCompilableTest.java @ 10200:d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
Reviewed-by: kvn, vlivanov
author | iignatyev |
---|---|
date | Fri, 26 Apr 2013 07:21:41 -0700 |
parents | 4b2eebe03f93 |
children | 11237ee74aae |
comparison
equal
deleted
inserted
replaced
10197:7b23cb975cf2 | 10200:d1c9384eecb4 |
---|---|
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 | 23 |
24 /* | 24 /* |
25 * @test MakeMethodNotCompilableTest | 25 * @test MakeMethodNotCompilableTest |
26 * @bug 8012322 | |
26 * @library /testlibrary /testlibrary/whitebox | 27 * @library /testlibrary /testlibrary/whitebox |
27 * @build MakeMethodNotCompilableTest | 28 * @build MakeMethodNotCompilableTest |
28 * @run main ClassFileInstaller sun.hotspot.WhiteBox | 29 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
29 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI MakeMethodNotCompilableTest | 30 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI MakeMethodNotCompilableTest |
30 * @summary testing of WB::makeMethodNotCompilable() | 31 * @summary testing of WB::makeMethodNotCompilable() |
65 if (!WHITE_BOX.isMethodCompilable(method)) { | 66 if (!WHITE_BOX.isMethodCompilable(method)) { |
66 throw new RuntimeException(method + " must be compilable"); | 67 throw new RuntimeException(method + " must be compilable"); |
67 } | 68 } |
68 | 69 |
69 if (TIERED_COMPILATION) { | 70 if (TIERED_COMPILATION) { |
70 for (int i = 1, n = TIERED_STOP_AT_LEVEL + 1; i < n; ++i) { | 71 final int tierLimit = TIERED_STOP_AT_LEVEL + 1; |
71 WHITE_BOX.makeMethodNotCompilable(method, i); | 72 for (int testedTier = 1; testedTier < tierLimit; ++testedTier) { |
72 if (WHITE_BOX.isMethodCompilable(method, i)) { | 73 testTier(testedTier); |
74 } | |
75 for (int testedTier = 1; testedTier < tierLimit; ++testedTier) { | |
76 WHITE_BOX.makeMethodNotCompilable(method, testedTier); | |
77 if (WHITE_BOX.isMethodCompilable(method, testedTier)) { | |
73 throw new RuntimeException(method | 78 throw new RuntimeException(method |
74 + " must be not compilable at level" + i); | 79 + " must be not compilable at level" + testedTier); |
75 } | 80 } |
76 WHITE_BOX.enqueueMethodForCompilation(method, i); | 81 WHITE_BOX.enqueueMethodForCompilation(method, testedTier); |
77 checkNotCompiled(); | 82 checkNotCompiled(); |
78 | 83 |
79 if (!WHITE_BOX.isMethodCompilable(method)) { | 84 if (!WHITE_BOX.isMethodCompilable(method)) { |
80 System.out.println(method | 85 System.out.println(method |
81 + " is not compilable after level " + i); | 86 + " is not compilable after level " + testedTier); |
82 } | 87 } |
83 } | 88 } |
84 | 89 } else { |
85 // WB.clearMethodState() must reset no-compilable flags | 90 compile(); |
91 checkCompiled(); | |
92 int compLevel = WHITE_BOX.getMethodCompilationLevel(method); | |
93 WHITE_BOX.deoptimizeMethod(method); | |
94 WHITE_BOX.makeMethodNotCompilable(method, compLevel); | |
95 if (WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY)) { | |
96 throw new RuntimeException(method | |
97 + " must be not compilable at CompLevel::CompLevel_any," | |
98 + " after it is not compilable at " + compLevel); | |
99 } | |
86 WHITE_BOX.clearMethodState(method); | 100 WHITE_BOX.clearMethodState(method); |
87 if (!WHITE_BOX.isMethodCompilable(method)) { | 101 |
88 throw new RuntimeException(method | 102 // nocompilable at opposite level must make no sense |
89 + " is not compilable after clearMethodState()"); | 103 int oppositeLevel; |
90 } | 104 if (isC1Compile(compLevel)) { |
91 } | 105 oppositeLevel = COMP_LEVEL_FULL_OPTIMIZATION; |
106 } else { | |
107 oppositeLevel = COMP_LEVEL_SIMPLE; | |
108 } | |
109 WHITE_BOX.makeMethodNotCompilable(method, oppositeLevel); | |
110 | |
111 if (!WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY)) { | |
112 throw new RuntimeException(method | |
113 + " must be compilable at CompLevel::CompLevel_any," | |
114 + " even it is not compilable at opposite level [" | |
115 + compLevel + "]"); | |
116 } | |
117 | |
118 if (!WHITE_BOX.isMethodCompilable(method, compLevel)) { | |
119 throw new RuntimeException(method | |
120 + " must be compilable at level " + compLevel | |
121 + ", even it is not compilable at opposite level [" | |
122 + compLevel + "]"); | |
123 } | |
124 } | |
125 | |
126 // clearing after tiered/non-tiered tests | |
127 // WB.clearMethodState() must reset no-compilable flags | |
128 WHITE_BOX.clearMethodState(method); | |
129 if (!WHITE_BOX.isMethodCompilable(method)) { | |
130 throw new RuntimeException(method | |
131 + " is not compilable after clearMethodState()"); | |
132 } | |
133 | |
92 WHITE_BOX.makeMethodNotCompilable(method); | 134 WHITE_BOX.makeMethodNotCompilable(method); |
93 if (WHITE_BOX.isMethodCompilable(method)) { | 135 if (WHITE_BOX.isMethodCompilable(method)) { |
94 throw new RuntimeException(method + " must be not compilable"); | 136 throw new RuntimeException(method + " must be not compilable"); |
95 } | 137 } |
96 | 138 |
106 + " is not compilable after clearMethodState()"); | 148 + " is not compilable after clearMethodState()"); |
107 } | 149 } |
108 compile(); | 150 compile(); |
109 checkCompiled(); | 151 checkCompiled(); |
110 } | 152 } |
153 | |
154 // separately tests each tier | |
155 private void testTier(int testedTier) { | |
156 if (!WHITE_BOX.isMethodCompilable(method, testedTier)) { | |
157 throw new RuntimeException(method | |
158 + " is not compilable on start"); | |
159 } | |
160 WHITE_BOX.makeMethodNotCompilable(method, testedTier); | |
161 | |
162 // tests for all other tiers | |
163 for (int anotherTier = 1, tierLimit = TIERED_STOP_AT_LEVEL + 1; | |
164 anotherTier < tierLimit; ++anotherTier) { | |
165 boolean isCompilable = WHITE_BOX.isMethodCompilable(method, | |
166 anotherTier); | |
167 if (sameCompile(testedTier, anotherTier)) { | |
168 if (isCompilable) { | |
169 throw new RuntimeException(method | |
170 + " must be not compilable at level " + anotherTier | |
171 + ", if it is not compilable at " + testedTier); | |
172 } | |
173 WHITE_BOX.enqueueMethodForCompilation(method, anotherTier); | |
174 checkNotCompiled(); | |
175 } else { | |
176 if (!isCompilable) { | |
177 throw new RuntimeException(method | |
178 + " must be compilable at level " + anotherTier | |
179 + ", even if it is not compilable at " | |
180 + testedTier); | |
181 } | |
182 WHITE_BOX.enqueueMethodForCompilation(method, anotherTier); | |
183 checkCompiled(); | |
184 WHITE_BOX.deoptimizeMethod(method); | |
185 } | |
186 | |
187 if (!WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY)) { | |
188 throw new RuntimeException(method | |
189 + " must be compilable at 'CompLevel::CompLevel_any'" | |
190 + ", if it is not compilable only at " + testedTier); | |
191 } | |
192 } | |
193 | |
194 // clear state after test | |
195 WHITE_BOX.clearMethodState(method); | |
196 if (!WHITE_BOX.isMethodCompilable(method, testedTier)) { | |
197 throw new RuntimeException(method | |
198 + " is not compilable after clearMethodState()"); | |
199 } | |
200 } | |
201 | |
202 private boolean sameCompile(int level1, int level2) { | |
203 if (level1 == level2) { | |
204 return true; | |
205 } | |
206 if (isC1Compile(level1) && isC1Compile(level2)) { | |
207 return true; | |
208 } | |
209 if (isC2Compile(level1) && isC2Compile(level2)) { | |
210 return true; | |
211 } | |
212 return false; | |
213 } | |
111 } | 214 } |