RFR: 8308603: Removing do_pending_ref/enclosing_ref from MetaspaceClosure
Calvin Cheung
ccheung at openjdk.org
Tue May 30 21:24:57 UTC 2023
On Tue, 23 May 2023 01:47:18 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> **The problem**
>
> MetaspaceClosure is used to traverse all *pointers* in the metaspace objects. It works recursively. A pointer is represented by the `MetaspaceClosure::Ref` type. For example, if you have
>
>
> InstanceKlass* a = ..., *b = ...;
> a->_super = b;
>
>
> When we are traversing the pointer `a->_super`, we create a `Ref` that records the address of `b` and `&a->super`. However, we currently don't remember the address of `a` in the `Ref`. As a result, when processing the `Ref` inside a `push(Ref* ref)` function, we need to call `MetaspaceClosure::enclousing_ref()` to get to `a`, so that we can mark pointers inside it.
>
> The reason for`do_pending_ref` is even more convoluted. Please see [JDK-8308603](https://bugs.openjdk.org/browse/JDK-8308603) for more details.
>
> **The fix**
>
> The code can be much more readable if we simply remember `a` in the `Ref`.
>
> **More info**
>
> A more in-depth discussion of the use of the MetaspaceClosure API in CDS can be found at:
> - https://github.com/iklam/tools/blob/main/NOTES/cds_status_2023.md#33-copying-of-class-metadata
Marked as reviewed by ccheung (Reviewer).
src/hotspot/share/cds/archiveBuilder.cpp line 468:
> 466: // ref->enclosing_obj() == 0x00001000 (the Array that contains the Method)
> 467: //
> 468: // We use the above informatio to mark the bitmap to indicate that there's a pointer on address 0x00001008.
typo: informatio -> information
-------------
PR Review: https://git.openjdk.org/jdk/pull/14093#pullrequestreview-1451832250
PR Review Comment: https://git.openjdk.org/jdk/pull/14093#discussion_r1210833365
More information about the hotspot-runtime-dev
mailing list