RFR: 8293187: Store initialized Enum classes in AOTCache [v3]

Ashutosh Mehra asmehra at openjdk.org
Thu Sep 26 20:52:37 UTC 2024


On Thu, 19 Sep 2024 16:26:07 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> Expanding on the above example, lets say A is aot- initialized, but B and C are not.
>> So this function should initialize only X not Y, is that correct? If so, then how does it prevent initialization of Y? It iterates through all the subgraph_object_klasses which includes both X and Y.
>
> The `subgraph_object_klasses` are built during assembly phase when each mirror is added to the cache. Note that we don't add the "real" mirror of the classes, but we add the scratch mirror:
> 
> 
> void HeapShared::archive_java_mirrors() {
>     ...
>     oop m = scratch_java_mirror(orig_k);
>     if (m != nullptr) {
>       Klass* buffered_k = ArchiveBuilder::get_buffered_klass(orig_k);
>       bool success = archive_reachable_objects_from(1, _default_subgraph_info, m);
> 
> 
> So the scratch mirrors of `B` and `C` will be empty when they are being archived.
> 
> Because `A` is marked as aot-initialized, we copy the fields of the "real" mirror of `A` into its scratch mirror. See `HeapShared::copy_aot_initialized_mirror()`. That's why we are able to add `X` into the subgraph_object_klasses (when `A`'s scratch mirror is scanned inside `archive_reachable_objects_from()`)

@iklam are you planning to address this? Otherwise the patch looks good to me.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20958#discussion_r1777718590


More information about the hotspot-dev mailing list