7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import com.sun.management.HotSpotDiagnosticMXBean;
25 import com.sun.management.VMOption;
26 import sun.hotspot.WhiteBox;
27 import sun.management.ManagementFactoryHelper;
28
29 import java.lang.reflect.Constructor;
30 import java.lang.reflect.Executable;
31 import java.lang.reflect.Method;
32 import java.util.Objects;
33 import java.util.concurrent.Callable;
34 import java.util.function.Function;
35
36 /**
37 * Abstract class for WhiteBox testing of JIT.
38 *
39 * @author igor.ignatyev@oracle.com
40 */
41 public abstract class CompilerWhiteBoxTest {
42 /** {@code CompLevel::CompLevel_none} -- Interpreter */
43 protected static int COMP_LEVEL_NONE = 0;
44 /** {@code CompLevel::CompLevel_any}, {@code CompLevel::CompLevel_all} */
45 protected static int COMP_LEVEL_ANY = -1;
46 /** {@code CompLevel::CompLevel_simple} -- C1 */
261 if (!WHITE_BOX.isMethodCompiled(method, testCase.isOsr())) {
262 throw new RuntimeException(method + " must be "
263 + (testCase.isOsr() ? "osr_" : "") + "compiled");
264 }
265 if (WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr())
266 == 0) {
267 throw new RuntimeException(method
268 + (testCase.isOsr() ? " osr_" : " ")
269 + "comp_level must be != 0");
270 }
271 }
272
273 protected final void deoptimize() {
274 WHITE_BOX.deoptimizeMethod(method, testCase.isOsr());
275 if (testCase.isOsr()) {
276 WHITE_BOX.deoptimizeMethod(method, false);
277 }
278 }
279
280 protected final int getCompLevel() {
281 return WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr());
282 }
283
284 protected final boolean isCompilable() {
285 return WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY,
286 testCase.isOsr());
287 }
288
289 protected final boolean isCompilable(int compLevel) {
290 return WHITE_BOX
291 .isMethodCompilable(method, compLevel, testCase.isOsr());
292 }
293
294 protected final void makeNotCompilable() {
295 WHITE_BOX.makeMethodNotCompilable(method, COMP_LEVEL_ANY,
296 testCase.isOsr());
297 }
298
299 protected final void makeNotCompilable(int compLevel) {
300 WHITE_BOX.makeMethodNotCompilable(method, compLevel, testCase.isOsr());
301 }
|
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import com.sun.management.HotSpotDiagnosticMXBean;
25 import com.sun.management.VMOption;
26 import sun.hotspot.WhiteBox;
27 import sun.hotspot.code.NMethod;
28 import sun.management.ManagementFactoryHelper;
29
30 import java.lang.reflect.Constructor;
31 import java.lang.reflect.Executable;
32 import java.lang.reflect.Method;
33 import java.util.Objects;
34 import java.util.concurrent.Callable;
35 import java.util.function.Function;
36
37 /**
38 * Abstract class for WhiteBox testing of JIT.
39 *
40 * @author igor.ignatyev@oracle.com
41 */
42 public abstract class CompilerWhiteBoxTest {
43 /** {@code CompLevel::CompLevel_none} -- Interpreter */
44 protected static int COMP_LEVEL_NONE = 0;
45 /** {@code CompLevel::CompLevel_any}, {@code CompLevel::CompLevel_all} */
46 protected static int COMP_LEVEL_ANY = -1;
47 /** {@code CompLevel::CompLevel_simple} -- C1 */
262 if (!WHITE_BOX.isMethodCompiled(method, testCase.isOsr())) {
263 throw new RuntimeException(method + " must be "
264 + (testCase.isOsr() ? "osr_" : "") + "compiled");
265 }
266 if (WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr())
267 == 0) {
268 throw new RuntimeException(method
269 + (testCase.isOsr() ? " osr_" : " ")
270 + "comp_level must be != 0");
271 }
272 }
273
274 protected final void deoptimize() {
275 WHITE_BOX.deoptimizeMethod(method, testCase.isOsr());
276 if (testCase.isOsr()) {
277 WHITE_BOX.deoptimizeMethod(method, false);
278 }
279 }
280
281 protected final int getCompLevel() {
282 NMethod nm = NMethod.get(method, testCase.isOsr());
283 return nm == null ? COMP_LEVEL_NONE : nm.comp_level;
284 }
285
286 protected final boolean isCompilable() {
287 return WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY,
288 testCase.isOsr());
289 }
290
291 protected final boolean isCompilable(int compLevel) {
292 return WHITE_BOX
293 .isMethodCompilable(method, compLevel, testCase.isOsr());
294 }
295
296 protected final void makeNotCompilable() {
297 WHITE_BOX.makeMethodNotCompilable(method, COMP_LEVEL_ANY,
298 testCase.isOsr());
299 }
300
301 protected final void makeNotCompilable(int compLevel) {
302 WHITE_BOX.makeMethodNotCompilable(method, compLevel, testCase.isOsr());
303 }
|