8235795: replace monitor list mux{Acquire,Release}(&gListLock) with spin locks

Reviewed-by: dholmes, coleenp, rehn
This commit is contained in:
Daniel D. Daugherty 2020-02-05 11:40:20 -05:00
parent 8ff24c55ef
commit a7a82b0c79
6 changed files with 749 additions and 310 deletions

View file

@ -136,20 +136,22 @@ class ObjectMonitor {
// Enforced by the assert() in header_addr().
volatile markWord _header; // displaced object header word - mark
void* volatile _object; // backward object pointer - strong root
public:
ObjectMonitor* _next_om; // Next ObjectMonitor* linkage
private:
// Separate _header and _owner on different cache lines since both can
// have busy multi-threaded access. _header and _object are set at
// initial inflation and _object doesn't change until deflation so
// _object is a good choice to share the cache line with _header.
// _next_om shares _header's cache line for pre-monitor list historical
// reasons. _next_om only changes if the next ObjectMonitor is deflated.
DEFINE_PAD_MINUS_SIZE(0, OM_CACHE_LINE_SIZE,
sizeof(volatile markWord) + sizeof(void* volatile) +
sizeof(ObjectMonitor *));
sizeof(volatile markWord) + sizeof(void* volatile));
void* volatile _owner; // pointer to owning thread OR BasicLock
volatile jlong _previous_owner_tid; // thread id of the previous owner of the monitor
// Separate _owner and _next_om on different cache lines since
// both can have busy multi-threaded access. _previous_owner_tid is only
// changed by ObjectMonitor::exit() so it is a good choice to share the
// cache line with _owner.
DEFINE_PAD_MINUS_SIZE(1, OM_CACHE_LINE_SIZE, sizeof(void* volatile) +
sizeof(volatile jlong));
ObjectMonitor* _next_om; // Next ObjectMonitor* linkage
volatile intx _recursions; // recursion count, 0 for first entry
ObjectWaiter* volatile _EntryList; // Threads blocked on entry or reentry.
// The list is actually composed of WaitNodes,
@ -249,6 +251,14 @@ class ObjectMonitor {
// _owner field. Returns the prior value of the _owner field.
void* try_set_owner_from(void* old_value, void* new_value);
ObjectMonitor* next_om() const;
// Simply set _next_om field to new_value.
void set_next_om(ObjectMonitor* new_value);
// Try to set _next_om field to new_value if the current value matches
// old_value, using Atomic::cmpxchg(). Otherwise, does not change the
// _next_om field. Returns the prior value of the _next_om field.
ObjectMonitor* try_set_next_om(ObjectMonitor* old_value, ObjectMonitor* new_value);
jint waiters() const;
jint contentions() const;