< prev index next >

src/hotspot/share/runtime/objectMonitor.hpp

Print this page
rev 57560 : imported patch 8235795.patch.cr0


 113 //     same line for monitorexit. Putting these <remaining_fields>:
 114 //     _recursions, _EntryList, _cxq, and _succ, all of which may be
 115 //     fetched in the inflated unlock path, on a different cache line
 116 //     would make them immune to CAS-based invalidation from the _owner
 117 //     field.
 118 //
 119 //   - The _recursions field should be of type int, or int32_t but not
 120 //     intptr_t. There's no reason to use a 64-bit type for this field
 121 //     in a 64-bit JVM.
 122 
 123 class ObjectMonitor {
 124   friend class ObjectSynchronizer;
 125   friend class ObjectWaiter;
 126   friend class VMStructs;
 127   JVMCI_ONLY(friend class JVMCIVMStructs;)
 128 
 129   // The sync code expects the header field to be at offset zero (0).
 130   // Enforced by the assert() in header_addr().
 131   volatile markWord _header;        // displaced object header word - mark
 132   void* volatile _object;           // backward object pointer - strong root
 133  public:
 134   ObjectMonitor* _next_om;          // Next ObjectMonitor* linkage
 135  private:
 136   // Separate _header and _owner on different cache lines since both can
 137   // have busy multi-threaded access. _header and _object are set at
 138   // initial inflation and _object doesn't change until deflation so
 139   // _object is a good choice to share the cache line with _header.
 140   // _next_om shares _header's cache line for pre-monitor list historical
 141   // reasons. _next_om only changes if the next ObjectMonitor is deflated.
 142   DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE,
 143                         sizeof(volatile markWord) + sizeof(void* volatile) +
 144                         sizeof(ObjectMonitor *));
 145   void* volatile _owner;            // pointer to owning thread OR BasicLock
 146   volatile jlong _previous_owner_tid;  // thread id of the previous owner of the monitor









 147   volatile intx _recursions;        // recursion count, 0 for first entry
 148   ObjectWaiter* volatile _EntryList;  // Threads blocked on entry or reentry.
 149                                       // The list is actually composed of WaitNodes,
 150                                       // acting as proxies for Threads.
 151 
 152   ObjectWaiter* volatile _cxq;      // LL of recently-arrived threads blocked on entry.
 153   Thread* volatile _succ;           // Heir presumptive thread - used for futile wakeup throttling
 154   Thread* volatile _Responsible;
 155 
 156   volatile int _Spinner;            // for exit->spinner handoff optimization
 157   volatile int _SpinDuration;
 158 
 159   volatile jint  _contentions;      // Number of active contentions in enter(). It is used by is_busy()
 160                                     // along with other fields to determine if an ObjectMonitor can be
 161                                     // deflated. See ObjectSynchronizer::deflate_monitor().
 162  protected:
 163   ObjectWaiter* volatile _WaitSet;  // LL of threads wait()ing on the monitor
 164   volatile jint  _waiters;          // number of waiting threads
 165  private:
 166   volatile int _WaitSetLock;        // protects Wait Queue - simple spinlock




 113 //     same line for monitorexit. Putting these <remaining_fields>:
 114 //     _recursions, _EntryList, _cxq, and _succ, all of which may be
 115 //     fetched in the inflated unlock path, on a different cache line
 116 //     would make them immune to CAS-based invalidation from the _owner
 117 //     field.
 118 //
 119 //   - The _recursions field should be of type int, or int32_t but not
 120 //     intptr_t. There's no reason to use a 64-bit type for this field
 121 //     in a 64-bit JVM.
 122 
 123 class ObjectMonitor {
 124   friend class ObjectSynchronizer;
 125   friend class ObjectWaiter;
 126   friend class VMStructs;
 127   JVMCI_ONLY(friend class JVMCIVMStructs;)
 128 
 129   // The sync code expects the header field to be at offset zero (0).
 130   // Enforced by the assert() in header_addr().
 131   volatile markWord _header;        // displaced object header word - mark
 132   void* volatile _object;           // backward object pointer - strong root


 133  private:
 134   // Separate _header and _owner on different cache lines since both can
 135   // have busy multi-threaded access. _header and _object are set at
 136   // initial inflation and _object doesn't change until deflation so
 137   // _object is a good choice to share the cache line with _header.


 138   DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE,
 139                         sizeof(volatile markWord) + sizeof(void* volatile));

 140   void* volatile _owner;            // pointer to owning thread OR BasicLock
 141   volatile jlong _previous_owner_tid;  // thread id of the previous owner of the monitor
 142   // Separate _owner and _next_om on different cache lines since
 143   // both can have busy multi-threaded access. _previous_owner_tid is only
 144   // changed by ObjectMonitor::exit() so it is a good choice to share the
 145   // cache line with _owner.
 146   DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, sizeof(void* volatile) +
 147                         sizeof(volatile jlong));
 148  public:
 149   ObjectMonitor* _next_om;          // Next ObjectMonitor* linkage
 150  private:
 151   volatile intx _recursions;        // recursion count, 0 for first entry
 152   ObjectWaiter* volatile _EntryList;  // Threads blocked on entry or reentry.
 153                                       // The list is actually composed of WaitNodes,
 154                                       // acting as proxies for Threads.
 155 
 156   ObjectWaiter* volatile _cxq;      // LL of recently-arrived threads blocked on entry.
 157   Thread* volatile _succ;           // Heir presumptive thread - used for futile wakeup throttling
 158   Thread* volatile _Responsible;
 159 
 160   volatile int _Spinner;            // for exit->spinner handoff optimization
 161   volatile int _SpinDuration;
 162 
 163   volatile jint  _contentions;      // Number of active contentions in enter(). It is used by is_busy()
 164                                     // along with other fields to determine if an ObjectMonitor can be
 165                                     // deflated. See ObjectSynchronizer::deflate_monitor().
 166  protected:
 167   ObjectWaiter* volatile _WaitSet;  // LL of threads wait()ing on the monitor
 168   volatile jint  _waiters;          // number of waiting threads
 169  private:
 170   volatile int _WaitSetLock;        // protects Wait Queue - simple spinlock


< prev index next >