********
Note: Updating the wiki for the upcoming CR7/v2.07/10-for-jdk14 review cycle. Changes have been made, but not yet sanity checked.
********
Table of Contents:
...
The purpose of this subsection is to provide background information about how ObjectMonitors move between the various lists. This project changes the way these movements are implemented, but does not change the movements themselves. For example, newly allocated blocks of ObjectMonitors are always prepending to the global free list; this is true in the baseline and is true in this project. One exception is the optional addition of the global wait list (see below).
ObjectMonitor Allocation Path
...
- ObjectMonitors are linked with objects by ObjectSynchronizer::inflate().
- An inflate() call by one JavaThread can race with an inflate() call by another JavaThread for the same object.
- When inflate() realizes that it failed to link an ObjectMonitor with the target object, it calls ObjectSynchronizer::om_release() to extract the ObjectMonitor from the JavaThread's in-use list and prepends it on the JavaThread's free list.
Note: Remember that ObjectSynchronizer::om_alloc() optimistically added the newly allocated ObjectMonitor to the JavaThread's in-use list. - When inflate() successfully links an ObjectMonitor with the target object, that ObjectMonitor stays on the JavaThread's in-use list.
The Lists and Which Threads Touch Them
- global free list:
- prepended to by JavaThreads that allocated a new block of ObjectMonitors (malloc time)
- prepended to by JavaThreads that are exiting (and have a non-empty per-thread free list)
- taken from the head by JavaThreads that need to allocate ObjectMonitor(s) for their per-thread free list (reprovision)
- prepended to by deflation done by:
- either the VMThread or a worker thread for safepoint based
- or the ServiceThread for async monitor deflation
- global in-use list:
- prepended to by JavaThreads that are exiting (and have a non-empty per-thread free list)
- extracted from by deflation done by:
- either the VMThread or a worker thread for safepoint based
- or the ServiceThread for async monitor deflation
- global wait list:
- only used when HandshakeAfterDeflateIdleMonitors == true
- prepended by the ServiceThread during async deflation
- entire list detached and prepended to the global free list by the ServiceThread during async deflation
- Note: The global wait list serves the same function as Carsten's gFreeListNextSafepoint list in his prototype.
- per-thread free list:
- prepended to by a JavaThread when it needs to allocate new ObjectMonitor(s) (reprovision)
- taken from the head by a JavaThread when it needs to allocate a new ObjectMonitor (inflation)
- prepended to by a JavaThread when it isn't able to link the object to the ObjectMonitor (failed inflation)
- entire list detached and prepended to the global free list when the JavaThread is exiting
- per-thread in-use list:
- prepended to by a JavaThread when it allocates a new ObjectMonitor (inflation, optimistically in-use)
- extracted from by deflation done by:
- either the VMThread or a worker thread for safepoint based
- or the ServiceThread for async monitor deflation
- entire list detached and prepended to the global in-use list when the JavaThread is exiting
Lock-Free Monitor List Management In Reality
...