8309136: [JVMCI] add -XX:+UseGraalJIT flag
Reviewed-by: dholmes, kvn
This commit is contained in:
parent
98b53c06cf
commit
b3c9d6785e
src/hotspot/share
test/hotspot/jtreg/compiler/jvmci
@ -545,7 +545,7 @@ bool CompilerConfig::check_args_consistency(bool status) {
|
||||
FLAG_SET_DEFAULT(SegmentedCodeCache, false);
|
||||
}
|
||||
#if INCLUDE_JVMCI
|
||||
if (EnableJVMCI) {
|
||||
if (EnableJVMCI || UseJVMCICompiler) {
|
||||
if (!FLAG_IS_DEFAULT(EnableJVMCI) || !FLAG_IS_DEFAULT(UseJVMCICompiler)) {
|
||||
warning("JVMCI Compiler disabled due to -Xint.");
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ bool JVMCIGlobals::check_jvmci_flags_are_consistent() {
|
||||
JVMCI_FLAG_CHECKED(UseJVMCICompiler)
|
||||
JVMCI_FLAG_CHECKED(EnableJVMCI)
|
||||
JVMCI_FLAG_CHECKED(EnableJVMCIProduct)
|
||||
JVMCI_FLAG_CHECKED(UseGraalJIT)
|
||||
|
||||
CHECK_NOT_SET(BootstrapJVMCI, UseJVMCICompiler)
|
||||
CHECK_NOT_SET(PrintBootstrap, UseJVMCICompiler)
|
||||
@ -164,7 +165,7 @@ bool JVMCIGlobals::check_jvmci_flags_are_consistent() {
|
||||
}
|
||||
|
||||
// Convert JVMCI flags from experimental to product
|
||||
bool JVMCIGlobals::enable_jvmci_product_mode(JVMFlagOrigin origin) {
|
||||
bool JVMCIGlobals::enable_jvmci_product_mode(JVMFlagOrigin origin, bool use_graal_jit) {
|
||||
const char *JVMCIFlags[] = {
|
||||
"EnableJVMCI",
|
||||
"EnableJVMCIProduct",
|
||||
@ -201,6 +202,12 @@ bool JVMCIGlobals::enable_jvmci_product_mode(JVMFlagOrigin origin) {
|
||||
if (JVMFlagAccess::set_bool(jvmciEnableFlag, &value, origin) != JVMFlag::SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
if (use_graal_jit) {
|
||||
JVMFlag *useGraalJITFlag = JVMFlag::find_flag("UseGraalJIT");
|
||||
if (JVMFlagAccess::set_bool(useGraalJITFlag, &value, origin) != JVMFlag::SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Effect of EnableJVMCIProduct on changing defaults of EnableJVMCI
|
||||
// and UseJVMCICompiler is deferred to check_jvmci_flags_are_consistent
|
||||
|
@ -48,6 +48,11 @@ class fileStream;
|
||||
product(bool, EnableJVMCI, false, EXPERIMENTAL, \
|
||||
"Enable JVMCI") \
|
||||
\
|
||||
product(bool, UseGraalJIT, false, EXPERIMENTAL, \
|
||||
"Select the Graal JVMCI compiler. This is an alias for: " \
|
||||
" -XX:+EnableJVMCIProduct " \
|
||||
" -Djvmci.Compiler=graal ") \
|
||||
\
|
||||
product(bool, EnableJVMCIProduct, false, EXPERIMENTAL, \
|
||||
"Allow JVMCI to be used in product mode. This alters a subset of "\
|
||||
"JVMCI flags to be non-experimental, defaults UseJVMCICompiler " \
|
||||
@ -185,7 +190,7 @@ class JVMCIGlobals {
|
||||
static bool check_jvmci_flags_are_consistent();
|
||||
|
||||
// Convert JVMCI experimental flags to product
|
||||
static bool enable_jvmci_product_mode(JVMFlagOrigin);
|
||||
static bool enable_jvmci_product_mode(JVMFlagOrigin origin, bool use_graal_jit);
|
||||
|
||||
// Returns true iff the GC fully supports JVMCI.
|
||||
static bool gc_supports_jvmci();
|
||||
|
@ -2827,28 +2827,42 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
|
||||
return JNI_ERR;
|
||||
#endif // INCLUDE_MANAGEMENT
|
||||
#if INCLUDE_JVMCI
|
||||
} else if (match_option(option, "-XX:-EnableJVMCIProduct")) {
|
||||
} else if (match_option(option, "-XX:-EnableJVMCIProduct") || match_option(option, "-XX:-UseGraalJIT")) {
|
||||
if (EnableJVMCIProduct) {
|
||||
jio_fprintf(defaultStream::error_stream(),
|
||||
"-XX:-EnableJVMCIProduct cannot come after -XX:+EnableJVMCIProduct\n");
|
||||
"-XX:-EnableJVMCIProduct or -XX:-UseGraalJIT cannot come after -XX:+EnableJVMCIProduct or -XX:+UseGraalJIT\n");
|
||||
return JNI_EINVAL;
|
||||
}
|
||||
} else if (match_option(option, "-XX:+EnableJVMCIProduct")) {
|
||||
// Just continue, since "-XX:+EnableJVMCIProduct" has been specified before
|
||||
} else if (match_option(option, "-XX:+EnableJVMCIProduct") || match_option(option, "-XX:+UseGraalJIT")) {
|
||||
bool use_graal_jit = match_option(option, "-XX:+UseGraalJIT");
|
||||
if (use_graal_jit) {
|
||||
const char* jvmci_compiler = get_property("jvmci.Compiler");
|
||||
if (jvmci_compiler != nullptr) {
|
||||
if (strncmp(jvmci_compiler, "graal", strlen("graal")) != 0) {
|
||||
jio_fprintf(defaultStream::error_stream(),
|
||||
"Value of jvmci.Compiler incompatible with +UseGraalJIT: %s", jvmci_compiler);
|
||||
return JNI_ERR;
|
||||
}
|
||||
} else if (!add_property("jvmci.Compiler=graal")) {
|
||||
return JNI_ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
// Just continue, since "-XX:+EnableJVMCIProduct" or "-XX:+UseGraalJIT" has been specified before
|
||||
if (EnableJVMCIProduct) {
|
||||
continue;
|
||||
}
|
||||
JVMFlag *jvmciFlag = JVMFlag::find_flag("EnableJVMCIProduct");
|
||||
// Allow this flag if it has been unlocked.
|
||||
if (jvmciFlag != nullptr && jvmciFlag->is_unlocked()) {
|
||||
if (!JVMCIGlobals::enable_jvmci_product_mode(origin)) {
|
||||
if (!JVMCIGlobals::enable_jvmci_product_mode(origin, use_graal_jit)) {
|
||||
jio_fprintf(defaultStream::error_stream(),
|
||||
"Unable to enable JVMCI in product mode");
|
||||
return JNI_ERR;
|
||||
}
|
||||
}
|
||||
// The flag was locked so process normally to report that error
|
||||
else if (!process_argument("EnableJVMCIProduct", args->ignoreUnrecognized, origin)) {
|
||||
else if (!process_argument(use_graal_jit ? "UseGraalJIT" : "EnableJVMCIProduct", args->ignoreUnrecognized, origin)) {
|
||||
return JNI_EINVAL;
|
||||
}
|
||||
#endif // INCLUDE_JVMCI
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -50,6 +50,14 @@ public class TestEnableJVMCIProduct {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length != 0) {
|
||||
// Called as subprocess. Print system properties named by
|
||||
// `args` and then exit.
|
||||
for (String arg : args) {
|
||||
System.out.printf("%s=%s%n", arg, System.getProperty(arg));
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Test EnableJVMCIProduct without any other explicit JVMCI option
|
||||
test("-XX:-PrintWarnings",
|
||||
new Expectation("EnableJVMCI", "true", "default"),
|
||||
@ -67,24 +75,33 @@ public class TestEnableJVMCIProduct {
|
||||
new Expectation("EnableJVMCI", "false", "command line"),
|
||||
new Expectation("UseJVMCICompiler", "false", "default"));
|
||||
test("-XX:+EnableJVMCIProduct",
|
||||
new Expectation("EnableJVMCIProduct", "true", "command line"),
|
||||
new Expectation("EnableJVMCIProduct", "true", "(?:command line|jimage)"),
|
||||
new Expectation("EnableJVMCI", "true", "default"),
|
||||
new Expectation("UseJVMCICompiler", "true", "default"));
|
||||
}
|
||||
|
||||
static void test(String explicitFlag, Expectation... expectations) throws Exception {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||||
"-XX:+UnlockExperimentalVMOptions", "-XX:+EnableJVMCIProduct", "-XX:-UnlockExperimentalVMOptions",
|
||||
explicitFlag,
|
||||
"-XX:+PrintFlagsFinal", "-version");
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
for (Expectation expectation : expectations) {
|
||||
output.stdoutShouldMatch(expectation.pattern);
|
||||
}
|
||||
if (output.getExitValue() != 0) {
|
||||
// This should only happen when JVMCI compilation is requested and the VM has no
|
||||
// JVMCI compiler (e.g. Graal is not included in the build)
|
||||
output.stdoutShouldMatch("No JVMCI compiler found");
|
||||
String[] flags = {"-XX:+EnableJVMCIProduct", "-XX:+UseGraalJIT"};
|
||||
String cwd = System.getProperty("user.dir");
|
||||
for (String flag : flags) {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||||
"-XX:+UnlockExperimentalVMOptions", flag, "-XX:-UnlockExperimentalVMOptions",
|
||||
explicitFlag,
|
||||
"-XX:+PrintFlagsFinal",
|
||||
"--class-path=" + System.getProperty("java.class.path"),
|
||||
"TestEnableJVMCIProduct", "jvmci.Compiler");
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
for (Expectation expectation : expectations) {
|
||||
output.stdoutShouldMatch(expectation.pattern);
|
||||
}
|
||||
if (flag.equals("-XX:+UseGraalJIT")) {
|
||||
output.shouldContain("jvmci.Compiler=graal");
|
||||
}
|
||||
if (output.getExitValue() != 0) {
|
||||
// This should only happen when JVMCI compilation is requested and the VM has no
|
||||
// JVMCI compiler (e.g. Graal is not included in the build)
|
||||
output.stdoutShouldMatch("No JVMCI compiler found");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user