RFR: 8329706: Implement -XX:+AOTClassLinking
David Holmes
dholmes at openjdk.org
Fri Sep 6 05:12:54 UTC 2024
On Tue, 3 Sep 2024 20:57:48 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> This is the 3rd PR for [JEP 483: Ahead-of-Time Class Loading & Linking](https://bugs.openjdk.org/browse/JDK-8315737).
>
> **Overview**
>
> - A new `-XX:+AOTClassLinking` flag is added. See [JEP 498](https://bugs.openjdk.org/browse/JDK-8315737) and the [CSR](https://bugs.openjdk.org/browse/JDK-8339506) for a discussion of this command-line option, its default value, and its impact on compatibility.
> - When this flag is enabled during the creation of an AOT cache (aka CDS archive), an `AOTLinkedClassTable` is added to the cache to include all classes that are AOT-linked. For this PR, only classes for the boot/platform/application loaders are eligible. The main logic is in `aotClassLinker.cpp`.
> - When an AOT archive is loaded in a production run, all classes in the `AOTLinkedClassTable` are loaded into their respective class loaders at the earliest opportunity. The main logic is in `aotLinkedClassBulkLoader.cpp`.
> - The boot classes are loaded as part of `vmClasses::resolve_all()`
> - The platform/application classes are loaded after the module graph is restored (see changes in `threads.cpp`).
> - Since all classes in a `AOTLinkedClassTable` are loaded before any user-code is executed, we can resolve constant pool entries that refer to these classes during AOT cache creation. See changes in `AOTConstantPoolResolver::is_class_resolution_deterministic()`.
>
> **All-or-nothing Loading**
>
> - Because AOT-linked classes can refer to each other, using direct C++ pointers, all AOT-linked classes must be loaded together. Otherwise we will have dangling C++ pointers in the class metadata structures.
> - During a production run, we check during VM start-up for incompatible VM options that would prevent some of the AOT-linked classes from being loaded. For example:
> - If the VM is started with an JVMTI agent that has ClassFileLoadHook capabilities, it could replace some of the AOT-linked classes with alternative versions.
> - If the VM is started with certain module options, such as `--patch-module` or `--module`, some AOT-linked classes may be replaced with patched versions, or may become invisible and cannot be loaded into the JVM.
> - When incompatible VM options are detected, the JVM will refuse to load an AOT cache that has AOT-linked classes. See `FileMapInfo::validate_aot_class_linking()`.
> - For simplfication, `FileMapInfo::validate_aot_class_linking()` requires `CDSConfig::is_using_full_module_graph()` to be true. This means that the exact same set of modules are visible whe...
src/hotspot/share/cds/archiveBuilder.cpp line 902:
> 900:
> 901: log_info(cds)("Number of classes %d", num_instance_klasses + num_obj_array_klasses + num_type_array_klasses);
> 902: log_info(cds)(" instance classes " STATS_FORMAT, STATS_PARAMS(instance_klasses));
Suggestion:
log_info(cds)(" instance classes " STATS_FORMAT, STATS_PARAMS(instance_klasses));
src/hotspot/share/cds/archiveBuilder.cpp line 904:
> 902: log_info(cds)(" instance classes " STATS_FORMAT, STATS_PARAMS(instance_klasses));
> 903: log_info(cds)(" boot " STATS_FORMAT, STATS_PARAMS(boot_klasses));
> 904: log_info(cds)(" vm " STATS_FORMAT, STATS_PARAMS(vm_klasses));
Suggestion:
log_info(cds)(" vm " STATS_FORMAT, STATS_PARAMS(vm_klasses));
src/hotspot/share/cds/archiveBuilder.cpp line 912:
> 910: STATS_PARAMS(unlinked_klasses),
> 911: boot_unlinked, platform_unlinked,
> 912: app_unlinked, unreg_unlinked);
Suggestion:
log_info(cds)(" (unlinked) " STATS_FORMAT ", boot = %d, plat = %d, app = %d, unreg = %d",
STATS_PARAMS(unlinked_klasses),
boot_unlinked, platform_unlinked, app_unlinked, unreg_unlinked);
src/hotspot/share/cds/archiveUtils.cpp line 390:
> 388: return "boot"; // boot classes in java.base
> 389: } else {
> 390: return "boot2"; // boot classes outside of java.base
Suggestion: boot -> boot-base, boot2 -> boot-nonbase ?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20843#discussion_r1746516082
PR Review Comment: https://git.openjdk.org/jdk/pull/20843#discussion_r1746516226
PR Review Comment: https://git.openjdk.org/jdk/pull/20843#discussion_r1746517363
PR Review Comment: https://git.openjdk.org/jdk/pull/20843#discussion_r1746518309
More information about the serviceability-dev
mailing list