RFR: 8283710: JVMTI: Use BitSet for object marking [v7]

Roman Kennke rkennke at openjdk.java.net
Fri Apr 8 17:35:09 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.
> 
> In addition to that, marking objects in their header requires that the original header gets saved and restored. We only do that for 'interesting' headers, that is headers that have a stack-lock, monitor or hash-code. All other headers are reset to their default value. This means we are losing object's GC age. This is not catastrophic, but nontheless interferes with GC. 
> 
> JFR already has a datastructure called BitSet to support object marking without messing with object's headers. We can use that in JVMTI too.
> 
> Testing:
>  - [x] tier1
>  - [x] tier2
>  - [x] tier3
>  - [x] serviceability/jvmti
>  - [x] vmTestbase/nsk/jvmti

Roman Kennke has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 12 commits:

 - Merge branch 'master' into JDK-8283710
 - Move JFRBitSet typedef into its own header; Make _bitset a direct member, not dynamically allocated
 - Add comment describing ObjectBitSet
 - Refactor JVMTI usage of ObjectBitSet
 - Typedef ObjectBitSet<mtTracing> to JFRBitSet in JFR code
 - Rename BitSet to ObjectBitSet
 - Templatize BitSet for MEMFLAGS
 - Rename ObjectMarkerController -> ObjectMarker
 - Use (former JFR) BitSet for JVMTI object marking
 - Restore missing include
 - ... and 2 more: https://git.openjdk.java.net/jdk/compare/0a026759...9ea51d78

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

Changes: https://git.openjdk.java.net/jdk/pull/7964/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7964&range=06
  Stats: 774 lines in 12 files changed: 326 ins; 427 del; 21 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