RFR: 8297313: Refactor APIs for calculating address of CDS archive heap regions

Ioi Lam iklam at openjdk.org
Mon Nov 21 06:29:15 UTC 2022


In anticipation of the following RFEs:

- [JDK-8296263](https://bugs.openjdk.org/browse/JDK-8296263): Uniform APIs for using archived heap regions
- [JDK-8296344](https://bugs.openjdk.org/browse/JDK-8296344): Remove dependency on G1 for writing the CDS archive heap

We need to clean up the APIs for calculating the addresses of CDS archive heap regions.  The current APIs have confusing names and the implementation is convoluted.

The proposal is to change the above to three APIs with easy-to-understand semantics:

// The actual address of this region during dump time.
address heap_region_dumptime_address(FileMapRegion* r)

// The address where this region can be mapped into the runtime heap without
// patching any of the pointers that are embedded in this region.
address heap_region_requested_address(FileMapRegion* r)

// The address where this shared heap region is actually mapped at runtime.
address heap_region_mapped_address(FileMapRegion* r)


The meaning of the `CDSFileMapRegion::_mapping_offset` field is changed slightly to simplify the implementation of the above 3 functions. Comments are improved explain what's going on.

With the above changes, `FileMapInfo::map_heap_regions_impl()` can also be simplified significantly.

****
Testing: tiers 1-4
****
Misc changes:
- added more assertions about exactly which combinations of collector and oop encoding mode are supported
  - Specifically, uncompressed oops for non-G1 collectors are currently not supported;
  - Change error message accordingly when the user selects an unsupported combination.

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

Commit messages:
 - 8297313: Refactor APIs for calculating address of CDS archive heap regions

Changes: https://git.openjdk.org/jdk/pull/11257/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=11257&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8297313
  Stats: 331 lines in 11 files changed: 177 ins; 104 del; 50 mod
  Patch: https://git.openjdk.org/jdk/pull/11257.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/11257/head:pull/11257

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


More information about the hotspot-runtime-dev mailing list