RFR: 8284435: Add dedicated filler objects for known dead Java heap areas [v2]
Thomas Schatzl
tschatzl at openjdk.java.net
Mon Apr 11 10:48:35 UTC 2022
On Fri, 8 Apr 2022 16:45:54 GMT, Ioi Lam <iklam at openjdk.org> wrote:
>> Thomas Schatzl has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - iklam review
>> - Test case
>
> src/hotspot/share/classfile/systemDictionaryShared.cpp line 1727:
>
>> 1725: ArchivedMirrorPatcher::update_array_klasses(k);
>> 1726: }
>> 1727: ArchivedMirrorPatcher::update_array_klasses(Universe::fillerArrayKlassObj());
>
> I think this is not necessary. `Universe::fillerArrayKlassObj()` shares the same mirror as `Universe::intArrayKlassObj()`, which has already been updated in the loop above.
>
> `ArchivedMirrorPatcher::update_array_klasses(k)` will essentially do `k->mirror->pointer_back_to_klass += delta`, so it will incorrectly set the pointer when delta is not zero.
>
> I would suggest running with
>
>
> -XX:ArchiveRelocationMode=1 -Xlog:cds -Xlog:class+load=debug
>
>
> and step into the following code:
>
>
> void java_lang_Class::update_archived_mirror_native_pointers(oop archived_mirror) {
> assert(MetaspaceShared::relocation_delta() != 0, "must be");
>
> Klass* k = ((Klass*)archived_mirror->metadata_field(_klass_offset));
> archived_mirror->metadata_field_put(_klass_offset,
> (Klass*)(address(k) + MetaspaceShared::relocation_delta())); <<<< HERE
Stepping into that code (well, I added some logging) indicated that the mirrors for these klasses (`_fillerArrayKlassObj` and `intArrayKlassObj`) are different, so the field is not updated multiple times. So this code seems required, also because there are lots of crashes when removing the `ArchivedMirrorPatcher::update_array_klasses` call.
(Say, if you print the `java_mirror()` after Universe initialization)
The problem with the compiler we had (which was resolved by initializing the filler array before the int-array) was that in the component mirror, there is a reference to the arrayklass that represents an array of that basic type.
So as the code earlier initialized the filler array klass after the int array klass, the compiler used the filler array klass for array instantiation which tests did not like.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8156
More information about the core-libs-dev
mailing list