RFR: 8374549: Extend MetaspaceClosure to cover non-MetaspaceObj types
Ioi Lam
iklam at openjdk.org
Wed Jan 14 04:50:14 UTC 2026
Previously, `MetaspaceClosure` could iterate only `MetaspaceObject`, using its four member functions:
- `is_read_only_by_default()`
- `metaspace_pointers_do()`
- `size()`
- `type()`
`PackageEntry`, `ModuleEntry` and `GrowableArray` cannot be subclasses from `MetaspaceObject` due to various constraints. As a result, they were copied with ad-hoc code.
This PR updates the templates in `MetaspaceClosure` so that it can iterate any classes that have the above four functions. This allows new types of data to be uniformly copied into the AOT cache (aka CDS archive) without ad-hoc copiers.
This PR is necessary for future evolution of AOT as more types of data will be copied into the AOT cache. For example, in Valhalla we have a `GrowableArray` that needs to be copied along with `AdapterHandleEntry`.
-------------
Commit messages:
- More clean up -- MetaspaceObj::Type -> MetaspaceClosureType
- clean up
- Remove test code inside HotSpot for OtherCArrayRef and MSOCArrayRef
- Added OtherCArrayRef and MSOCArrayRef
- Removed old code that explicitly convert between GrowableArray and Array
- Finished copying and clean up of PackageEntry, ModuleEntry and their growable arrays. These are not actually used by the production run yet
- clean up
- rename size() to size_in_heapwords() for types that are not MetaspaceObj
- Add MetaspaceClosure support functions back to AOTGrowableArray
- New AOTGrowableArray<T> class
- ... and 7 more: https://git.openjdk.org/jdk/compare/6b3c1e0f...331fe165
Changes: https://git.openjdk.org/jdk/pull/29049/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29049&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8374549
Stats: 1166 lines in 30 files changed: 651 ins; 306 del; 209 mod
Patch: https://git.openjdk.org/jdk/pull/29049.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/29049/head:pull/29049
PR: https://git.openjdk.org/jdk/pull/29049
More information about the hotspot-dev
mailing list