src/hotspot/share/runtime/vmThread.cpp
changeset 49594 898ef81cbc0e
parent 49449 ef5d5d343e2a
child 50113 caf115bb98ad
equal deleted inserted replaced
49593:4dd58ecc9912 49594:898ef81cbc0e
   574       SafepointSynchronize::end();
   574       SafepointSynchronize::end();
   575     }
   575     }
   576   }
   576   }
   577 }
   577 }
   578 
   578 
       
   579 // A SkipGCALot object is used to elide the usual effect of gc-a-lot
       
   580 // over a section of execution by a thread. Currently, it's used only to
       
   581 // prevent re-entrant calls to GC.
       
   582 class SkipGCALot : public StackObj {
       
   583   private:
       
   584    bool _saved;
       
   585    Thread* _t;
       
   586 
       
   587   public:
       
   588 #ifdef ASSERT
       
   589     SkipGCALot(Thread* t) : _t(t) {
       
   590       _saved = _t->skip_gcalot();
       
   591       _t->set_skip_gcalot(true);
       
   592     }
       
   593 
       
   594     ~SkipGCALot() {
       
   595       assert(_t->skip_gcalot(), "Save-restore protocol invariant");
       
   596       _t->set_skip_gcalot(_saved);
       
   597     }
       
   598 #else
       
   599     SkipGCALot(Thread* t) { }
       
   600     ~SkipGCALot() { }
       
   601 #endif
       
   602 };
       
   603 
   579 void VMThread::execute(VM_Operation* op) {
   604 void VMThread::execute(VM_Operation* op) {
   580   Thread* t = Thread::current();
   605   Thread* t = Thread::current();
   581 
   606 
   582   if (!t->is_VM_thread()) {
   607   if (!t->is_VM_thread()) {
   583     SkipGCALot sgcalot(t);    // avoid re-entrant attempts to gc-a-lot
   608     SkipGCALot sgcalot(t);    // avoid re-entrant attempts to gc-a-lot