Skip to content

Commit 2bc72fb

Browse files
committed
--add-modules=jdk.internal.vm.ci implies -XX:+EnableJVMCI
1 parent 78ce70b commit 2bc72fb

File tree

10 files changed

+54
-18
lines changed

10 files changed

+54
-18
lines changed

src/hotspot/share/jvmci/jvmci_globals.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class fileStream;
4545
constraint) \
4646
\
4747
product(bool, EnableJVMCI, false, EXPERIMENTAL, \
48-
"Enable JVMCI. Defaults to true if UseJVMCICompiler is true.") \
48+
"Enable JVMCI. Defaults to true if UseJVMCICompiler is true or " \
49+
"jdk.internal.vm.ci is added to the root set with --add-modules.")\
4950
\
5051
product(bool, UseGraalJIT, false, EXPERIMENTAL, \
5152
"Select the Graal JVMCI compiler. This is an alias for: " \

src/hotspot/share/runtime/arguments.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ int Arguments::_num_jvm_flags = 0;
8585
char** Arguments::_jvm_args_array = nullptr;
8686
int Arguments::_num_jvm_args = 0;
8787
unsigned int Arguments::_addmods_count = 0;
88+
#if INCLUDE_JVMCI
89+
bool Arguments::_jvmci_module_added = false;
90+
#endif
8891
char* Arguments::_java_command = nullptr;
8992
SystemProperty* Arguments::_system_properties = nullptr;
9093
size_t Arguments::_conservative_max_heap_alignment = 0;
@@ -1798,13 +1801,13 @@ bool Arguments::check_vm_args_consistency() {
17981801
status = CompilerConfig::check_args_consistency(status);
17991802
#if INCLUDE_JVMCI
18001803
if (status && EnableJVMCI) {
1804+
if (ClassLoader::is_module_observable("jdk.internal.vm.ci") && !UseJVMCINativeLibrary && !_jvmci_module_added) {
1805+
jio_fprintf(defaultStream::error_stream(),
1806+
"'+EnableJVMCI' requires '--add-modules=jdk.internal.vm.ci' when UseJVMCINativeLibrary is false\n");
1807+
return false;
1808+
}
18011809
PropertyList_unique_add(&_system_properties, "jdk.internal.vm.ci.enabled", "true",
18021810
AddProperty, UnwriteableProperty, InternalProperty);
1803-
if (ClassLoader::is_module_observable("jdk.internal.vm.ci")) {
1804-
if (!create_numbered_module_property("jdk.module.addmods", "jdk.internal.vm.ci", _addmods_count++)) {
1805-
return false;
1806-
}
1807-
}
18081811
}
18091812
#endif
18101813

@@ -2247,6 +2250,19 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, JVMFlagOrigin
22472250
if (!create_numbered_module_property("jdk.module.addmods", tail, _addmods_count++)) {
22482251
return JNI_ENOMEM;
22492252
}
2253+
#if INCLUDE_JVMCI
2254+
if (!_jvmci_module_added) {
2255+
const char *jvmci_module = strstr(tail, "jdk.internal.vm.ci");
2256+
if (jvmci_module != nullptr) {
2257+
char before = *(jvmci_module - 1);
2258+
char after = *(jvmci_module + strlen("jdk.internal.vm.ci"));
2259+
if ((before == '=' || before == ',') && (after == '\0' || after == ',')) {
2260+
FLAG_SET_DEFAULT(EnableJVMCI, true);
2261+
_jvmci_module_added = true;
2262+
}
2263+
}
2264+
}
2265+
#endif
22502266
} else if (match_option(option, "--enable-native-access=", &tail)) {
22512267
if (!create_numbered_module_property("jdk.module.enable.native.access", tail, enable_native_access_count++)) {
22522268
return JNI_ENOMEM;

src/hotspot/share/runtime/arguments.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ class Arguments : AllStatic {
197197
static char* _java_command;
198198
// number of unique modules specified in the --add-modules option
199199
static unsigned int _addmods_count;
200+
// number of unique modules specified in the --add-modules option
201+
#if INCLUDE_JVMCI
202+
static bool _jvmci_module_added;
203+
#endif
200204

201205
// Property list
202206
static SystemProperty* _system_properties;

test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,37 +64,50 @@ public static void main(String[] args) throws Exception {
6464
.collect(Collectors.joining(",")));
6565
return;
6666
}
67+
68+
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
69+
"-XX:+UnlockExperimentalVMOptions", "-XX:+UseJVMCICompiler",
70+
"-XX:+PrintFlagsFinal", "--version");
71+
OutputAnalyzer output = new OutputAnalyzer(pb.start());
72+
boolean useJVMCINativeLibrary = output.firstMatch("bool +UseJVMCINativeLibrary += true") != null;
73+
// If libjvmci is not in use, then the JVMCI module must be explicitly
74+
// added with --add-modules=jdk.internal.vm.ci
75+
String addJVMCIModule = useJVMCINativeLibrary ?
76+
"--add-modules=java.base" : // effectively a nop
77+
"--add-modules=jdk.internal.vm.ci";
78+
6779
// Test EnableJVMCIProduct without any other explicit JVMCI option
68-
test("-XX:-PrintWarnings",
80+
test("-XX:-PrintWarnings", addJVMCIModule,
6981
new Expectation("EnableJVMCI", "true", "default"),
7082
new Expectation("UseJVMCICompiler", "true", "default"));
71-
test("-XX:+UseJVMCICompiler",
83+
test("-XX:+UseJVMCICompiler", addJVMCIModule,
7284
new Expectation("EnableJVMCI", "true", "default"),
7385
new Expectation("UseJVMCICompiler", "true", "command line"));
74-
test("-XX:-UseJVMCICompiler",
86+
test("-XX:-UseJVMCICompiler", addJVMCIModule,
7587
new Expectation("EnableJVMCI", "true", "default"),
7688
new Expectation("UseJVMCICompiler", "false", "command line"));
77-
test("-XX:+EnableJVMCI",
89+
test("-XX:+EnableJVMCI", addJVMCIModule,
7890
new Expectation("EnableJVMCI", "true", "command line"),
7991
new Expectation("UseJVMCICompiler", "true", "default"));
80-
test("-XX:-EnableJVMCI",
92+
test("-XX:-EnableJVMCI", addJVMCIModule,
8193
new Expectation("EnableJVMCI", "false", "command line"),
8294
new Expectation("UseJVMCICompiler", "false", "default"));
83-
test("-XX:+EnableJVMCIProduct",
95+
test("-XX:+EnableJVMCIProduct", addJVMCIModule,
8496
new Expectation("EnableJVMCIProduct", "true", "(?:command line|jimage)"),
8597
new Expectation("EnableJVMCI", "true", "default"),
8698
new Expectation("UseJVMCICompiler", "true", "default"));
8799
}
88100

89101
static int id;
90102

91-
static void test(String explicitFlag, Expectation... expectations) throws Exception {
103+
static void test(String explicitFlag, String addJVMCIModule, Expectation... expectations) throws Exception {
92104
String[] flags = {"-XX:+EnableJVMCIProduct", "-XX:+UseGraalJIT"};
93105
String cwd = System.getProperty("user.dir");
106+
94107
for (String flag : flags) {
95108
Path propsPath = Path.of("props." + id++);
96109
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
97-
"-XX:+UnlockExperimentalVMOptions", flag, "-XX:-UnlockExperimentalVMOptions",
110+
"-XX:+UnlockExperimentalVMOptions", addJVMCIModule, flag, "-XX:-UnlockExperimentalVMOptions",
98111
explicitFlag,
99112
"-XX:+PrintFlagsFinal",
100113
"--class-path=" + System.getProperty("java.class.path"),

test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public static void main(String[] args) throws Exception {
4141
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
4242
"-XX:+UnlockExperimentalVMOptions",
4343
"-XX:+EagerJVMCI",
44+
"--add-modules=jdk.internal.vm.ci",
4445
"-XX:+UseJVMCICompiler",
4546
"-Djvmci.XXXXXXXXX=true");
4647
OutputAnalyzer output = new OutputAnalyzer(pb.start());

test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public static void main(String[] args) throws Exception {
4444
static void test(String enableFlag) throws Exception {
4545
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
4646
"-XX:+UnlockExperimentalVMOptions",
47+
"--add-modules=jdk.internal.vm.ci",
4748
enableFlag, "-Djvmci.Compiler=null",
4849
"-XX:+JVMCIPrintProperties");
4950
OutputAnalyzer output = new OutputAnalyzer(pb.start());

test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static void main(String[] args) throws Exception {
4848
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
4949
"-XX:+UnlockExperimentalVMOptions",
5050
"-XX:+EagerJVMCI",
51-
"-XX:+EnableJVMCI",
51+
"--add-modules=jdk.internal.vm.ci",
5252
"-Ddebug.jvmci.PrintSavedProperties=true",
5353
"-Dapp1.propX=true",
5454
"-Dapp2.propY=SomeStringValue",

test/hotspot/jtreg/compiler/jvmci/TestValidateModules.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
public class TestValidateModules {
3737
public static void main(String... args) throws Exception {
3838
ProcessTools.executeTestJava("-XX:+UnlockExperimentalVMOptions",
39-
"-XX:+EnableJVMCI",
39+
"--add-modules=jdk.internal.vm.ci",
4040
"--validate-modules",
4141
"--list-modules")
4242
.outputTo(System.out)

test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static void main(String[] args) throws Exception {
6565

6666
pb = ProcessTools.createLimitedTestJavaProcessBuilder(
6767
"-XX:+UnlockExperimentalVMOptions",
68-
"-XX:+EnableJVMCI",
68+
"--add-modules=jdk.internal.vm.ci",
6969
"-XX:+PrintFlagsFinal",
7070
"-version");
7171
out = new OutputAnalyzer(pb.start());

test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public void jniEnomemTest() throws Exception {
169169
for (String name : names) {
170170
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
171171
"-XX:+UnlockExperimentalVMOptions",
172-
"-XX:+EnableJVMCI",
172+
"--add-modules=jdk.internal.vm.ci",
173173
"-XX:-UseJVMCICompiler",
174174
"-XX:+UseJVMCINativeLibrary",
175175
"-Dtest.jvmci.forceEnomemOnLibjvmciInit=true",

0 commit comments

Comments
 (0)