-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8309136: [JVMCI] add -XX:+UseGraalJIT flag #14231
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
Conversation
|
👋 Welcome back dnsimon! A progress list of the required criteria for merging this PR into |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor items but otherwise the flag handling seems fine (though not what was linked in the CSR request).
Thanks.
| product(bool, EnableJVMCI, false, EXPERIMENTAL, \ | ||
| "Enable JVMCI") \ | ||
| \ | ||
| product(bool, UseGraalJIT, false, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be EXPERIMENTAL
| "Enable JVMCI") \ | ||
| \ | ||
| product(bool, UseGraalJIT, false, \ | ||
| "Select the Graal JVMCI compiler. This is a macro for: " \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/a macro/an alias/ please
Would you mind expanding on the discrepancy? I'd like to make it consistent. |
|
In the CSR request when asked about the response when the run-time image does not include the Graal JIT you pointed to this Java code: jdk/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Line 112 in 927a9ed
but it seems to me that the logic in arguments.cpp handles the case where Graal is not available. Or are there different levels of "availability" here? |
|
The logic in arguments.cpp only ensures the value of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about UseJVMCICompiler flag? A lot of code in HotSpot is guarded by this flag.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update Copyright year in test.
| if (match_option(option, "-XX:+UseGraalJIT")) { | ||
| const char* jvmci_compiler = get_property("jvmci.Compiler"); | ||
| if (jvmci_compiler != nullptr) { | ||
| if (strcmp(jvmci_compiler, "graal") != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not use strcmp - use strncmp.
| 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this restriction? Usually latest specified flag wins. May be comment with explanation.
Also you did not check for if (UseGraalJIT).
What about the case -XX:+EnableJVMCIProduct -XX:-UseGraalJIT?
I would expect this kind of checks done in JVMCIGlobals::check_jvmci_flags_are_consistent()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this restriction? Usually latest specified flag wins. May be comment with explanation.
This is a pre-existing restriction on EnableJVMCIProduct and since UseGraalJIT is an alias for EnableJVMCIProduct, it must abide by the same restrictions. For whatever reason, the effect of +EnableJVMCIProduct cannot be undone and so the same must hold for +UseGraalJIT.
Also you did not check for
if (UseGraalJIT).
This check is not necessary as UseGraalJIT is an alias. When EnableJVMCIProduct is set to true, UseGraalJIT will also be set to true. Stating this now, I see that I missed it: 430b7a5
What about the case -XX:+EnableJVMCIProduct -XX:-UseGraalJIT?
That results in:
-XX:-EnableJVMCIProduct or -XX:-UseGraalJIT cannot come after -XX:+EnableJVMCIProduct or -XX:+UseGraalJIT
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
which is what is expected.
| new Expectation("UseJVMCICompiler", "false", "default")); | ||
| test("-XX:+EnableJVMCIProduct", | ||
| new Expectation("EnableJVMCIProduct", "true", "command line"), | ||
| new Expectation("EnableJVMCIProduct", "true", "(?:command line|jimage)"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What "(?:command line|jimage)" means? Also | hard to see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a standard Java regular expression and it means the value is expected have been set on the command line or by the VM options read from the jimage (see JDK-8232080).
Are you saying that the application will start executing quite happily in interpreted mode and then only abort when the JIT first kicks in? That would be a very bad thing to do unless you can guarantee the jit will kick in extremely early during VM init sequence. |
I assume this is required only for Java Graal. For libgraal you can check library presence at the VM startup. Or I am wrong? |
JVMCI compiler initialization is always lazy. It has been this way since the initial JVMCI implementation. Even libgraal initialization will impact VM startup. The first top tier compilation usually happens within the first 100 ms of VM execution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now. You need second approval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes here seem fine, but I remain concerned about the compiler detection logic that presently exists. I can run trivial "programs" using -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCIProduct -Djvmci.Compiler=graal and there is no error. That means that JIT compilation is not kicking in during VM init and that application code is being executed prior to the VM aborting! That is very wrong behaviour IMO, but it is pre-existing so would need to be addressed in separate bug.
|
Thanks for input David. I agree that it's best to open a new JBS issue to discuss concerns about lazy JVMCI compiler initialization. |
|
@dougxc This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 23 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
|
Thanks to all the reviewers. /integrate |
|
Going to push as commit b3c9d67.
Your commit was automatically rebased without conflicts. |
@dougxc : was the "new JBS issue" opened? If so, can it be linked here and in https://bugs.openjdk.org/browse/JDK-8309136. |
|
@ysramakrishna I'm not aware of an issue being opened. I'd prefer to avoid opening an issue until we better understand where the concern results in a real problem in practice. If you have something along these lines, feel free to open the issue. |
Use of the Graal-based JIT in OpenJDK currently requires the following flag:
-XX:+EnableJVMCIProductThis has no direct association with Graal. If the JDK image happens to include a non-Graal JVMCI implementation, it will be automatically selected. This would come as a surprise to users who equate JVMCI with Graal.
This PR introduces a new flag,
-XX:+UseGraalJITto address these shortcomings. It is an alias for-XX:+EnableJVMCIProduct -Djvmci.Compiler=graal.When
-XX:+UseGraalJITis specified, the VM fails fast at startup if there is a non-Graal JVMCI implementation or no JVMCI implementation in the JDK image.Progress
Issues
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14231/head:pull/14231$ git checkout pull/14231Update a local copy of the PR:
$ git checkout pull/14231$ git pull https://git.openjdk.org/jdk.git pull/14231/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 14231View PR using the GUI difftool:
$ git pr show -t 14231Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14231.diff
Webrev
Link to Webrev Comment