-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8354890: AOT-initialize j.l.i.MethodHandleImpl and inner classes #24956
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
8354890: AOT-initialize j.l.i.MethodHandleImpl and inner classes #24956
Conversation
…ptions on GC behavior. Suggested by @fisk
…/hotspot/jtreg/runtime/invokedynamic"
…DanHeidinga comment -- renamed to MethodType::assemblySetup()
…r AOTReferenceObjSupport::is_enabled()
👋 Welcome back iklam! A progress list of the required criteria for merging this PR into |
@iklam 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 no new commits pushed to the ➡️ To integrate this PR with the above commit message to the |
The parent pull request that this pull request depends on has now been integrated and the target branch of this pull request has been updated. This means that changes from the dependent pull request can start to show up as belonging to this pull request, which may be confusing for reviewers. To remedy this situation, simply merge the latest changes from the new target branch into this pull request by running commands similar to these in the local repository for your personal fork: git checkout 8354890-aot-init-methodhandleimpl-and-inner-classes
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# if there are conflicts, follow the instructions given by git merge
git commit -m "Merge master"
git push |
@iklam this pull request can not be integrated into git checkout 8354890-aot-init-methodhandleimpl-and-inner-classes
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
…patterns for MethodHandles
// of <clinit> | ||
initialize(CHECK); | ||
return; | ||
} |
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 change is to avoid deadlock in the previous implementation.
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 tests look good to me.
@@ -1525,7 +1525,12 @@ private static NamedFunction createFunction(byte func) { | |||
} | |||
} | |||
|
|||
// Called from JVM when loading an AOT cache |
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.
// Called from JVM when loading an AOT cache |
|
||
private static void runtimeSetup() { |
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.
private static void runtimeSetup() { | |
// Called from JVM when loading an AOT cache | |
private static void runtimeSetup() { |
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.
Same problem in Reference, credit to @ExE-Boss
throw new RuntimeException("o has wrong interfaces"); | ||
} | ||
|
||
statementEnum(MyEnum.A); |
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.
String s = statementEnum(MyEnum.A);
if (!s.equals("A")) {
throw new RuntimeException("enum switch incorrect");
}
@iklam We have seen this problem with Red Hat deployments in jdk24 as well as jdk25-ea. I'm saying that mostly for information. However, I do have to ask: If this is fixed for jdk25 is there any question of also fixing it in jdk24? I would be content to receive a no answer -- a similar issue with patch that could be backported from jdk26 -> jdk25 might be something to think about a bit more? |
Backporting this to jdk 24 would require a lot of effort. I think it might be easier to update CDSHeapVerifier to add more rules to filter out the false positives. CDSHeapVerifier is too conservative and reports error for things that are actually OK. |
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 Java code change and the BSM coverage looks good to me. Requiring another reviewer for hotspot changes.
/reviewers 2 reviewer
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.
This is a general fix for all the "points to a static field that may hold a different value" failures related to
java/lang/invoke/MethodHandleImpl
. E.g., JDK-8354840, JDK-8353330.AOT-cached method handles quite often refer to the static fields in
MethodHandleImpl
or its inner classes. In the production run, if the value of these static field changes, we may have unexpected behavior related to identity of objects in these static fields.CDSHeapVerifier
makes a very conservative check for such static fields, but sometimes gives false positives (as in the above two JBS issues)In this PR, we AOT-initialize
MethodHandleImpl
and its inner classes. This is a more authentic snapshot of the state ofjava.lang.invoke
during the assembly phase. We also avoid the need to add and maintain entries in thecdsHeapVerifier.cpp
table.I also added more code in
MethodHandleTest.java
to simulate potential usage patterns ofMethodHandle
by the Java core libraries. Hopefully this will reduce the likelihood for innocent core lib changes breaking the AOT assembly phase.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24956/head:pull/24956
$ git checkout pull/24956
Update a local copy of the PR:
$ git checkout pull/24956
$ git pull https://git.openjdk.org/jdk.git pull/24956/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24956
View PR using the GUI difftool:
$ git pr show -t 24956
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24956.diff
Using Webrev
Link to Webrev Comment