> When inflating a monitor the `ObjectMonitor*` is written directly over the 
> `markWord` and any overwritten data is displaced into a displaced `markWord`. 
> This is problematic for concurrent GCs which needs extra care or looser 
> semantics to use this displaced data. In Lilliput this data also contains the 
> klass forcing this to be something that the GC has to take into account 
> everywhere.
> 
> This patch introduces an alternative solution where locking only uses the 
> lock bits of the `markWord` and inflation does not override and displace the 
> `markWord`. This is done by keeping associations between objects and 
> `ObjectMonitor*` in an external hash table. Different caching techniques are 
> used to speedup lookups from compiled code.
> 
> A diagnostic VM option is introduced called `UseObjectMonitorTable`. It is 
> only supported in combination with the LM_LIGHTWEIGHT locking mode (the 
> default). 
> 
> This patch has been evaluated to be performance neutral when 
> `UseObjectMonitorTable` is turned off (the default). 
> 
> Below is a more detailed explanation of this change and how `LM_LIGHTWEIGHT` 
> and `UseObjectMonitorTable` works.
> 
> # Cleanups
> 
> Cleaned up displaced header usage for:
>   * BasicLock
>     * Contains some Zero changes
>     * Renames one exported JVMCI field
>   * ObjectMonitor
>     * Updates comments and tests consistencies
> 
> # Refactoring
> 
> `ObjectMonitor::enter` has been refactored an a `ObjectMonitorContentionMark` 
> witness object has been introduced to the signatures. Which signals that the 
> contentions reference counter is being held. More details are given below in 
> the section about deflation.
> 
> The initial purpose of this was to allow `UseObjectMonitorTable` to interact 
> more seamlessly with the `ObjectMonitor::enter` code. 
> 
> _There is even more `ObjectMonitor` refactoring which can be done here to 
> create a more understandable and enforceable API. There are a handful of 
> invariants / assumptions which are not always explicitly asserted which could 
> be trivially abstracted and verified by the type system by using similar 
> witness objects._
> 
> # LightweightSynchronizer
> 
> Working on adapting and incorporating the following section as a comment in 
> the source code
> 
> ## Fast Locking
> 
>   CAS on locking bits in markWord. 
>   0b00 (Fast Locked) <--> 0b01 (Unlocked)
> 
>   When locking and 0b00 (Fast Locked) is observed, it may be beneficial to 
> avoid inflating by spinning a bit.
> 
>   If 0b10 (Inflated) is observed or there is to much contention or to long 
> critical sections for spinning to be feasible, inf...

Axel Boldt-Christmas has updated the pull request with a new target base due to 
a merge or a rebase. The incremental webrev excludes the unrelated changes 
brought in by the merge/rebase. The pull request contains 36 additional commits 
since the last revision:

 - Remove extra whitespace in UseObjectMonitorTableTest.java
 - Inline _table
 - Rename ObjectMonitorWorld to ObjectMonitorTable
 - Update comment basicLock.hpp
 - Remove const for InflateCause parameters in lightweightSynchronizer
 - Use [inc/dec]_no_safepoint_count directly instead of a conditionally created 
NoSafepointVerifier
 - Remove unnecessary assert
 - Rename _table_count to _items_count
 - Revert instanceKlass.cpp comment change
 - Merge tag 'jdk-24+10' into JDK-8315884
   
   Added tag jdk-24+10 for changeset 16df9c33
 - ... and 26 more: https://git.openjdk.org/jdk/compare/0cb42d5f...92a88366

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/20067/files
  - new: https://git.openjdk.org/jdk/pull/20067/files/ebf11542..92a88366

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=20067&range=09
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=20067&range=08-09

  Stats: 42239 lines in 1406 files changed: 24413 ins; 11582 del; 6244 mod
  Patch: https://git.openjdk.org/jdk/pull/20067.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20067/head:pull/20067

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

Reply via email to