< prev index next >

src/hotspot/share/runtime/objectMonitor.inline.hpp

Print this page




  27 
  28 #include "runtime/atomic.hpp"
  29 
  30 inline intptr_t ObjectMonitor::is_entered(TRAPS) const {
  31   if (THREAD == _owner || THREAD->is_lock_owned((address) _owner)) {
  32     return 1;
  33   }
  34   return 0;
  35 }
  36 
  37 inline markWord ObjectMonitor::header() const {
  38   return Atomic::load(&_header);
  39 }
  40 
  41 inline volatile markWord* ObjectMonitor::header_addr() {
  42   assert((intptr_t)this == (intptr_t)&_header, "sync code expects this");
  43   return &_header;
  44 }
  45 
  46 inline void ObjectMonitor::set_header(markWord hdr) {
  47   Atomic::store(hdr, &_header);
  48 }
  49 
  50 inline jint ObjectMonitor::waiters() const {
  51   return _waiters;
  52 }
  53 
  54 inline void* ObjectMonitor::owner() const {
  55   return _owner;
  56 }
  57 
  58 inline void ObjectMonitor::clear() {
  59   assert(Atomic::load(&_header).value() != 0, "must be non-zero");
  60   assert(_contentions == 0, "must be 0: contentions=%d", _contentions);
  61   assert(_waiters == 0, "must be 0: waiters=%d", _waiters);
  62   assert(_recursions == 0, "must be 0: recursions=" INTX_FORMAT, _recursions);
  63   assert(_object != NULL, "must be non-NULL");
  64   assert(_owner == NULL, "must be NULL: owner=" INTPTR_FORMAT, p2i(_owner));
  65 
  66   Atomic::store(markWord::zero(), &_header);
  67   _object = NULL;
  68 }
  69 
  70 inline void* ObjectMonitor::object() const {
  71   return _object;
  72 }
  73 
  74 inline void* ObjectMonitor::object_addr() {
  75   return (void *)(&_object);
  76 }
  77 
  78 inline void ObjectMonitor::set_object(void* obj) {
  79   _object = obj;
  80 }
  81 
  82 // return number of threads contending for this monitor
  83 inline jint ObjectMonitor::contentions() const {
  84   return _contentions;
  85 }
  86 


  27 
  28 #include "runtime/atomic.hpp"
  29 
  30 inline intptr_t ObjectMonitor::is_entered(TRAPS) const {
  31   if (THREAD == _owner || THREAD->is_lock_owned((address) _owner)) {
  32     return 1;
  33   }
  34   return 0;
  35 }
  36 
  37 inline markWord ObjectMonitor::header() const {
  38   return Atomic::load(&_header);
  39 }
  40 
  41 inline volatile markWord* ObjectMonitor::header_addr() {
  42   assert((intptr_t)this == (intptr_t)&_header, "sync code expects this");
  43   return &_header;
  44 }
  45 
  46 inline void ObjectMonitor::set_header(markWord hdr) {
  47   Atomic::store(&_header, hdr);
  48 }
  49 
  50 inline jint ObjectMonitor::waiters() const {
  51   return _waiters;
  52 }
  53 
  54 inline void* ObjectMonitor::owner() const {
  55   return _owner;
  56 }
  57 
  58 inline void ObjectMonitor::clear() {
  59   assert(Atomic::load(&_header).value() != 0, "must be non-zero");
  60   assert(_contentions == 0, "must be 0: contentions=%d", _contentions);
  61   assert(_waiters == 0, "must be 0: waiters=%d", _waiters);
  62   assert(_recursions == 0, "must be 0: recursions=" INTX_FORMAT, _recursions);
  63   assert(_object != NULL, "must be non-NULL");
  64   assert(_owner == NULL, "must be NULL: owner=" INTPTR_FORMAT, p2i(_owner));
  65 
  66   Atomic::store(&_header, markWord::zero());
  67   _object = NULL;
  68 }
  69 
  70 inline void* ObjectMonitor::object() const {
  71   return _object;
  72 }
  73 
  74 inline void* ObjectMonitor::object_addr() {
  75   return (void *)(&_object);
  76 }
  77 
  78 inline void ObjectMonitor::set_object(void* obj) {
  79   _object = obj;
  80 }
  81 
  82 // return number of threads contending for this monitor
  83 inline jint ObjectMonitor::contentions() const {
  84   return _contentions;
  85 }
  86 
< prev index next >