1 /*
2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
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 package sun.hotspot.code;
25
26 import java.lang.reflect.Executable;
27 import sun.hotspot.WhiteBox;
28
29 /**
30 * API to obtain information about enabled JIT compilers
31 * retrieved from the VM with the WhiteBox API.
32 */
33 public class Compiler {
34
35 private static final WhiteBox WB = WhiteBox.getWhiteBox();
36
37 /**
38 * Check if Graal is used as JIT compiler.
39 *
40 * Graal is enabled if following conditions are true:
41 * - we are not in Interpreter mode
42 * - UseJVMCICompiler flag is true
43 * - jvmci.Compiler variable is equal to 'graal'
44 * - TieredCompilation is not used or TieredStopAtLevel is greater than 3
45 * No need to check client mode because it set UseJVMCICompiler to false.
46 *
47 * @return true if Graal is used as JIT compiler.
48 */
49 public static boolean isGraalEnabled() {
50 Boolean useCompiler = WB.getBooleanVMFlag("UseCompiler");
51 if (useCompiler == null || !useCompiler) {
52 return false;
53 }
54 Boolean useJvmciComp = WB.getBooleanVMFlag("UseJVMCICompiler");
55 if (useJvmciComp == null || !useJvmciComp) {
|
1 /*
2 * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
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 package sun.hotspot.code;
25
26 import java.lang.reflect.Executable;
27 import sun.hotspot.WhiteBox;
28
29 /**
30 * API to obtain information about enabled JIT compilers
31 * retrieved from the VM with the WhiteBox API.
32 */
33 public class Compiler {
34
35 private static final WhiteBox WB = WhiteBox.getWhiteBox();
36
37 /**
38 * Check if C2 or JVMCI were included in the VM build
39 *
40 * @return true if either C2 or JVMCI were included in the VM build.
41 */
42 public static boolean isC2OrJVMCIIncludedInVmBuild() {
43 return WB.isC2OrJVMCIIncludedInVmBuild();
44 }
45
46 /**
47 * Check if Graal is used as JIT compiler.
48 *
49 * Graal is enabled if following conditions are true:
50 * - we are not in Interpreter mode
51 * - UseJVMCICompiler flag is true
52 * - jvmci.Compiler variable is equal to 'graal'
53 * - TieredCompilation is not used or TieredStopAtLevel is greater than 3
54 * No need to check client mode because it set UseJVMCICompiler to false.
55 *
56 * @return true if Graal is used as JIT compiler.
57 */
58 public static boolean isGraalEnabled() {
59 Boolean useCompiler = WB.getBooleanVMFlag("UseCompiler");
60 if (useCompiler == null || !useCompiler) {
61 return false;
62 }
63 Boolean useJvmciComp = WB.getBooleanVMFlag("UseJVMCICompiler");
64 if (useJvmciComp == null || !useJvmciComp) {
|