RFR: 8308603: Removing do_pending_ref/enclosing_ref from MetaspaceClosure

Ioi Lam iklam at openjdk.org
Tue May 23 01:53:50 UTC 2023


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

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

Commit messages:
 - 8308603: Removing do_pending_ref() and enclosing_ref() from MetaspaceClosure

Changes: https://git.openjdk.org/jdk/pull/14093/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14093&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8308603
  Stats: 129 lines in 4 files changed: 43 ins; 64 del; 22 mod
  Patch: https://git.openjdk.org/jdk/pull/14093.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14093/head:pull/14093

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


More information about the hotspot-runtime-dev mailing list