> This is the 7th and final PR for [JEP 483: Ahead-of-Time Class Loading & > Linking](https://bugs.openjdk.org/browse/JDK-8315737). > > This PR implements the AOT-linking of invokedynamic callsites: > - We only link lambda expressions (`LambdaMetafactory::metafactory`) and > string concat (`StringConcatFactory::makeConcatWithConstants()`) as the > results of these bootstrap methods do not have environment dependencies and > can be safely cached. > - The resolved CallSites are represented as Java heap objects. Thus, this > optimizations is supported only for the static CDS archive, which can store > heap objects. The dynamic CDS archive is not supported. > > **Review Notes:** > > - Start with `AOTConstantPoolResolver::preresolve_indy_cp_entries()` -- it > checks all indys that were linked during the training run, and aot-links only > those for lambdas and string concats > - `SystemDictionaryShared::find_all_archivable_classes()` finds all the > hidden classes that are reachable from the indy CallSites > - In `MetaspaceShared::preload_and_dump_impl()` we call > `MethodType::createArchivedObjects()` to record all MethodTypes that were > created in the assembly phase. This is necessary because the identity of > MethodTypes is significant (they are compared with the `==` operator). Also > see MethodType.java for the corresponding code that are used in the > production run. > - Afterwards, we enter the safepoint (`VM_PopulateDumpSharedSpace::doit()`). > In this safepoint, > `ConstantPoolCache::remove_resolved_indy_entries_if_non_deterministic()` is > called to remove any resolved indy callsites that cannot be archived. (Such > CallSites may be created as a side effect of Java code execution in the > assembly phase. E.g., the bootstrap of the module system). > > **Rough Edges:** > > - Many archived CallSites references (directly or indirectly) the static > fields of the classes listed under > `AOTClassInitializer::can_archive_initialized_mirror()`, where the object > identity of these static fields is significant. Therefore, we must preserve > the initialized states of these classes. Otherwise, we might run into > problems such as [JDK-8340836](https://bugs.openjdk.org/browse/JDK-8340836). > Unfortunately, the list is created by trial-and-error, and may need to be > updated to match changes in the `java.lang.invoke` and > `jdk.internal.constant` packages. We expect Project Leyden to come with a > general solution to this problem. > - If the identity is significant for a static field in a complex class, but > not all of the static fields of this cl...
Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 48 commits: - Merge branch 'jep-483-step-06-8311071-avoid-soft-refs-in-java-lang-invoke' into jep-483-step-07-8293336-store-lambda-forms-in-cds-archive - Better fix for JDK-8342438: runtime/cds/SharedBaseAddress.java fails with Parallel and Serial GCs when running with AOTClassLinking enabled - (1) @ashu-mehra review comments - code simplfication; (2) fix bug in last commit - @DanHeidinga comments - removed dead code; added assert with ArchiveBuilder::has_been_buffered(src_ik) - Fixed JDK-8342732: java/lang/invoke/MethodTypeSecurityManager.java fails with "should never leak JDK internal class" in case AOTClassLinking enabled - Fixed JDK-8342723: Crash with "assert(_instance != nullptr) failed: cannot enqueue events before the service thread runs" in case AOTClassLinking enabled - @ashu-mehra comments: renamed to find_required_hidden_classes(), etc, and added checks for only hidden classes - fixed minimal build - Fixed JDK-8342438: runtime/cds/SharedBaseAddress.java fails with Parallel and Serial GCs when running with AOTClassLinking enabled - dholmes-ora comment - removed direct_only parameter from InstanceKlass::is_enum_subclass() - ... and 38 more: https://git.openjdk.org/jdk/compare/875c066d...f0bc1ae6 ------------- Changes: https://git.openjdk.org/jdk/pull/21143/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21143&range=16 Stats: 2793 lines in 76 files changed: 2445 ins; 146 del; 202 mod Patch: https://git.openjdk.org/jdk/pull/21143.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/21143/head:pull/21143 PR: https://git.openjdk.org/jdk/pull/21143