RFR: 8311071: Avoid SoftReferences in LambdaFormEditor and MethodTypeForm when storing heap objects into AOT cache [v10]
Ioi Lam
iklam at openjdk.org
Mon Oct 21 20:47:08 UTC 2024
> This is the 6th PR for [JEP 483: Ahead-of-Time Class Loading & Linking](https://bugs.openjdk.org/browse/JDK-8315737).
>
> 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](https://bugs.openjdk.org/browse/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](https://bugs.openjdk.org/browse/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](https://bugs.openjdk.org/browse/JDK-8293336).
>
> ---
> See [here](https://bugs.openjdk.org/browse/JDK-8315737) for the sequence of dependent RFEs for implementing JEP 483.
Ioi Lam has updated the pull request incrementally with one additional commit since the last revision:
@iwanowww comment: no need for @Stable for USE_SOFT_CACHE; use final instead
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/21049/files
- new: https://git.openjdk.org/jdk/pull/21049/files/11391c39..a9ae70e2
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=21049&range=09
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=21049&range=08-09
Stats: 2 lines in 1 file changed: 0 ins; 1 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/21049.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/21049/head:pull/21049
PR: https://git.openjdk.org/jdk/pull/21049
More information about the core-libs-dev
mailing list