--- old/src/hotspot/share/runtime/objectMonitor.hpp 2019-08-28 15:03:30.106958426 -0400 +++ new/src/hotspot/share/runtime/objectMonitor.hpp 2019-08-28 15:03:29.914958433 -0400 @@ -126,6 +126,12 @@ // intptr_t. There's no reason to use a 64-bit type for this field // in a 64-bit JVM. +#ifndef OM_CACHE_LINE_SIZE +// Use DEFAULT_CACHE_LINE_SIZE if not already specified for +// the current build platform. +#define OM_CACHE_LINE_SIZE DEFAULT_CACHE_LINE_SIZE +#endif + class ObjectMonitor { public: enum { @@ -147,24 +153,39 @@ // Enforced by the assert() in header_addr(). volatile markWord _header; // displaced object header word - mark void* volatile _object; // backward object pointer - strong root + typedef enum { + Free = 0, // Free must be 0 for monitor to be free after memset(..,0,..). + New, + Old + } AllocationState; + AllocationState _allocation_state; 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, DEFAULT_CACHE_LINE_SIZE, - sizeof(volatile markWord) + sizeof(void* volatile) + - sizeof(ObjectMonitor *)); + // have busy multi-threaded access. _header, _object and _allocation_state + // are set at initial inflation. _object and _allocation_state don't + // change until deflation so _object and _allocation_state are good + // choices 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(AllocationState) + + sizeof(ObjectMonitor*)); // Used by async deflation as a marker in the _owner field: #define DEFLATER_MARKER reinterpret_cast(-1) protected: // protected for JvmtiRawMonitor void* volatile _owner; // pointer to owning thread OR BasicLock private: volatile jlong _previous_owner_tid; // thread id of the previous owner of the monitor + // Separate _owner and _ref_count 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)); + volatile jint _ref_count; // ref count for ObjectMonitor* and used by the async deflation + // protocol. See ObjectSynchronizer::deflate_monitor_using_JT(). protected: // protected for JvmtiRawMonitor volatile intptr_t _recursions; // recursion count, 0 for first entry ObjectWaiter* volatile _EntryList; // Threads blocked on entry or reentry. @@ -187,14 +208,6 @@ volatile jint _waiters; // number of waiting threads private: volatile int _WaitSetLock; // protects Wait Queue - simple spinlock - volatile jint _ref_count; // ref count for ObjectMonitor* and used by the async deflation - // protocol. See ObjectSynchronizer::deflate_monitor_using_JT(). - typedef enum { - Free = 0, // Free must be 0 for monitor to be free after memset(..,0,..). - New, - Old - } AllocationState; - AllocationState _allocation_state; public: static void Initialize();