8311071: Avoid SoftReferences in LambdaFormEditor and MethodTypeForm when storing heap objects into AOT cache#21049
Conversation
…s' of /jdk3/yak/open into jep-483-step-06-8311071-avoid-soft-refs-in-java-lang-invoke
…s' of /jdk3/yak/open into jep-483-step-06-8311071-avoid-soft-refs-in-java-lang-invoke
…s' of /jdk3/yam/open into jep-483-step-06-8311071-avoid-soft-refs-in-java-lang-invoke
|
👋 Welcome back iklam! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
Webrevs
|
dholmes-ora
left a comment
There was a problem hiding this comment.
This seems quite reasonable for dumping the static archive.
A couple of typos.
Thanks
src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java
Outdated
Show resolved
Hide resolved
…s' of /jdk3/yam/open into jep-483-step-06-8311071-avoid-soft-refs-in-java-lang-invoke
|
|
…s' of /jdk3/yam/open into jep-483-step-06-8311071-avoid-soft-refs-in-java-lang-invoke
src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/java/lang/invoke/MethodTypeForm.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/java/lang/invoke/MethodTypeForm.java
Outdated
Show resolved
Hide resolved
cl4es
left a comment
There was a problem hiding this comment.
How does archiving and resolution of the linked MethodType instances work? In particular how does archiving fill up the MethodType::internTable to ensure MethodType uniqueness?
…s' of /jdk3/yam/open into jep-483-step-06-8311071-avoid-soft-refs-in-java-lang-invoke
The details are in the next PR (#21143) which is still in draft state. At the end of AOT cache assembly phase, the JVM (in During the production run, we first look up from the side table, before checking/interning in the main table. |
…s' of /jdk3/yam/open into jep-483-step-06-8311071-avoid-soft-refs-in-java-lang-invoke
…s' of /jdk3/yam/open into jep-483-step-06-8311071-avoid-soft-refs-in-java-lang-invoke
…s' of /jdk3/yam/open into jep-483-step-06-8311071-avoid-soft-refs-in-java-lang-invoke
src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java
Outdated
Show resolved
Hide resolved
|
This is good although hacky, due to incomplete "build out" of Leyden-related functionality. For a first JEP it is fine. But it leaves some debt to pay off later. Later, we need to decide how to more fully embrace SoftReference. There is nothing inherently wrong with mixing SR's and AOT, even if they interfere somewhat. I think the right answer might be forcing them to get along better. We need to get their queueing status into a quiet state order to push them into the AOT cache (and then pull them out as the production run states). It seems to me we should (first) try pruning away most of the queueing infrastructure during the assembly phase, and patching it up in the production run (at some appropriate Or, we could do a Three Table (or Two Table) solution. This PR is an example of a Two Table solution. (One could say the handoff from AOT table to runtime table is overly subtle but it works, and maybe that subtlety just comes with the territory.) The various cache variables ( If we have a sudden flash of insight how to support AOT of soft references (SRs), then this PR goes away. Otherwise, I have one request, related to MethodHandleStatics. I think we should be moving towards respecting the finals of that class, like any other class, as AOT-able values. Using just one static as a secret channel for AOT logic is too edgy for my taste. First, Also, consider moving it (as a stable non-final) to |
|
Here is a more extensive example of using stable variables to split a single class initializer into multiple phases: https://cr.openjdk.org/~jrose/leyden/SplitInitsWithStableFields.java |
…s' of /jdk3/yam/open into jep-483-step-06-8311071-avoid-soft-refs-in-java-lang-invoke
…ndleNatives as a @stable field; use system prop for init
Hi John, I've moved the variable to |
liach
left a comment
There was a problem hiding this comment.
The updated version using MH natives flag looks good.
…s' of /jdk3/yam/open into jep-483-step-06-8311071-avoid-soft-refs-in-java-lang-invoke
|
Still looks good except @iklam I'd be surprised if this class is AOT-initialized. I hope it's not the case here. |
…s' of /jdk3/yam/open into jep-483-step-06-8311071-avoid-soft-refs-in-java-lang-invoke
|
Closing this PR as its changes have been combined into #21642. |
This is the 6th PR for JEP 483: Ahead-of-Time Class Loading & Linking.
The implementation of java.lang.invoke uses SoftReferences so that unused MethodHandles, LambdaForms, etc, can be garbage collected.
However, if we want to store java.lang.invoke objects in the AOT cache (JDK-8293336, the final step in JEP 493), it's difficult to cache these SoftReferences -- SoftReferences in turn point to ReferenceQueues, etc, which have dependencies on the current execution state (Threads, etc) which are difficult to cache.
The proposal is to add a new flag:
MethodHandleStatics.NO_SOFT_CACHE. When this flag is true, we avoid using SoftReferences, and store a direct reference to the target object instead.JDK-8293336 stores only java.lang.invoke objects that refer to classes loaded by the boot/platform/app loaders. These classes are never unloaded, so it's not necessary to point to them using SoftReferences.
This RFE modifies only the LambdaFormEditor and MethodTypeForm classes, as that's the minimal modification required by JDK-8293336.
See here for the sequence of dependent RFEs for implementing JEP 483.
Progress
Integration blocker
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21049/head:pull/21049$ git checkout pull/21049Update a local copy of the PR:
$ git checkout pull/21049$ git pull https://git.openjdk.org/jdk.git pull/21049/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 21049View PR using the GUI difftool:
$ git pr show -t 21049Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21049.diff
Webrev
Link to Webrev Comment