RFR: 8297290: Use int indices to reference CDS archived primitive mirrors [v3]
Ashutosh Mehra
duke at openjdk.org
Tue Nov 22 20:34:35 UTC 2022
On Tue, 22 Nov 2022 18:53:43 GMT, Ioi Lam <iklam at openjdk.org> wrote:
>> In CDS, when archived class metadata reference an object in the archive heap, it's usually done using an integer index, which can be passed to `HeapShared::get_root(int)` to retrieve the object. This way, we don't need to worry if the archive heap has been relocated. E.g.,
>>
>>
>> oop Klass::archived_java_mirror() {
>> assert(has_archived_mirror_index(), "must have archived mirror");
>> return HeapShared::get_root(_archived_mirror_index);
>> }
>>
>> However, for the primitive mirror objects (in `Universe::_mirrors[]`, which point to the `java.lang.Class` instances of the Java primitive types such as `int`, `float`, etc), we are still using a direct oop reference.
>>
>> For consistency, we should change this code to use the same int indices as the rest of the system. This will also make it simpler to optimize the layout of the CDS archive heap (e.g., in [JDK-8234679](https://bugs.openjdk.org/browse/JDK-8234679)).
>>
>> Testing: passed tiers 1-4
>
> Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
>
> - Merge branch 'master' into 8297290-simplify-cds-primitive-mirror-storage
> - @calvinccheung comments
> - fixed spaces
> - 8297290: Simplify the storage for CDS archived primitive mirrors
src/hotspot/share/memory/universe.cpp line 93:
> 91: OopHandle Universe::_mirrors[T_VOID+1];
> 92: #if INCLUDE_CDS_JAVA_HEAP
> 93: int Universe::_archived_mirror_indices[T_VOID+1];
a minor suggestion - I feel it would be better to name it as `_archived_basic_type_mirror_indices` as it only stores mirrors for primitive types. Same for the other functions accessing `_archived_mirror_indices` i.e. `set_archived_mirror_index` -> `set_archived_basic_type_mirror_index` and `update_archived_mirrors` -> `update_archived_basic_type_mirrors`.
-------------
PR: https://git.openjdk.org/jdk/pull/11256
More information about the hotspot-runtime-dev
mailing list