RFR: 8297914: Remove java_lang_Class::process_archived_mirror()
Ashutosh Mehra
duke at openjdk.org
Tue Jan 10 19:17:56 UTC 2023
On Wed, 4 Jan 2023 21:01:28 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> This is another prerequisite for [JDK-8296344](https://bugs.openjdk.org/browse/JDK-8296344).
>
> Before this PR, when archiving mirror objects (i.e., instances of `java.lang.Class`):
> - We first allocate a copy of the mirror inside a safepoint.
> - We then reinitialize the contents of the copy to the desired state (so that it can be used by `Klass::restore_unshareable_info()`
>
> This copy-and-modify operation inside the safepoint makes it difficult to implement [JDK-8296344](https://bugs.openjdk.org/browse/JDK-8296344). It violates the requirements [1] and [2] as stated in [JDK-8298600](https://bugs.openjdk.org/browse/JDK-8298600). Also, the reinitialization code is complicated.
>
> After this PR:
> - During the creation of each regular mirror object, we allocate a "scratch mirror" object, which has the states as expected by `Klass::restore_unshareable_info()`. See `java_lang_Class::create_scratch_mirror()`.
> - When the archive heap is dumped inside a safepoint, we use the scratch mirror, so we can avoid the copy-and-modify operation. See `HeapShared::archive_java_mirrors()`.
>
> Testing: tiers 1-4
src/hotspot/share/cds/heapShared.cpp line 379:
> 377: };
> 378:
> 379: static KlassToOopHandleTable* _scratch_java_mirror_table = NULL;
Any reason why `_scratch_basic_type_mirrors` is a static member of `HeapShared` but `_scratch_java_mirror_table` is not?
src/hotspot/share/classfile/javaClasses.cpp line 1347:
> 1345: assert(java_class == Universe::void_mirror(), "only valid non-array primitive");
> 1346: }
> 1347: assert(Universe::java_mirror(type) == java_class ||
If we need the condition `HeapShared::scratch_java_mirror(type) == java_class` here, shouldn't the previous assert be also updated to check for scratch java mirror for void type?
`assert(java_class == Universe::void_mirror() |, "only valid non-array primitive");`
-------------
PR: https://git.openjdk.org/jdk/pull/11853
More information about the hotspot-dev
mailing list