[master] Integrated: Read class from object header

Roman Kennke rkennke at openjdk.java.net
Thu Sep 16 14:20:33 UTC 2021


On Tue, 13 Jul 2021 12:20:56 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

> 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)

This pull request has now been integrated.

Changeset: 02606f25
Author:    Roman Kennke <rkennke at openjdk.org>
URL:       https://git.openjdk.java.net/lilliput/commit/02606f251d69735a1550f06828f9b5ef3f10122d
Stats:     245 lines in 24 files changed: 180 ins; 35 del; 30 mod

Read class from object header

Reviewed-by: shade

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

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


More information about the lilliput-dev mailing list