From 171703a808df5d48e311207bd586df2e21ab93f7 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Tue, 13 May 2025 23:34:24 +0200 Subject: [PATCH 01/11] --add-modules=jdk.internal.vm.ci implies -XX:+EnableJVMCI --- src/hotspot/share/jvmci/jvmci_globals.hpp | 3 +- src/hotspot/share/runtime/arguments.cpp | 26 +++++++++++++---- src/hotspot/share/runtime/arguments.hpp | 4 +++ .../jvmci/TestEnableJVMCIProduct.java | 29 ++++++++++++++----- .../jvmci/TestInvalidJVMCIOption.java | 1 + .../jvmci/TestJVMCIPrintProperties.java | 1 + .../jvmci/TestJVMCISavedProperties.java | 2 +- .../compiler/jvmci/TestValidateModules.java | 2 +- .../jvmci/compilerToVM/GetFlagValueTest.java | 2 +- .../hotspot/test/TestHotSpotJVMCIRuntime.java | 2 +- 10 files changed, 54 insertions(+), 18 deletions(-) diff --git a/src/hotspot/share/jvmci/jvmci_globals.hpp b/src/hotspot/share/jvmci/jvmci_globals.hpp index 5bcead9ff7b32..439b0c91475db 100644 --- a/src/hotspot/share/jvmci/jvmci_globals.hpp +++ b/src/hotspot/share/jvmci/jvmci_globals.hpp @@ -45,7 +45,8 @@ class fileStream; constraint) \ \ product(bool, EnableJVMCI, false, EXPERIMENTAL, \ - "Enable JVMCI. Defaults to true if UseJVMCICompiler is true.") \ + "Enable JVMCI. Defaults to true if UseJVMCICompiler is true or " \ + "jdk.internal.vm.ci is added to the root set with --add-modules.")\ \ product(bool, UseGraalJIT, false, EXPERIMENTAL, \ "Select the Graal JVMCI compiler. This is an alias for: " \ diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 69d37a11e45ab..27afa9c74f408 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -85,6 +85,9 @@ int Arguments::_num_jvm_flags = 0; char** Arguments::_jvm_args_array = nullptr; int Arguments::_num_jvm_args = 0; unsigned int Arguments::_addmods_count = 0; +#if INCLUDE_JVMCI +bool Arguments::_jvmci_module_added = false; +#endif char* Arguments::_java_command = nullptr; SystemProperty* Arguments::_system_properties = nullptr; size_t Arguments::_conservative_max_heap_alignment = 0; @@ -1798,13 +1801,13 @@ bool Arguments::check_vm_args_consistency() { status = CompilerConfig::check_args_consistency(status); #if INCLUDE_JVMCI if (status && EnableJVMCI) { + if (ClassLoader::is_module_observable("jdk.internal.vm.ci") && !UseJVMCINativeLibrary && !_jvmci_module_added) { + jio_fprintf(defaultStream::error_stream(), + "'+EnableJVMCI' requires '--add-modules=jdk.internal.vm.ci' when UseJVMCINativeLibrary is false\n"); + return false; + } PropertyList_unique_add(&_system_properties, "jdk.internal.vm.ci.enabled", "true", AddProperty, UnwriteableProperty, InternalProperty); - if (ClassLoader::is_module_observable("jdk.internal.vm.ci")) { - if (!create_numbered_module_property("jdk.module.addmods", "jdk.internal.vm.ci", _addmods_count++)) { - return false; - } - } } #endif @@ -2247,6 +2250,19 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, JVMFlagOrigin if (!create_numbered_module_property("jdk.module.addmods", tail, _addmods_count++)) { return JNI_ENOMEM; } +#if INCLUDE_JVMCI + if (!_jvmci_module_added) { + const char *jvmci_module = strstr(tail, "jdk.internal.vm.ci"); + if (jvmci_module != nullptr) { + char before = *(jvmci_module - 1); + char after = *(jvmci_module + strlen("jdk.internal.vm.ci")); + if ((before == '=' || before == ',') && (after == '\0' || after == ',')) { + FLAG_SET_DEFAULT(EnableJVMCI, true); + _jvmci_module_added = true; + } + } + } +#endif } else if (match_option(option, "--enable-native-access=", &tail)) { if (!create_numbered_module_property("jdk.module.enable.native.access", tail, enable_native_access_count++)) { return JNI_ENOMEM; diff --git a/src/hotspot/share/runtime/arguments.hpp b/src/hotspot/share/runtime/arguments.hpp index a18996f85e805..69edd124bad6a 100644 --- a/src/hotspot/share/runtime/arguments.hpp +++ b/src/hotspot/share/runtime/arguments.hpp @@ -197,6 +197,10 @@ class Arguments : AllStatic { static char* _java_command; // number of unique modules specified in the --add-modules option static unsigned int _addmods_count; + // number of unique modules specified in the --add-modules option +#if INCLUDE_JVMCI + static bool _jvmci_module_added; +#endif // Property list static SystemProperty* _system_properties; diff --git a/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java b/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java index ed3e0920bf4d2..63055004c96da 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java @@ -64,23 +64,35 @@ public static void main(String[] args) throws Exception { .collect(Collectors.joining(","))); return; } + + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( + "-XX:+UnlockExperimentalVMOptions", "-XX:+UseJVMCICompiler", + "-XX:+PrintFlagsFinal", "--version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + boolean useJVMCINativeLibrary = output.firstMatch("bool +UseJVMCINativeLibrary += true") != null; + // If libjvmci is not in use, then the JVMCI module must be explicitly + // added with --add-modules=jdk.internal.vm.ci + String addJVMCIModule = useJVMCINativeLibrary ? + "--add-modules=java.base" : // effectively a nop + "--add-modules=jdk.internal.vm.ci"; + // Test EnableJVMCIProduct without any other explicit JVMCI option - test("-XX:-PrintWarnings", + test("-XX:-PrintWarnings", addJVMCIModule, new Expectation("EnableJVMCI", "true", "default"), new Expectation("UseJVMCICompiler", "true", "default")); - test("-XX:+UseJVMCICompiler", + test("-XX:+UseJVMCICompiler", addJVMCIModule, new Expectation("EnableJVMCI", "true", "default"), new Expectation("UseJVMCICompiler", "true", "command line")); - test("-XX:-UseJVMCICompiler", + test("-XX:-UseJVMCICompiler", addJVMCIModule, new Expectation("EnableJVMCI", "true", "default"), new Expectation("UseJVMCICompiler", "false", "command line")); - test("-XX:+EnableJVMCI", + test("-XX:+EnableJVMCI", addJVMCIModule, new Expectation("EnableJVMCI", "true", "command line"), new Expectation("UseJVMCICompiler", "true", "default")); - test("-XX:-EnableJVMCI", + test("-XX:-EnableJVMCI", addJVMCIModule, new Expectation("EnableJVMCI", "false", "command line"), new Expectation("UseJVMCICompiler", "false", "default")); - test("-XX:+EnableJVMCIProduct", + test("-XX:+EnableJVMCIProduct", addJVMCIModule, new Expectation("EnableJVMCIProduct", "true", "(?:command line|jimage)"), new Expectation("EnableJVMCI", "true", "default"), new Expectation("UseJVMCICompiler", "true", "default")); @@ -88,13 +100,14 @@ public static void main(String[] args) throws Exception { static int id; - static void test(String explicitFlag, Expectation... expectations) throws Exception { + static void test(String explicitFlag, String addJVMCIModule, Expectation... expectations) throws Exception { String[] flags = {"-XX:+EnableJVMCIProduct", "-XX:+UseGraalJIT"}; String cwd = System.getProperty("user.dir"); + for (String flag : flags) { Path propsPath = Path.of("props." + id++); ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UnlockExperimentalVMOptions", flag, "-XX:-UnlockExperimentalVMOptions", + "-XX:+UnlockExperimentalVMOptions", addJVMCIModule, flag, "-XX:-UnlockExperimentalVMOptions", explicitFlag, "-XX:+PrintFlagsFinal", "--class-path=" + System.getProperty("java.class.path"), diff --git a/test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java b/test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java index 0758fd24df034..0b93a21185b9f 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java @@ -41,6 +41,7 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", "-XX:+EagerJVMCI", + "--add-modules=jdk.internal.vm.ci", "-XX:+UseJVMCICompiler", "-Djvmci.XXXXXXXXX=true"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java b/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java index e58bc4df169bc..dad947e43742e 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java @@ -44,6 +44,7 @@ public static void main(String[] args) throws Exception { static void test(String enableFlag) throws Exception { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", + "--add-modules=jdk.internal.vm.ci", enableFlag, "-Djvmci.Compiler=null", "-XX:+JVMCIPrintProperties"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java b/test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java index 6d0f87fa0f51d..688a4e29199db 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java @@ -48,7 +48,7 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", "-XX:+EagerJVMCI", - "-XX:+EnableJVMCI", + "--add-modules=jdk.internal.vm.ci", "-Ddebug.jvmci.PrintSavedProperties=true", "-Dapp1.propX=true", "-Dapp2.propY=SomeStringValue", diff --git a/test/hotspot/jtreg/compiler/jvmci/TestValidateModules.java b/test/hotspot/jtreg/compiler/jvmci/TestValidateModules.java index 1e3dc23673b16..7834227c554ca 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestValidateModules.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestValidateModules.java @@ -36,7 +36,7 @@ public class TestValidateModules { public static void main(String... args) throws Exception { ProcessTools.executeTestJava("-XX:+UnlockExperimentalVMOptions", - "-XX:+EnableJVMCI", + "--add-modules=jdk.internal.vm.ci", "--validate-modules", "--list-modules") .outputTo(System.out) diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java index f29c10a34f876..28d6e109a1270 100644 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java @@ -65,7 +65,7 @@ public static void main(String[] args) throws Exception { pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", - "-XX:+EnableJVMCI", + "--add-modules=jdk.internal.vm.ci", "-XX:+PrintFlagsFinal", "-version"); out = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java index e5d1da81309af..5dbc89e323cdb 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java @@ -169,7 +169,7 @@ public void jniEnomemTest() throws Exception { for (String name : names) { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", - "-XX:+EnableJVMCI", + "--add-modules=jdk.internal.vm.ci", "-XX:-UseJVMCICompiler", "-XX:+UseJVMCINativeLibrary", "-Dtest.jvmci.forceEnomemOnLibjvmciInit=true", From 0e8773e10b0b4f4a8bb624b56b2f083ca8e4a3c7 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Thu, 15 May 2025 23:24:47 +0200 Subject: [PATCH 02/11] added comment in check_vm_args_consistency --- src/hotspot/share/runtime/arguments.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 27afa9c74f408..ad0532f017b6b 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -1801,6 +1801,10 @@ bool Arguments::check_vm_args_consistency() { status = CompilerConfig::check_args_consistency(status); #if INCLUDE_JVMCI if (status && EnableJVMCI) { + // libjvmci doesn't require resolving jdk.internal.vm.ci as it is + // compiled into the libjvmci image itself. Without libjvmci, there + // is no other representation of the jdk.internal.vm.ci module + // so it needs to be added to the root module set. if (ClassLoader::is_module_observable("jdk.internal.vm.ci") && !UseJVMCINativeLibrary && !_jvmci_module_added) { jio_fprintf(defaultStream::error_stream(), "'+EnableJVMCI' requires '--add-modules=jdk.internal.vm.ci' when UseJVMCINativeLibrary is false\n"); From 343603318d7be4907cb8d9db581be58729fb41c0 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Fri, 16 May 2025 14:53:44 +0200 Subject: [PATCH 03/11] resolve jdk.internal.vm.ci if +EnableJVMCI and -UseJVMCINativeLibrary --- src/hotspot/share/jvmci/jvmci_globals.hpp | 9 ++++-- src/hotspot/share/runtime/arguments.cpp | 8 ++--- .../jvmci/TestEnableJVMCIProduct.java | 29 +++++-------------- .../jvmci/TestInvalidJVMCIOption.java | 1 - .../jvmci/TestJVMCIPrintProperties.java | 1 - .../jvmci/TestJVMCISavedProperties.java | 2 +- .../compiler/jvmci/TestValidateModules.java | 2 +- .../jvmci/compilerToVM/GetFlagValueTest.java | 2 +- .../hotspot/test/TestHotSpotJVMCIRuntime.java | 2 +- 9 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/hotspot/share/jvmci/jvmci_globals.hpp b/src/hotspot/share/jvmci/jvmci_globals.hpp index 439b0c91475db..99267b8c8bb8d 100644 --- a/src/hotspot/share/jvmci/jvmci_globals.hpp +++ b/src/hotspot/share/jvmci/jvmci_globals.hpp @@ -45,8 +45,13 @@ class fileStream; constraint) \ \ product(bool, EnableJVMCI, false, EXPERIMENTAL, \ - "Enable JVMCI. Defaults to true if UseJVMCICompiler is true or " \ - "jdk.internal.vm.ci is added to the root set with --add-modules.")\ + "Enable JVMCI support in the VM. " \ + "Defaults to true if UseJVMCICompiler is true or " \ + "--add-modules=jdk.internal.vm.ci was specified. " \ + "If true and UseJVMCINativeLibrary is false (i.e. libjvmci is " \ + "not available or not selected), the behavior of adding the " \ + "jdk.internal.vm.ci module is triggered, as if the " \ + "--add-modules=jdk.internal.vm.ci option was specified.") \ \ product(bool, UseGraalJIT, false, EXPERIMENTAL, \ "Select the Graal JVMCI compiler. This is an alias for: " \ diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index ad0532f017b6b..1aa4592ca1410 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -1805,10 +1805,10 @@ bool Arguments::check_vm_args_consistency() { // compiled into the libjvmci image itself. Without libjvmci, there // is no other representation of the jdk.internal.vm.ci module // so it needs to be added to the root module set. - if (ClassLoader::is_module_observable("jdk.internal.vm.ci") && !UseJVMCINativeLibrary && !_jvmci_module_added) { - jio_fprintf(defaultStream::error_stream(), - "'+EnableJVMCI' requires '--add-modules=jdk.internal.vm.ci' when UseJVMCINativeLibrary is false\n"); - return false; + if (!UseJVMCINativeLibrary && ClassLoader::is_module_observable("jdk.internal.vm.ci") && !_jvmci_module_added) { + if (!create_numbered_module_property("jdk.module.addmods", "jdk.internal.vm.ci", _addmods_count++)) { + return false; + } } PropertyList_unique_add(&_system_properties, "jdk.internal.vm.ci.enabled", "true", AddProperty, UnwriteableProperty, InternalProperty); diff --git a/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java b/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java index 63055004c96da..ed3e0920bf4d2 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java @@ -64,35 +64,23 @@ public static void main(String[] args) throws Exception { .collect(Collectors.joining(","))); return; } - - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UnlockExperimentalVMOptions", "-XX:+UseJVMCICompiler", - "-XX:+PrintFlagsFinal", "--version"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - boolean useJVMCINativeLibrary = output.firstMatch("bool +UseJVMCINativeLibrary += true") != null; - // If libjvmci is not in use, then the JVMCI module must be explicitly - // added with --add-modules=jdk.internal.vm.ci - String addJVMCIModule = useJVMCINativeLibrary ? - "--add-modules=java.base" : // effectively a nop - "--add-modules=jdk.internal.vm.ci"; - // Test EnableJVMCIProduct without any other explicit JVMCI option - test("-XX:-PrintWarnings", addJVMCIModule, + test("-XX:-PrintWarnings", new Expectation("EnableJVMCI", "true", "default"), new Expectation("UseJVMCICompiler", "true", "default")); - test("-XX:+UseJVMCICompiler", addJVMCIModule, + test("-XX:+UseJVMCICompiler", new Expectation("EnableJVMCI", "true", "default"), new Expectation("UseJVMCICompiler", "true", "command line")); - test("-XX:-UseJVMCICompiler", addJVMCIModule, + test("-XX:-UseJVMCICompiler", new Expectation("EnableJVMCI", "true", "default"), new Expectation("UseJVMCICompiler", "false", "command line")); - test("-XX:+EnableJVMCI", addJVMCIModule, + test("-XX:+EnableJVMCI", new Expectation("EnableJVMCI", "true", "command line"), new Expectation("UseJVMCICompiler", "true", "default")); - test("-XX:-EnableJVMCI", addJVMCIModule, + test("-XX:-EnableJVMCI", new Expectation("EnableJVMCI", "false", "command line"), new Expectation("UseJVMCICompiler", "false", "default")); - test("-XX:+EnableJVMCIProduct", addJVMCIModule, + test("-XX:+EnableJVMCIProduct", new Expectation("EnableJVMCIProduct", "true", "(?:command line|jimage)"), new Expectation("EnableJVMCI", "true", "default"), new Expectation("UseJVMCICompiler", "true", "default")); @@ -100,14 +88,13 @@ public static void main(String[] args) throws Exception { static int id; - static void test(String explicitFlag, String addJVMCIModule, Expectation... expectations) throws Exception { + static void test(String explicitFlag, Expectation... expectations) throws Exception { String[] flags = {"-XX:+EnableJVMCIProduct", "-XX:+UseGraalJIT"}; String cwd = System.getProperty("user.dir"); - for (String flag : flags) { Path propsPath = Path.of("props." + id++); ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UnlockExperimentalVMOptions", addJVMCIModule, flag, "-XX:-UnlockExperimentalVMOptions", + "-XX:+UnlockExperimentalVMOptions", flag, "-XX:-UnlockExperimentalVMOptions", explicitFlag, "-XX:+PrintFlagsFinal", "--class-path=" + System.getProperty("java.class.path"), diff --git a/test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java b/test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java index 0b93a21185b9f..0758fd24df034 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java @@ -41,7 +41,6 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", "-XX:+EagerJVMCI", - "--add-modules=jdk.internal.vm.ci", "-XX:+UseJVMCICompiler", "-Djvmci.XXXXXXXXX=true"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java b/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java index dad947e43742e..e58bc4df169bc 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java @@ -44,7 +44,6 @@ public static void main(String[] args) throws Exception { static void test(String enableFlag) throws Exception { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", - "--add-modules=jdk.internal.vm.ci", enableFlag, "-Djvmci.Compiler=null", "-XX:+JVMCIPrintProperties"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java b/test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java index 688a4e29199db..6d0f87fa0f51d 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java @@ -48,7 +48,7 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", "-XX:+EagerJVMCI", - "--add-modules=jdk.internal.vm.ci", + "-XX:+EnableJVMCI", "-Ddebug.jvmci.PrintSavedProperties=true", "-Dapp1.propX=true", "-Dapp2.propY=SomeStringValue", diff --git a/test/hotspot/jtreg/compiler/jvmci/TestValidateModules.java b/test/hotspot/jtreg/compiler/jvmci/TestValidateModules.java index 7834227c554ca..1e3dc23673b16 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestValidateModules.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestValidateModules.java @@ -36,7 +36,7 @@ public class TestValidateModules { public static void main(String... args) throws Exception { ProcessTools.executeTestJava("-XX:+UnlockExperimentalVMOptions", - "--add-modules=jdk.internal.vm.ci", + "-XX:+EnableJVMCI", "--validate-modules", "--list-modules") .outputTo(System.out) diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java index 28d6e109a1270..f29c10a34f876 100644 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java @@ -65,7 +65,7 @@ public static void main(String[] args) throws Exception { pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", - "--add-modules=jdk.internal.vm.ci", + "-XX:+EnableJVMCI", "-XX:+PrintFlagsFinal", "-version"); out = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java index 5dbc89e323cdb..e5d1da81309af 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java @@ -169,7 +169,7 @@ public void jniEnomemTest() throws Exception { for (String name : names) { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", - "--add-modules=jdk.internal.vm.ci", + "-XX:+EnableJVMCI", "-XX:-UseJVMCICompiler", "-XX:+UseJVMCINativeLibrary", "-Dtest.jvmci.forceEnomemOnLibjvmciInit=true", From cc49ed057ba954c6930268512083bf5b3b2fe3ed Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Fri, 16 May 2025 16:24:00 +0200 Subject: [PATCH 04/11] fix TestHotSpotJVMCIRuntime --- .../src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java | 1 + 1 file changed, 1 insertion(+) diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java index e5d1da81309af..aa6d62774720e 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java @@ -170,6 +170,7 @@ public void jniEnomemTest() throws Exception { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", "-XX:+EnableJVMCI", + "--add-modules=jdk.internal.vm.ci", "-XX:-UseJVMCICompiler", "-XX:+UseJVMCINativeLibrary", "-Dtest.jvmci.forceEnomemOnLibjvmciInit=true", From 7b302382c59f688e2bb1e9c00e92655277ecf566 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Fri, 16 May 2025 16:24:32 +0200 Subject: [PATCH 05/11] removed use of jdk.internal.vm.ci.enabled property --- src/hotspot/share/runtime/arguments.cpp | 2 -- .../jdk/vm/ci/services/JVMCIServiceLocator.java | 2 -- .../share/classes/jdk/vm/ci/services/Services.java | 13 ------------- 3 files changed, 17 deletions(-) diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 1aa4592ca1410..32f51ed2beb8d 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -1810,8 +1810,6 @@ bool Arguments::check_vm_args_consistency() { return false; } } - PropertyList_unique_add(&_system_properties, "jdk.internal.vm.ci.enabled", "true", - AddProperty, UnwriteableProperty, InternalProperty); } #endif diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/JVMCIServiceLocator.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/JVMCIServiceLocator.java index 265b8c24f3e23..d5ff0bba9b300 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/JVMCIServiceLocator.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/JVMCIServiceLocator.java @@ -59,7 +59,6 @@ private JVMCIServiceLocator(Void ignore) { */ protected JVMCIServiceLocator() { this(checkPermission()); - Services.checkJVMCIEnabled(); Services.openJVMCITo(getClass().getModule()); } @@ -85,7 +84,6 @@ protected JVMCIServiceLocator() { * {@link JVMCIPermission} */ public static List getProviders(Class service) { - Services.checkJVMCIEnabled(); @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/Services.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/Services.java index d16a788eb1476..22f8eec7d120f 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/Services.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/Services.java @@ -64,17 +64,6 @@ private Services() { */ private static volatile Map savedProperties; - static final boolean JVMCI_ENABLED = Boolean.parseBoolean(VM.getSavedProperties().get("jdk.internal.vm.ci.enabled")); - - /** - * Checks that JVMCI is enabled in the VM and throws an error if it isn't. - */ - static void checkJVMCIEnabled() { - if (!JVMCI_ENABLED) { - throw new Error("The EnableJVMCI VM option must be true (i.e., -XX:+EnableJVMCI) to use JVMCI"); - } - } - /** * Gets an unmodifiable copy of the system properties as of VM startup. * @@ -84,7 +73,6 @@ static void checkJVMCIEnabled() { * on the command line are ignored. */ public static Map getSavedProperties() { - checkJVMCIEnabled(); if (savedProperties == null) { synchronized (Services.class) { if (savedProperties == null) { @@ -113,7 +101,6 @@ public static String getSavedProperty(String name) { * Causes the JVMCI subsystem to be initialized if it isn't already initialized. */ public static void initializeJVMCI() { - checkJVMCIEnabled(); try { Class.forName("jdk.vm.ci.runtime.JVMCI"); } catch (ClassNotFoundException e) { From 3cdef586f6617251a70feb432701d8fc34f0625d Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Fri, 16 May 2025 16:38:18 +0200 Subject: [PATCH 06/11] fixed comment --- src/hotspot/share/runtime/arguments.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/runtime/arguments.hpp b/src/hotspot/share/runtime/arguments.hpp index 69edd124bad6a..55667df2c591f 100644 --- a/src/hotspot/share/runtime/arguments.hpp +++ b/src/hotspot/share/runtime/arguments.hpp @@ -197,8 +197,8 @@ class Arguments : AllStatic { static char* _java_command; // number of unique modules specified in the --add-modules option static unsigned int _addmods_count; - // number of unique modules specified in the --add-modules option #if INCLUDE_JVMCI + // was jdk.internal.vm.ci module specified in the --add-modules option? static bool _jvmci_module_added; #endif From 1fe56b41ccfe00c91623828f9821d57d94cc05f2 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Fri, 16 May 2025 18:32:10 +0200 Subject: [PATCH 07/11] improved error message --- src/hotspot/share/jvmci/jvmciCompiler.cpp | 2 +- src/hotspot/share/jvmci/jvmciRuntime.cpp | 6 +++--- src/hotspot/share/jvmci/jvmciRuntime.hpp | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/hotspot/share/jvmci/jvmciCompiler.cpp b/src/hotspot/share/jvmci/jvmciCompiler.cpp index 38bf9c438e7d0..fb860c26e8ac2 100644 --- a/src/hotspot/share/jvmci/jvmciCompiler.cpp +++ b/src/hotspot/share/jvmci/jvmciCompiler.cpp @@ -48,7 +48,7 @@ JVMCICompiler::JVMCICompiler() : AbstractCompiler(compiler_jvmci) { JVMCICompiler* JVMCICompiler::instance(bool require_non_null, TRAPS) { if (!EnableJVMCI) { - THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVMCI is not enabled") + THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), JAVA_NOT_ENABLED_ERROR_MESSAGE) } if (_instance == nullptr && require_non_null) { THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "The JVMCI compiler instance has not been created"); diff --git a/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/hotspot/share/jvmci/jvmciRuntime.cpp index 6f1fa52576e41..27c12ede8dcb4 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.cpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp @@ -720,7 +720,7 @@ JRT_END JVM_ENTRY_NO_ENV(jobject, JVM_GetJVMCIRuntime(JNIEnv *libjvmciOrHotspotEnv, jclass c)) JVMCIENV_FROM_JNI(thread, libjvmciOrHotspotEnv); if (!EnableJVMCI) { - JVMCI_THROW_MSG_NULL(InternalError, "JVMCI is not enabled"); + JVMCI_THROW_MSG_NULL(InternalError, JAVA_NOT_ENABLED_ERROR_MESSAGE); } JVMCIENV->runtime()->initialize_HotSpotJVMCIRuntime(JVMCI_CHECK_NULL); JVMCIObject runtime = JVMCIENV->runtime()->get_HotSpotJVMCIRuntime(JVMCI_CHECK_NULL); @@ -732,7 +732,7 @@ JVM_END JVM_ENTRY_NO_ENV(jlong, JVM_ReadSystemPropertiesInfo(JNIEnv *env, jclass c, jintArray offsets_handle)) JVMCIENV_FROM_JNI(thread, env); if (!EnableJVMCI) { - JVMCI_THROW_MSG_0(InternalError, "JVMCI is not enabled"); + JVMCI_THROW_MSG_0(InternalError, JAVA_NOT_ENABLED_ERROR_MESSAGE); } JVMCIPrimitiveArray offsets = JVMCIENV->wrap(offsets_handle); JVMCIENV->put_int_at(offsets, 0, SystemProperty::next_offset_in_bytes()); @@ -1515,7 +1515,7 @@ JVM_ENTRY_NO_ENV(void, JVM_RegisterJVMCINatives(JNIEnv *libjvmciOrHotspotEnv, jc JVMCIENV_FROM_JNI(thread, libjvmciOrHotspotEnv); if (!EnableJVMCI) { - JVMCI_THROW_MSG(InternalError, "JVMCI is not enabled"); + JVMCI_THROW_MSG(InternalError, JAVA_NOT_ENABLED_ERROR_MESSAGE); } JVMCIENV->runtime()->initialize(JVMCIENV); diff --git a/src/hotspot/share/jvmci/jvmciRuntime.hpp b/src/hotspot/share/jvmci/jvmciRuntime.hpp index 884d11f792e2a..f1f4d5b06376c 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.hpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.hpp @@ -35,6 +35,8 @@ #include "gc/g1/g1CardTable.hpp" #endif // INCLUDE_G1GC +#define JAVA_NOT_ENABLED_ERROR_MESSAGE "JVMCI is not enabled. Must specify '--add-modules=jdk.internal.vm.ci' or '-XX:+EnableJVMCI' to the java launcher." + class JVMCIEnv; class JVMCICompiler; class JVMCICompileState; From cd615efdfa1c6fcef122cd4c286f5853308033ce Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Fri, 16 May 2025 22:45:08 +0200 Subject: [PATCH 08/11] JAVA_NOT_ENABLED_ERROR_MESSAGE -> JVMCI_NOT_ENABLED_ERROR_MESSAGE --- src/hotspot/share/jvmci/jvmciCompiler.cpp | 2 +- src/hotspot/share/jvmci/jvmciRuntime.cpp | 6 +++--- src/hotspot/share/jvmci/jvmciRuntime.hpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hotspot/share/jvmci/jvmciCompiler.cpp b/src/hotspot/share/jvmci/jvmciCompiler.cpp index fb860c26e8ac2..cf70e251b1429 100644 --- a/src/hotspot/share/jvmci/jvmciCompiler.cpp +++ b/src/hotspot/share/jvmci/jvmciCompiler.cpp @@ -48,7 +48,7 @@ JVMCICompiler::JVMCICompiler() : AbstractCompiler(compiler_jvmci) { JVMCICompiler* JVMCICompiler::instance(bool require_non_null, TRAPS) { if (!EnableJVMCI) { - THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), JAVA_NOT_ENABLED_ERROR_MESSAGE) + THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), JVMCI_NOT_ENABLED_ERROR_MESSAGE) } if (_instance == nullptr && require_non_null) { THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "The JVMCI compiler instance has not been created"); diff --git a/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/hotspot/share/jvmci/jvmciRuntime.cpp index 27c12ede8dcb4..f02ef57de3486 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.cpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp @@ -720,7 +720,7 @@ JRT_END JVM_ENTRY_NO_ENV(jobject, JVM_GetJVMCIRuntime(JNIEnv *libjvmciOrHotspotEnv, jclass c)) JVMCIENV_FROM_JNI(thread, libjvmciOrHotspotEnv); if (!EnableJVMCI) { - JVMCI_THROW_MSG_NULL(InternalError, JAVA_NOT_ENABLED_ERROR_MESSAGE); + JVMCI_THROW_MSG_NULL(InternalError, JVMCI_NOT_ENABLED_ERROR_MESSAGE); } JVMCIENV->runtime()->initialize_HotSpotJVMCIRuntime(JVMCI_CHECK_NULL); JVMCIObject runtime = JVMCIENV->runtime()->get_HotSpotJVMCIRuntime(JVMCI_CHECK_NULL); @@ -732,7 +732,7 @@ JVM_END JVM_ENTRY_NO_ENV(jlong, JVM_ReadSystemPropertiesInfo(JNIEnv *env, jclass c, jintArray offsets_handle)) JVMCIENV_FROM_JNI(thread, env); if (!EnableJVMCI) { - JVMCI_THROW_MSG_0(InternalError, JAVA_NOT_ENABLED_ERROR_MESSAGE); + JVMCI_THROW_MSG_0(InternalError, JVMCI_NOT_ENABLED_ERROR_MESSAGE); } JVMCIPrimitiveArray offsets = JVMCIENV->wrap(offsets_handle); JVMCIENV->put_int_at(offsets, 0, SystemProperty::next_offset_in_bytes()); @@ -1515,7 +1515,7 @@ JVM_ENTRY_NO_ENV(void, JVM_RegisterJVMCINatives(JNIEnv *libjvmciOrHotspotEnv, jc JVMCIENV_FROM_JNI(thread, libjvmciOrHotspotEnv); if (!EnableJVMCI) { - JVMCI_THROW_MSG(InternalError, JAVA_NOT_ENABLED_ERROR_MESSAGE); + JVMCI_THROW_MSG(InternalError, JVMCI_NOT_ENABLED_ERROR_MESSAGE); } JVMCIENV->runtime()->initialize(JVMCIENV); diff --git a/src/hotspot/share/jvmci/jvmciRuntime.hpp b/src/hotspot/share/jvmci/jvmciRuntime.hpp index f1f4d5b06376c..01756f0ad41e4 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.hpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.hpp @@ -35,7 +35,7 @@ #include "gc/g1/g1CardTable.hpp" #endif // INCLUDE_G1GC -#define JAVA_NOT_ENABLED_ERROR_MESSAGE "JVMCI is not enabled. Must specify '--add-modules=jdk.internal.vm.ci' or '-XX:+EnableJVMCI' to the java launcher." +#define JVMCI_NOT_ENABLED_ERROR_MESSAGE "JVMCI is not enabled. Must specify '--add-modules=jdk.internal.vm.ci' or '-XX:+EnableJVMCI' to the java launcher." class JVMCIEnv; class JVMCICompiler; From d9223afbeebe798dad3e9d18706e0037237276bb Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Fri, 16 May 2025 22:46:48 +0200 Subject: [PATCH 09/11] load the JVMCI module if +EnableJVMCI is set on the command line --- src/hotspot/share/jvmci/jvmci_globals.hpp | 7 +++---- src/hotspot/share/runtime/arguments.cpp | 8 +++----- .../jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java | 1 - 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/hotspot/share/jvmci/jvmci_globals.hpp b/src/hotspot/share/jvmci/jvmci_globals.hpp index 99267b8c8bb8d..0f32cbab2053d 100644 --- a/src/hotspot/share/jvmci/jvmci_globals.hpp +++ b/src/hotspot/share/jvmci/jvmci_globals.hpp @@ -48,10 +48,9 @@ class fileStream; "Enable JVMCI support in the VM. " \ "Defaults to true if UseJVMCICompiler is true or " \ "--add-modules=jdk.internal.vm.ci was specified. " \ - "If true and UseJVMCINativeLibrary is false (i.e. libjvmci is " \ - "not available or not selected), the behavior of adding the " \ - "jdk.internal.vm.ci module is triggered, as if the " \ - "--add-modules=jdk.internal.vm.ci option was specified.") \ + "If explicity set to true on the command line OR defaulted to " \ + "true by UseJVMCICompiler and libjvmci is not enabled, the " \ + "behavior --add-modules=jdk.internal.vm.ci is triggered.") \ \ product(bool, UseGraalJIT, false, EXPERIMENTAL, \ "Select the Graal JVMCI compiler. This is an alias for: " \ diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 32f51ed2beb8d..2223666cdb1d2 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -1801,11 +1801,9 @@ bool Arguments::check_vm_args_consistency() { status = CompilerConfig::check_args_consistency(status); #if INCLUDE_JVMCI if (status && EnableJVMCI) { - // libjvmci doesn't require resolving jdk.internal.vm.ci as it is - // compiled into the libjvmci image itself. Without libjvmci, there - // is no other representation of the jdk.internal.vm.ci module - // so it needs to be added to the root module set. - if (!UseJVMCINativeLibrary && ClassLoader::is_module_observable("jdk.internal.vm.ci") && !_jvmci_module_added) { + // Add the JVMCI module if not using libjvmci or EnableJVMCI + // was explicitly set on the command line. + if ((!UseJVMCINativeLibrary || FLAG_IS_CMDLINE(EnableJVMCI)) && ClassLoader::is_module_observable("jdk.internal.vm.ci") && !_jvmci_module_added) { if (!create_numbered_module_property("jdk.module.addmods", "jdk.internal.vm.ci", _addmods_count++)) { return false; } diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java index aa6d62774720e..e5d1da81309af 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java @@ -170,7 +170,6 @@ public void jniEnomemTest() throws Exception { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", "-XX:+EnableJVMCI", - "--add-modules=jdk.internal.vm.ci", "-XX:-UseJVMCICompiler", "-XX:+UseJVMCINativeLibrary", "-Dtest.jvmci.forceEnomemOnLibjvmciInit=true", From 196425f993abd064edb9ac268d7c2e752290cfaf Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Sun, 18 May 2025 21:10:04 +0200 Subject: [PATCH 10/11] load the JVMCI module if +EnableJVMCI is set in the jimage --- src/hotspot/share/jvmci/jvmci_globals.hpp | 10 +++++++--- src/hotspot/share/runtime/arguments.cpp | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/hotspot/share/jvmci/jvmci_globals.hpp b/src/hotspot/share/jvmci/jvmci_globals.hpp index 0f32cbab2053d..a81391af96a44 100644 --- a/src/hotspot/share/jvmci/jvmci_globals.hpp +++ b/src/hotspot/share/jvmci/jvmci_globals.hpp @@ -48,9 +48,13 @@ class fileStream; "Enable JVMCI support in the VM. " \ "Defaults to true if UseJVMCICompiler is true or " \ "--add-modules=jdk.internal.vm.ci was specified. " \ - "If explicity set to true on the command line OR defaulted to " \ - "true by UseJVMCICompiler and libjvmci is not enabled, the " \ - "behavior --add-modules=jdk.internal.vm.ci is triggered.") \ + "The behavior of --add-modules=jdk.internal.vm.ci is triggered " \ + "if any of the following is true: " \ + "1. -XX:+EnableJVMCI is set to true on the command line. " \ + "2. -XX:+EnableJVMCI is set to true by jdk/internal/vm/options " \ + " in the java.base module. " \ + "3. EnableJVMCI is defaulted to true by UseJVMCICompiler and " \ + " libjvmci is not enabled") \ \ product(bool, UseGraalJIT, false, EXPERIMENTAL, \ "Select the Graal JVMCI compiler. This is an alias for: " \ diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 2223666cdb1d2..bf927564abbe3 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -1802,8 +1802,8 @@ bool Arguments::check_vm_args_consistency() { #if INCLUDE_JVMCI if (status && EnableJVMCI) { // Add the JVMCI module if not using libjvmci or EnableJVMCI - // was explicitly set on the command line. - if ((!UseJVMCINativeLibrary || FLAG_IS_CMDLINE(EnableJVMCI)) && ClassLoader::is_module_observable("jdk.internal.vm.ci") && !_jvmci_module_added) { + // was explicitly set on the command line or in the jimage. + if ((!UseJVMCINativeLibrary || FLAG_IS_CMDLINE(EnableJVMCI) || FLAG_IS_JIMAGE_RESOURCE(EnableJVMCI)) && ClassLoader::is_module_observable("jdk.internal.vm.ci") && !_jvmci_module_added) { if (!create_numbered_module_property("jdk.module.addmods", "jdk.internal.vm.ci", _addmods_count++)) { return false; } From b74077f1f5d60bd8c61c1f14912d101d4147cd43 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Mon, 19 May 2025 09:42:52 +0200 Subject: [PATCH 11/11] swapped order of recommended options in error message --- src/hotspot/share/jvmci/jvmciRuntime.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/jvmci/jvmciRuntime.hpp b/src/hotspot/share/jvmci/jvmciRuntime.hpp index 01756f0ad41e4..c35813eb16ffc 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.hpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.hpp @@ -35,7 +35,7 @@ #include "gc/g1/g1CardTable.hpp" #endif // INCLUDE_G1GC -#define JVMCI_NOT_ENABLED_ERROR_MESSAGE "JVMCI is not enabled. Must specify '--add-modules=jdk.internal.vm.ci' or '-XX:+EnableJVMCI' to the java launcher." +#define JVMCI_NOT_ENABLED_ERROR_MESSAGE "JVMCI is not enabled. Must specify '-XX:+EnableJVMCI' or '--add-modules=jdk.internal.vm.ci' to the java launcher." class JVMCIEnv; class JVMCICompiler;