Skip to content
Closed
9 changes: 7 additions & 2 deletions src/hotspot/share/jvmci/jvmci_globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: " \
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/runtime/arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
29 changes: 8 additions & 21 deletions test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,50 +64,37 @@ 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"));
}

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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/compiler/jvmci/TestValidateModules.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down