215 // reference. The latter avoids an AGI (Address Generation Interlock)
216 // stall so the helper macro adjusts the offset value that is returned
217 // to the ObjectMonitor reference manipulation code:
218 //
219 #define OM_OFFSET_NO_MONITOR_VALUE_TAG(f) \
220 ((ObjectMonitor::f ## _offset_in_bytes()) - markWord::monitor_value)
221
222 markWord header() const;
223 volatile markWord* header_addr();
224 void set_header(markWord hdr);
225
226 intptr_t is_busy() const {
227 // TODO-FIXME: assert _owner == null implies _recursions = 0
228 return _contentions|_waiters|intptr_t(_owner)|intptr_t(_cxq)|intptr_t(_EntryList);
229 }
230 const char* is_busy_to_string(stringStream* ss);
231
232 intptr_t is_entered(Thread* current) const;
233
234 void* owner() const;
235 void set_owner(void* owner);
236
237 jint waiters() const;
238
239 jint contentions() const;
240 intx recursions() const { return _recursions; }
241
242 // JVM/TI GetObjectMonitorUsage() needs this:
243 ObjectWaiter* first_waiter() { return _WaitSet; }
244 ObjectWaiter* next_waiter(ObjectWaiter* o) { return o->_next; }
245 Thread* thread_of_waiter(ObjectWaiter* o) { return o->_thread; }
246
247 protected:
248 // We don't typically expect or want the ctors or dtors to run.
249 // normal ObjectMonitors are type-stable and immortal.
250 ObjectMonitor() { ::memset((void*)this, 0, sizeof(*this)); }
251
252 ~ObjectMonitor() {
253 // TODO: Add asserts ...
254 // _cxq == 0 _succ == NULL _owner == NULL _waiters == 0
255 // _contentions == 0 _EntryList == NULL etc
|
215 // reference. The latter avoids an AGI (Address Generation Interlock)
216 // stall so the helper macro adjusts the offset value that is returned
217 // to the ObjectMonitor reference manipulation code:
218 //
219 #define OM_OFFSET_NO_MONITOR_VALUE_TAG(f) \
220 ((ObjectMonitor::f ## _offset_in_bytes()) - markWord::monitor_value)
221
222 markWord header() const;
223 volatile markWord* header_addr();
224 void set_header(markWord hdr);
225
226 intptr_t is_busy() const {
227 // TODO-FIXME: assert _owner == null implies _recursions = 0
228 return _contentions|_waiters|intptr_t(_owner)|intptr_t(_cxq)|intptr_t(_EntryList);
229 }
230 const char* is_busy_to_string(stringStream* ss);
231
232 intptr_t is_entered(Thread* current) const;
233
234 void* owner() const;
235 // Clear _owner field; current value must match old_value.
236 void release_clear_owner(void* old_value);
237 // Simply set _owner field to new_value; current value must match old_value.
238 void set_owner_from(void* old_value, void* new_value);
239 // Simply set _owner field to self; current value must match basic_lock_p.
240 void set_owner_from_BasicLock(void* basic_lock_p, Thread* self);
241 // Try to set _owner field to new_value if the current value matches
242 // old_value. Otherwise, does not change the _owner field. Returns
243 // the prior value of the _owner field. try_set_owner_from() provides:
244 // <fence> compare-and-exchange <membar StoreLoad|StoreStore>
245 void* try_set_owner_from(void* old_value, void* new_value);
246
247 jint waiters() const;
248
249 jint contentions() const;
250 intx recursions() const { return _recursions; }
251
252 // JVM/TI GetObjectMonitorUsage() needs this:
253 ObjectWaiter* first_waiter() { return _WaitSet; }
254 ObjectWaiter* next_waiter(ObjectWaiter* o) { return o->_next; }
255 Thread* thread_of_waiter(ObjectWaiter* o) { return o->_thread; }
256
257 protected:
258 // We don't typically expect or want the ctors or dtors to run.
259 // normal ObjectMonitors are type-stable and immortal.
260 ObjectMonitor() { ::memset((void*)this, 0, sizeof(*this)); }
261
262 ~ObjectMonitor() {
263 // TODO: Add asserts ...
264 // _cxq == 0 _succ == NULL _owner == NULL _waiters == 0
265 // _contentions == 0 _EntryList == NULL etc
|