RFR: 8307567: Avoid relocating global roots to metaspaceObjs in CDS dump
Calvin Cheung
ccheung at openjdk.org
Thu May 11 00:02:56 UTC 2023
On Sat, 6 May 2023 17:11:54 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> The functions `ArchiveBuilder::relocate_roots()` and `ArchiveBuilder::relocate_vm_classes()` relocate global roots such as `Universe::_typeArrayKlassObjs[]` and `vmClasses::_klasses[]` to point to locations inside the CDS "buffer" space.
>
> As a result, the VM is no longer usable after CDS dumping has finished.
>
> Previously, we tried to save some of the VM states and restore them after CDS dump has finished. See [JDK-8264735](https://bugs.openjdk.org/browse/JDK-8264735), which added functions like `FileMapInfo::clone_shared_path_table()`.
>
> However, this is too cumbersome and doesn't cover all cases. The intention of the global root relocation is to make it easy to write the roots using `WriteClosure::do_ptr()`, which could handle only pointers into the "buffer" space. If we call `get_buffered_addr()` inside `WriteClosure::do_ptr()`, then there's no need to modify the global roots.
>
> Notes for reviewers:
>
> - Start with changes in `WriteClosure::do_ptr()`
> - Some code in SystemDictionaryShared also needed to call `get_buffered_addr()`
> - I added new function `ArchiveBuilder::write_pointer_in_buffer()` to simplify writing pointers into the CDS buffer
> - `ArchiveBuilder::relocate_roots()`, `ArchiveBuilder::relocate_vm_classes()` and `FileMapInfo::clone_shared_path_table()` are removed.
> - I am leaving `CloneDumpTimeClassTable` and `CloneDumpTimeLambdaProxyClassTable` for now. I plan to remove them in a follow up RFE after more testing.
I have a question and a comment. Looks good otherwise.
src/hotspot/share/cds/archiveBuilder.cpp line 495:
> 493: iterate_sorted_roots(&doit);
> 494: doit.finish();
> 495: FileMapInfo::remember_embedded_pointers();
What is the above call for?
I thought `FileMapInfo::metaspace_pointers_do()` already called from `iterate_roots()` which is called from `iterate_sorted_roots()`.
src/hotspot/share/cds/archiveBuilder.hpp line 252:
> 250: void make_shallow_copies(DumpRegion *dump_region, const SourceObjList* src_objs);
> 251: void make_shallow_copy(DumpRegion *dump_region, SourceObjInfo* src_info);
> 252:
Blank line removed by accident?
-------------
Marked as reviewed by ccheung (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/13854#pullrequestreview-1421503482
PR Review Comment: https://git.openjdk.org/jdk/pull/13854#discussion_r1190484821
PR Review Comment: https://git.openjdk.org/jdk/pull/13854#discussion_r1190485138
More information about the hotspot-runtime-dev
mailing list