Print this page
rev 6860 : 8046268: compiler/whitebox/ tests fail : must be osr_compiled
Summary: Added code to 'warm up' the methods before triggering OSR compilation by executing them a limited number of times. Like this, the profile information marks the loop exit as taken and we don't add an uncommon trap.
Reviewed-by: kvn, dlong, iignatyev
rev 6863 : 8061983: [TESTBUG] compiler/whitebox/MakeMethodNotCompilableTest.java fails with "must not be in queue"
Summary: Added a method checkNotCompiled(boolean isOsr) to either check if the method is OSR compiled or to check if it is non-OSR compiled.
Reviewed-by: kvn
Split |
Split |
Close |
Expand all |
Collapse all |
--- old/test/compiler/whitebox/MakeMethodNotCompilableTest.java
+++ new/test/compiler/whitebox/MakeMethodNotCompilableTest.java
1 1 /*
2 2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 */
23 23
24 24 /*
25 25 * @test MakeMethodNotCompilableTest
26 26 * @bug 8012322 8006683 8007288 8022832
27 27 * @library /testlibrary /testlibrary/whitebox
28 28 * @build MakeMethodNotCompilableTest
29 29 * @run main ClassFileInstaller sun.hotspot.WhiteBox
30 30 * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* MakeMethodNotCompilableTest
31 31 * @summary testing of WB::makeMethodNotCompilable()
32 32 * @author igor.ignatyev@oracle.com
33 33 */
34 34 public class MakeMethodNotCompilableTest extends CompilerWhiteBoxTest {
35 35 private int bci;
36 36 public static void main(String[] args) throws Exception {
37 37 CompilerWhiteBoxTest.main(MakeMethodNotCompilableTest::new, args);
38 38 }
39 39
40 40 private MakeMethodNotCompilableTest(TestCase testCase) {
41 41 super(testCase);
42 42 // to prevent inlining of #method
43 43 WHITE_BOX.testSetDontInlineMethod(method, true);
44 44 }
45 45
46 46 /**
47 47 * Tests {@code WB::makeMethodNotCompilable()} by calling it before
48 48 * compilation and checking that method isn't compiled. Also
49 49 * checks that WB::clearMethodState() clears no-compilable flags. For
50 50 * tiered, additional checks for all available levels are conducted.
51 51 *
52 52 * @throws Exception if one of the checks fails.
53 53 */
54 54 @Override
55 55 protected void test() throws Exception {
56 56 if (skipXcompOSR()) {
57 57 return;
58 58 }
59 59 checkNotCompiled();
60 60 if (!isCompilable()) {
61 61 throw new RuntimeException(method + " must be compilable");
62 62 }
63 63
64 64 bci = getBci();
65 65
66 66 if (TIERED_COMPILATION) {
67 67 final int tierLimit = TIERED_STOP_AT_LEVEL + 1;
68 68 for (int testedTier = 1; testedTier < tierLimit; ++testedTier) {
69 69 testTier(testedTier);
70 70 }
71 71 for (int testedTier = 1; testedTier < tierLimit; ++testedTier) {
72 72 makeNotCompilable(testedTier);
73 73 if (isCompilable(testedTier)) {
74 74 throw new RuntimeException(method
75 75 + " must be not compilable at level" + testedTier);
76 76 }
77 77 WHITE_BOX.enqueueMethodForCompilation(method, testedTier, bci);
78 78 checkNotCompiled();
79 79
80 80 if (!isCompilable()) {
81 81 System.out.println(method
82 82 + " is not compilable after level " + testedTier);
83 83 }
84 84 }
85 85 } else {
86 86 compile();
87 87 checkCompiled();
88 88 int compLevel = getCompLevel();
89 89 deoptimize();
90 90 makeNotCompilable(compLevel);
91 91 if (isCompilable(COMP_LEVEL_ANY)) {
92 92 throw new RuntimeException(method
93 93 + " must be not compilable at CompLevel::CompLevel_any,"
94 94 + " after it is not compilable at " + compLevel);
95 95 }
96 96
97 97 WHITE_BOX.clearMethodState(method);
98 98 if (!isCompilable()) {
99 99 throw new RuntimeException(method
100 100 + " is not compilable after clearMethodState()");
101 101 }
102 102
103 103 // nocompilable at opposite level must make no sense
104 104 int oppositeLevel;
105 105 if (isC1Compile(compLevel)) {
106 106 oppositeLevel = COMP_LEVEL_FULL_OPTIMIZATION;
107 107 } else {
108 108 oppositeLevel = COMP_LEVEL_SIMPLE;
109 109 }
110 110 makeNotCompilable(oppositeLevel);
111 111
112 112 if (!isCompilable(COMP_LEVEL_ANY)) {
113 113 throw new RuntimeException(method
114 114 + " must be compilable at CompLevel::CompLevel_any,"
115 115 + " even it is not compilable at opposite level ["
116 116 + compLevel + "]");
117 117 }
118 118
119 119 if (!isCompilable(compLevel)) {
120 120 throw new RuntimeException(method
121 121 + " must be compilable at level " + compLevel
122 122 + ", even it is not compilable at opposite level ["
123 123 + compLevel + "]");
↓ open down ↓ |
123 lines elided |
↑ open up ↑ |
124 124 }
125 125 }
126 126
127 127 // clearing after tiered/non-tiered tests
128 128 // WB.clearMethodState() must reset no-compilable flags
129 129 WHITE_BOX.clearMethodState(method);
130 130 if (!isCompilable()) {
131 131 throw new RuntimeException(method
132 132 + " is not compilable after clearMethodState()");
133 133 }
134 -
134 + // Make method not (OSR-)compilable (depending on testCase.isOsr())
135 135 makeNotCompilable();
136 136 if (isCompilable()) {
137 137 throw new RuntimeException(method + " must be not compilable");
138 138 }
139 -
139 + // Try to (OSR-)compile method
140 140 compile();
141 - checkNotCompiled();
141 + // Method should not be (OSR-)compiled
142 + checkNotCompiled(testCase.isOsr());
142 143 if (isCompilable()) {
143 144 throw new RuntimeException(method + " must be not compilable");
144 145 }
145 146 // WB.clearMethodState() must reset no-compilable flags
146 147 WHITE_BOX.clearMethodState(method);
147 148 if (!isCompilable()) {
148 149 throw new RuntimeException(method
149 150 + " is not compilable after clearMethodState()");
150 151 }
151 152 compile();
152 153 checkCompiled();
153 154 }
154 155
155 156 // separately tests each tier
156 157 private void testTier(int testedTier) {
157 158 if (!isCompilable(testedTier)) {
158 159 throw new RuntimeException(method
159 160 + " is not compilable on start");
160 161 }
161 162 makeNotCompilable(testedTier);
162 163
163 164 // tests for all other tiers
164 165 for (int anotherTier = 1, tierLimit = TIERED_STOP_AT_LEVEL + 1;
165 166 anotherTier < tierLimit; ++anotherTier) {
166 167 boolean isCompilable = isCompilable(anotherTier);
167 168 if (sameCompile(testedTier, anotherTier)) {
168 169 if (isCompilable) {
169 170 throw new RuntimeException(method
170 171 + " must be not compilable at level " + anotherTier
171 172 + ", if it is not compilable at " + testedTier);
172 173 }
173 174 WHITE_BOX.enqueueMethodForCompilation(method, anotherTier, bci);
174 175 checkNotCompiled();
175 176 } else {
176 177 if (!isCompilable) {
177 178 throw new RuntimeException(method
178 179 + " must be compilable at level " + anotherTier
179 180 + ", even if it is not compilable at "
180 181 + testedTier);
181 182 }
182 183 WHITE_BOX.enqueueMethodForCompilation(method, anotherTier, bci);
183 184 checkCompiled();
184 185 deoptimize();
185 186 }
186 187
187 188 if (!isCompilable(COMP_LEVEL_ANY)) {
188 189 throw new RuntimeException(method
189 190 + " must be compilable at 'CompLevel::CompLevel_any'"
190 191 + ", if it is not compilable only at " + testedTier);
191 192 }
192 193 }
193 194
194 195 // clear state after test
195 196 WHITE_BOX.clearMethodState(method);
196 197 if (!isCompilable(testedTier)) {
197 198 throw new RuntimeException(method
198 199 + " is not compilable after clearMethodState()");
199 200 }
200 201 }
201 202
202 203 private boolean sameCompile(int level1, int level2) {
203 204 if (level1 == level2) {
204 205 return true;
205 206 }
206 207 if (isC1Compile(level1) && isC1Compile(level2)) {
207 208 return true;
208 209 }
209 210 if (isC2Compile(level1) && isC2Compile(level2)) {
210 211 return true;
211 212 }
212 213 return false;
213 214 }
214 215
215 216 private int getBci() {
216 217 compile();
217 218 checkCompiled();
218 219 int result = WHITE_BOX.getMethodEntryBci(method);
219 220 deoptimize();
220 221 WHITE_BOX.clearMethodState(method);
221 222 return result;
222 223 }
223 224 }
↓ open down ↓ |
72 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX