[master] RFR: Read class from object header [v4]

Roman Kennke rkennke at openjdk.java.net
Thu Sep 16 13:23:10 UTC 2021

> This changes the Hotspot runtime to load the Klass* from the header instead of the dedicated Klass* word. The dedicated word is only still used for verification and for access by generated code (the former will eventually go away, the latter will be implemented separately).
> Currently, this means we need to coordinate with the ObjectSynchronizer: when encountering a header that is a stack lock or a monitor, the header is displaced. Worse, if it is a stack-locked that is owned by a thread other than the calling thread, we must first inflate the lock to a full monitor. This is particularily bad for GCs. Luckily, most paths only do this at a safepoint, where we can actually safely access foreign stack locks and don't need to worry about inflation. Notably exception is concurrent marking by G1GC, which can cause inflation of locks, but it doesn't hurt very much.
> It's really bad for Shenandoah and ZGC, though: when relocating objects, GC needs to know the object size of the from-space copy. However, this can cause inflation, and inflation creates new WeakHandle in the resulting monitor, and that would be initialized with a from-space copy, which is a no-go during evacuation/relocation.
> That said, I have been told that work is under way to get rid of displaced headers altogether, which would neatly solve all those problems. I have no desire to make complicated workarounds for Shenandoah GC and ZGC. I disabled both in my own builds for now, and will implement them as soon as the monitor changes arrive.
> In a couple of places in GC we need to access the header carefully: when concurrently forwarding (by parallel GC threads), we need to ensure we access the Klass* from an unforwarded header, and must also ensure to avoid re-loading the Klass* once we have the good header (that is why so many asserts have been removed - they would potentially re-load the Klass* from a header that may now be forwarded).
> Testing:
>  - [x] tier1
>  - [x] tier2
>  - [x] hotspot_gc
> (all without Shenandoah and ZGC, see above)

Roman Kennke has updated the pull request incrementally with four additional commits since the last revision:

 - Rename oopDesc::narrow_klass() to narrow_klass_legacy()
 - Formatting changes
 - Re-shape ObjectSynchronizer::stable_mark() and add assert
 - Assert +UseCompressedClassPointers


  - all: https://git.openjdk.java.net/lilliput/pull/12/files
  - new: https://git.openjdk.java.net/lilliput/pull/12/files/1f9e5aef..f9c58407

 - full: https://webrevs.openjdk.java.net/?repo=lilliput&pr=12&range=03
 - incr: https://webrevs.openjdk.java.net/?repo=lilliput&pr=12&range=02-03

  Stats: 28 lines in 5 files changed: 2 ins; 2 del; 24 mod
  Patch: https://git.openjdk.java.net/lilliput/pull/12.diff
  Fetch: git fetch https://git.openjdk.java.net/lilliput pull/12/head:pull/12

PR: https://git.openjdk.java.net/lilliput/pull/12

More information about the lilliput-dev mailing list