< prev index next >

src/hotspot/share/runtime/vmThread.cpp

Print this page




 559 
 560     //
 561     //  Notify (potential) waiting Java thread(s) - lock without safepoint
 562     //  check so that sneaking is not possible
 563     { MutexLockerEx mu(VMOperationRequest_lock,
 564                        Mutex::_no_safepoint_check_flag);
 565       VMOperationRequest_lock->notify_all();
 566     }
 567 
 568     //
 569     // We want to make sure that we get to a safepoint regularly.
 570     //
 571     if (VMThread::no_op_safepoint_needed(true)) {
 572       HandleMark hm(VMThread::vm_thread());
 573       SafepointSynchronize::begin();
 574       SafepointSynchronize::end();
 575     }
 576   }
 577 }
 578 

























 579 void VMThread::execute(VM_Operation* op) {
 580   Thread* t = Thread::current();
 581 
 582   if (!t->is_VM_thread()) {
 583     SkipGCALot sgcalot(t);    // avoid re-entrant attempts to gc-a-lot
 584     // JavaThread or WatcherThread
 585     bool concurrent = op->evaluate_concurrently();
 586     // only blocking VM operations need to verify the caller's safepoint state:
 587     if (!concurrent) {
 588       t->check_for_valid_safepoint_state(true);
 589     }
 590 
 591     // New request from Java thread, evaluate prologue
 592     if (!op->doit_prologue()) {
 593       return;   // op was cancelled
 594     }
 595 
 596     // Setup VM_operations for execution
 597     op->set_calling_thread(t, Thread::get_priority(t));
 598 




 559 
 560     //
 561     //  Notify (potential) waiting Java thread(s) - lock without safepoint
 562     //  check so that sneaking is not possible
 563     { MutexLockerEx mu(VMOperationRequest_lock,
 564                        Mutex::_no_safepoint_check_flag);
 565       VMOperationRequest_lock->notify_all();
 566     }
 567 
 568     //
 569     // We want to make sure that we get to a safepoint regularly.
 570     //
 571     if (VMThread::no_op_safepoint_needed(true)) {
 572       HandleMark hm(VMThread::vm_thread());
 573       SafepointSynchronize::begin();
 574       SafepointSynchronize::end();
 575     }
 576   }
 577 }
 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 
 604 void VMThread::execute(VM_Operation* op) {
 605   Thread* t = Thread::current();
 606 
 607   if (!t->is_VM_thread()) {
 608     SkipGCALot sgcalot(t);    // avoid re-entrant attempts to gc-a-lot
 609     // JavaThread or WatcherThread
 610     bool concurrent = op->evaluate_concurrently();
 611     // only blocking VM operations need to verify the caller's safepoint state:
 612     if (!concurrent) {
 613       t->check_for_valid_safepoint_state(true);
 614     }
 615 
 616     // New request from Java thread, evaluate prologue
 617     if (!op->doit_prologue()) {
 618       return;   // op was cancelled
 619     }
 620 
 621     // Setup VM_operations for execution
 622     op->set_calling_thread(t, Thread::get_priority(t));
 623 


< prev index next >