< prev index next >

src/share/vm/memory/gcLocker.hpp

Print this page




 207 };
 208 
 209 
 210 // A No_Safepoint_Verifier object will throw an assertion failure if
 211 // the current thread passes a possible safepoint while this object is
 212 // instantiated. A safepoint, will either be: an oop allocation, blocking
 213 // on a Mutex or JavaLock, or executing a VM operation.
 214 //
 215 // If StrictSafepointChecks is turned off, it degrades into a No_GC_Verifier
 216 //
 217 class No_Safepoint_Verifier : public No_GC_Verifier {
 218  friend class Pause_No_Safepoint_Verifier;
 219 
 220  private:
 221   bool _activated;
 222   Thread *_thread;
 223  public:
 224 #ifdef ASSERT
 225   No_Safepoint_Verifier(bool activated = true, bool verifygc = true ) :
 226     No_GC_Verifier(verifygc),
 227     _activated(activated) {
 228     _thread = Thread::current();
 229     if (_activated) {






 230       _thread->_allow_allocation_count++;
 231       _thread->_allow_safepoint_count++;

 232     }






 233   }
 234 
 235   ~No_Safepoint_Verifier() {
 236     if (_activated) {
 237       _thread->_allow_allocation_count--;
 238       _thread->_allow_safepoint_count--;
 239     }
 240   }
 241 #else
 242   No_Safepoint_Verifier(bool activated = true, bool verifygc = true) : No_GC_Verifier(verifygc){}


 243   ~No_Safepoint_Verifier() {}
 244 #endif
 245 };
 246 
 247 // A Pause_No_Safepoint_Verifier is used to temporarily pause the
 248 // behavior of a No_Safepoint_Verifier object. If we are not in debug
 249 // mode then there is nothing to do. If the No_Safepoint_Verifier
 250 // object has an _activated value of false, then there is nothing to
 251 // do for safepoint and allocation checking, but there may still be
 252 // something to do for the underlying No_GC_Verifier object.
 253 
 254 class Pause_No_Safepoint_Verifier : public Pause_No_GC_Verifier {
 255  private:
 256   No_Safepoint_Verifier * _nsv;
 257 
 258  public:
 259 #ifdef ASSERT
 260   Pause_No_Safepoint_Verifier(No_Safepoint_Verifier * nsv)
 261     : Pause_No_GC_Verifier(nsv) {
 262 




 207 };
 208 
 209 
 210 // A No_Safepoint_Verifier object will throw an assertion failure if
 211 // the current thread passes a possible safepoint while this object is
 212 // instantiated. A safepoint, will either be: an oop allocation, blocking
 213 // on a Mutex or JavaLock, or executing a VM operation.
 214 //
 215 // If StrictSafepointChecks is turned off, it degrades into a No_GC_Verifier
 216 //
 217 class No_Safepoint_Verifier : public No_GC_Verifier {
 218  friend class Pause_No_Safepoint_Verifier;
 219 
 220  private:
 221   bool _activated;
 222   Thread *_thread;
 223  public:
 224 #ifdef ASSERT
 225   No_Safepoint_Verifier(bool activated = true, bool verifygc = true ) :
 226     No_GC_Verifier(verifygc),
 227     _activated(false) {
 228     _thread = Thread::current();
 229     if (activated) {
 230       enable();
 231     }
 232   }
 233 
 234   void enable() {
 235     assert(!_activated, "expected");
 236     _thread->_allow_allocation_count++;
 237     _thread->_allow_safepoint_count++;
 238     _activated = true;
 239   }
 240 
 241   void disable() {
 242     assert(_activated, "expected");
 243     _thread->_allow_allocation_count--;
 244     _thread->_allow_safepoint_count--;
 245     _activated = false;
 246   }
 247 
 248   ~No_Safepoint_Verifier() {
 249     if (_activated) {
 250       disable();

 251     }
 252   }
 253 #else
 254   No_Safepoint_Verifier(bool activated = true, bool verifygc = true) : No_GC_Verifier(verifygc){}
 255   void enable() {}
 256   void disable() {}
 257   ~No_Safepoint_Verifier() {}
 258 #endif
 259 };
 260 
 261 // A Pause_No_Safepoint_Verifier is used to temporarily pause the
 262 // behavior of a No_Safepoint_Verifier object. If we are not in debug
 263 // mode then there is nothing to do. If the No_Safepoint_Verifier
 264 // object has an _activated value of false, then there is nothing to
 265 // do for safepoint and allocation checking, but there may still be
 266 // something to do for the underlying No_GC_Verifier object.
 267 
 268 class Pause_No_Safepoint_Verifier : public Pause_No_GC_Verifier {
 269  private:
 270   No_Safepoint_Verifier * _nsv;
 271 
 272  public:
 273 #ifdef ASSERT
 274   Pause_No_Safepoint_Verifier(No_Safepoint_Verifier * nsv)
 275     : Pause_No_GC_Verifier(nsv) {
 276 


< prev index next >