RFR: 8374549: Extend MetaspaceClosure to cover non-MetaspaceObj types [v2]

Ashutosh Mehra asmehra at openjdk.org
Tue Jan 27 02:20:22 UTC 2026


On Mon, 26 Jan 2026 18:35:37 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> 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`.
>
> Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 19 additional commits since the last revision:
> 
>  - @ashu-mehra review comment -- make data_addr() function protected
>  - Merge branch 'master' into 8374549-extend-MetaspaceClosure-to-cover-non-MetaspaceObj-types
>  - 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
>  - ... and 9 more: https://git.openjdk.org/jdk/compare/79dbaf1e...5dd8b690

still looks good

There is windows debug build failure but I don't see any logs. Looks like the job didn't run.

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

Marked as reviewed by asmehra (Committer).

PR Review: https://git.openjdk.org/jdk/pull/29049#pullrequestreview-3708807715
PR Comment: https://git.openjdk.org/jdk/pull/29049#issuecomment-3802708136


More information about the hotspot-dev mailing list