< prev index next >

src/hotspot/share/runtime/objectMonitor.hpp

Print this page




 218   // ObjectMonitor reference with an offset, we need to remove the tag
 219   // value in order to generate the proper address.
 220   //
 221   // We can either adjust the ObjectMonitor reference and then add the
 222   // offset or we can adjust the offset that is added to the ObjectMonitor
 223   // reference. The latter avoids an AGI (Address Generation Interlock)
 224   // stall so the helper macro adjusts the offset value that is returned
 225   // to the ObjectMonitor reference manipulation code:
 226   //
 227   #define OM_OFFSET_NO_MONITOR_VALUE_TAG(f) \
 228     ((ObjectMonitor::f ## _offset_in_bytes()) - markOopDesc::monitor_value)
 229 
 230   markOop   header() const;
 231   volatile markOop* header_addr();
 232   void      set_header(markOop hdr);
 233 
 234   intptr_t is_busy() const {
 235     // TODO-FIXME: assert _owner == null implies _recursions = 0
 236     return _contentions|_waiters|intptr_t(_owner)|intptr_t(_cxq)|intptr_t(_EntryList);
 237   }
 238   const char* is_busy_to_string(stringStream* ss);
 239 
 240   intptr_t  is_entered(Thread* current) const;
 241 
 242   void*     owner() const;
 243   void      set_owner(void* owner);
 244 
 245   jint      waiters() const;
 246 
 247   jint      contentions() const;
 248   intptr_t  recursions() const                                         { return _recursions; }
 249 
 250   // JVM/TI GetObjectMonitorUsage() needs this:
 251   ObjectWaiter* first_waiter()                                         { return _WaitSet; }
 252   ObjectWaiter* next_waiter(ObjectWaiter* o)                           { return o->_next; }
 253   Thread* thread_of_waiter(ObjectWaiter* o)                            { return o->_thread; }
 254 
 255  protected:
 256   // We don't typically expect or want the ctors or dtors to run.
 257   // normal ObjectMonitors are type-stable and immortal.
 258   ObjectMonitor() { ::memset((void *)this, 0, sizeof(*this)); }
 259 
 260   ~ObjectMonitor() {
 261     // TODO: Add asserts ...
 262     // _cxq == 0 _succ == NULL _owner == NULL _waiters == 0
 263     // _contentions == 0 _EntryList  == NULL etc
 264   }
 265 
 266  private:
 267   void Recycle() {
 268     // TODO: add stronger asserts ...
 269     // _cxq == 0 _succ == NULL _owner == NULL _waiters == 0
 270     // _contentions == 0 EntryList  == NULL
 271     // _recursions == 0 _WaitSet == NULL
 272     DEBUG_ONLY(stringStream ss;)
 273     assert((is_busy() | _recursions) == 0, "freeing in-use monitor: %s, "
 274            "recursions=" INTPTR_FORMAT, is_busy_to_string(&ss), _recursions);
 275     _succ          = NULL;
 276     _EntryList     = NULL;
 277     _cxq           = NULL;
 278     _WaitSet       = NULL;
 279     _recursions    = 0;
 280   }
 281 
 282  public:
 283 
 284   void*     object() const;
 285   void*     object_addr();
 286   void      set_object(void* obj);
 287 
 288   bool      check(TRAPS);       // true if the thread owns the monitor.
 289   void      check_slow(TRAPS);
 290   void      clear();
 291 
 292   void      enter(TRAPS);
 293   void      exit(bool not_suspended, TRAPS);
 294   void      wait(jlong millis, bool interruptable, TRAPS);




 218   // ObjectMonitor reference with an offset, we need to remove the tag
 219   // value in order to generate the proper address.
 220   //
 221   // We can either adjust the ObjectMonitor reference and then add the
 222   // offset or we can adjust the offset that is added to the ObjectMonitor
 223   // reference. The latter avoids an AGI (Address Generation Interlock)
 224   // stall so the helper macro adjusts the offset value that is returned
 225   // to the ObjectMonitor reference manipulation code:
 226   //
 227   #define OM_OFFSET_NO_MONITOR_VALUE_TAG(f) \
 228     ((ObjectMonitor::f ## _offset_in_bytes()) - markOopDesc::monitor_value)
 229 
 230   markOop   header() const;
 231   volatile markOop* header_addr();
 232   void      set_header(markOop hdr);
 233 
 234   intptr_t is_busy() const {
 235     // TODO-FIXME: assert _owner == null implies _recursions = 0
 236     return _contentions|_waiters|intptr_t(_owner)|intptr_t(_cxq)|intptr_t(_EntryList);
 237   }

 238 
 239   intptr_t  is_entered(Thread* current) const;
 240 
 241   void*     owner() const;
 242   void      set_owner(void* owner);
 243 
 244   jint      waiters() const;
 245 
 246   jint      contentions() const;
 247   intptr_t  recursions() const                                         { return _recursions; }
 248 
 249   // JVM/TI GetObjectMonitorUsage() needs this:
 250   ObjectWaiter* first_waiter()                                         { return _WaitSet; }
 251   ObjectWaiter* next_waiter(ObjectWaiter* o)                           { return o->_next; }
 252   Thread* thread_of_waiter(ObjectWaiter* o)                            { return o->_thread; }
 253 
 254  protected:
 255   // We don't typically expect or want the ctors or dtors to run.
 256   // normal ObjectMonitors are type-stable and immortal.
 257   ObjectMonitor() { ::memset((void *)this, 0, sizeof(*this)); }
 258 
 259   ~ObjectMonitor() {
 260     // TODO: Add asserts ...
 261     // _cxq == 0 _succ == NULL _owner == NULL _waiters == 0
 262     // _contentions == 0 _EntryList  == NULL etc
 263   }
 264 
 265  private:
 266   void Recycle() {
 267     // TODO: add stronger asserts ...
 268     // _cxq == 0 _succ == NULL _owner == NULL _waiters == 0
 269     // _contentions == 0 EntryList  == NULL
 270     // _recursions == 0 _WaitSet == NULL
 271     assert(((is_busy()|_recursions) == 0), "freeing inuse monitor");


 272     _succ          = NULL;
 273     _EntryList     = NULL;
 274     _cxq           = NULL;
 275     _WaitSet       = NULL;
 276     _recursions    = 0;
 277   }
 278 
 279  public:
 280 
 281   void*     object() const;
 282   void*     object_addr();
 283   void      set_object(void* obj);
 284 
 285   bool      check(TRAPS);       // true if the thread owns the monitor.
 286   void      check_slow(TRAPS);
 287   void      clear();
 288 
 289   void      enter(TRAPS);
 290   void      exit(bool not_suspended, TRAPS);
 291   void      wait(jlong millis, bool interruptable, TRAPS);


< prev index next >