Skip to content
Permalink
Browse files

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

…pin locks

Reviewed-by: dholmes, coleenp, rehn
  • Loading branch information
Daniel D. Daugherty
Daniel D. Daugherty committed Feb 5, 2020
1 parent 8ff24c5 commit a7a82b0c7959c70329bc83ebb61a3cb9eced5157
@@ -1987,7 +1987,7 @@ void ObjectMonitor::print_debug_style_on(outputStream* st) const {
st->print_cr("(ObjectMonitor*) " INTPTR_FORMAT " = {", p2i(this));
st->print_cr(" _header = " INTPTR_FORMAT, header().value());
st->print_cr(" _object = " INTPTR_FORMAT, p2i(_object));
st->print_cr(" _next_om = " INTPTR_FORMAT, p2i(_next_om));
st->print_cr(" _next_om = " INTPTR_FORMAT, p2i(next_om()));
st->print_cr(" _pad_buf0 = {");
st->print_cr(" [0] = '\\0'");
st->print_cr(" ...");
@@ -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;
@@ -137,4 +137,24 @@ inline void* ObjectMonitor::try_set_owner_from(void* old_value, void* new_value)
return prev;
}

// The _next_om field can be concurrently read and modified so we
// use Atomic operations to disable compiler optimizations that
// might try to elide loading and/or storing this field.

inline ObjectMonitor* ObjectMonitor::next_om() const {
return Atomic::load(&_next_om);
}

// Simply set _next_om field to new_value.
inline void ObjectMonitor::set_next_om(ObjectMonitor* new_value) {
Atomic::store(&_next_om, new_value);
}

// Try to set _next_om field to new_value if the current value matches
// old_value. Otherwise, does not change the _next_om field. Returns
// the prior value of the _next_om field.
inline ObjectMonitor* ObjectMonitor::try_set_next_om(ObjectMonitor* old_value, ObjectMonitor* new_value) {
return Atomic::cmpxchg(&_next_om, old_value, new_value);
}

#endif // SHARE_RUNTIME_OBJECTMONITOR_INLINE_HPP

0 comments on commit a7a82b0

Please sign in to comment.
You can’t perform that action at this time.