RFR: 8307567: Avoid relocating global roots to metaspaceObjs in CDS dump [v6]

Ioi Lam iklam at openjdk.org
Mon May 15 16:49:18 UTC 2023


> 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.

Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains ten commits:

 - Merge branch 'master' into 8307567-avoid-relocate-global-roots-in-cds-dump
 - removed obsolete comment
 - fixed windows build
 - Made SharedClassPathEntry a proper MetaspaceObj so we do not need FileMapInfo::remember_embedded_pointers()
 - Added comments about FileMapInfo::remember_embedded_pointers(); removed unused code
 - @calvinccheung comments
 - Merge branch 'master' into 8307567-avoid-relocate-global-roots-in-cds-dump
 - added comments and assert; fixed spaces
 - 8307567: Avoid relocating global roots to metaspaceObjs in CDS dump

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

Changes: https://git.openjdk.org/jdk/pull/13854/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13854&range=05
  Stats: 311 lines in 15 files changed: 98 ins; 139 del; 74 mod
  Patch: https://git.openjdk.org/jdk/pull/13854.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/13854/head:pull/13854

PR: https://git.openjdk.org/jdk/pull/13854


More information about the hotspot-runtime-dev mailing list