Skip to content

Commit d9a1f2f

Browse files
committed
[skip ci] add UseGraalJIT VM flag
1 parent 8474e69 commit d9a1f2f

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/hotspot/share/jvmci/jvmci_globals.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ class fileStream;
4848
product(bool, EnableJVMCI, false, EXPERIMENTAL, \
4949
"Enable JVMCI") \
5050
\
51+
product(bool, UseGraalJIT, false, \
52+
"Select the Graal JVMCI compiler. This is a macro for: " \
53+
" -XX:+UnlockExperimentalVMOptions " \
54+
" -XX:+EnableJVMCIProduct " \
55+
" -XX:+UseJVMCICompiler " \
56+
" -Djvmci.Compiler=graal " \
57+
" -XX:-UnlockExperimentalVMOptions") \
58+
\
5159
product(bool, EnableJVMCIProduct, false, EXPERIMENTAL, \
5260
"Allow JVMCI to be used in product mode. This alters a subset of "\
5361
"JVMCI flags to be non-experimental, defaults UseJVMCICompiler " \

src/hotspot/share/runtime/arguments.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2827,10 +2827,35 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
28272827
return JNI_ERR;
28282828
#endif // INCLUDE_MANAGEMENT
28292829
#if INCLUDE_JVMCI
2830+
} else if (match_option(option, "-XX:-UseGraalJIT")) {
2831+
FLAG_SET_CMDLINE(UseJVMCICompiler, false);
2832+
} else if (match_option(option, "-XX:+UseGraalJIT")) {
2833+
if (!EnableJVMCIProduct) {
2834+
bool save = UnlockExperimentalVMOptions;
2835+
bool ok = JVMCIGlobals::enable_jvmci_product_mode(origin);
2836+
UnlockExperimentalVMOptions = save;
2837+
if (!ok) {
2838+
jio_fprintf(defaultStream::error_stream(),
2839+
"Unable to enable JVMCI in product mode");
2840+
return JNI_ERR;
2841+
}
2842+
}
2843+
2844+
const char* jvmci_compiler = get_property("jvmci.Compiler");
2845+
if (jvmci_compiler != nullptr) {
2846+
if (strcmp(jvmci_compiler, "graal") != 0) {
2847+
jio_fprintf(defaultStream::error_stream(),
2848+
"Value of jvmci.Compiler incompatible with +UseGraalJIT: %s", jvmci_compiler);
2849+
return JNI_ERR;
2850+
}
2851+
} else if (!add_property("jvmci.Compiler=graal")) {
2852+
return JNI_ENOMEM;
2853+
}
2854+
FLAG_SET_CMDLINE(UseJVMCICompiler, true);
28302855
} else if (match_option(option, "-XX:-EnableJVMCIProduct")) {
28312856
if (EnableJVMCIProduct) {
28322857
jio_fprintf(defaultStream::error_stream(),
2833-
"-XX:-EnableJVMCIProduct cannot come after -XX:+EnableJVMCIProduct\n");
2858+
"-XX:-EnableJVMCIProduct cannot come after -XX:+EnableJVMCIProduct or -XX:+UseGraalJIT\n");
28342859
return JNI_EINVAL;
28352860
}
28362861
} else if (match_option(option, "-XX:+EnableJVMCIProduct")) {

0 commit comments

Comments
 (0)