RFR: 8283710: JVMTI: GC abstraction for ObjectMarker

Roman Kennke rkennke at openjdk.java.net
Mon Mar 28 13:29:12 UTC 2022


JVMTI heap walking marks objects in order to track which have been visited already. In order to do that, it uses bits in the object header. Those are the same bits that are also used by some GCs to mark objects (the lowest two bits, also used by locking code). Some GCs also use the bits in order to indicate 'forwarded' objects, where the upper bits of the header represent the forward-pointer. In the case of Shenandoah, it's even more problematic because this happens concurrently, even while JVMTI heap walks can intercept. So far we carefully worked around that problem, but it becomes very problematic in Lilliput, where accesses to the Klass* also requires to decode the header, and figure out what bits means what.

Taking a step back, it should not be JVMTI's business to mess with GC marking bits. Instead, the GC should provide this functionality to JVMTI, and implement it in a way that is suitable for the active GC. For example, in Shenandoah GC we would probably rather use a marking bitmap instead of letting JVMTI mark in the object header.

I would like to propose a GC abstraction to enable this. The proposed change provides an abstract class ObjectMarker, a single implementation HeaderObjectMarker (https://github.com/openjdk/lilliput/pull/45 proposes another implementation that uses bitmaps) and an ObjectMarkerController which manages the lifecycle. IMO, this is cleaner than the current impl in jvmtiTagMap, it keeps all state in the ObjectMarker implementation, rather than using global state and separates concerns better.

Testing:
 - [x] tier1
 - [x] tier2
 - [ ] tier3

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

Commit messages:
 - Restore missing include
 - Simpler needs_reset handling
 - 8283710: JVMTI: GC abstraction for ObjectMarker

Changes: https://git.openjdk.java.net/jdk/pull/7964/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7964&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8283710
  Stats: 361 lines in 5 files changed: 222 ins; 133 del; 6 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7964.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7964/head:pull/7964

PR: https://git.openjdk.java.net/jdk/pull/7964


More information about the serviceability-dev mailing list