Skip to content

8345826: [DO NOT MERGE] Do not automatically resolve jdk.internal.vm.ci when libgraal is used #23408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/hotspot/share/jvmci/jvmci_globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: " \
Expand Down
26 changes: 21 additions & 5 deletions src/hotspot/share/runtime/arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

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

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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
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",
"-XX:+EnableJVMCI",
"--add-modules=jdk.internal.vm.ci",
"-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",
"-XX:+EnableJVMCI",
"--add-modules=jdk.internal.vm.ci",
"--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",
"-XX:+EnableJVMCI",
"--add-modules=jdk.internal.vm.ci",
"-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",
"-XX:+EnableJVMCI",
"--add-modules=jdk.internal.vm.ci",
"-XX:-UseJVMCICompiler",
"-XX:+UseJVMCINativeLibrary",
"-Dtest.jvmci.forceEnomemOnLibjvmciInit=true",
Expand Down