src/share/vm/runtime/vmThread.cpp

Print this page




 553     // We want to make sure that we get to a safepoint regularly.
 554     //
 555     if (SafepointALot || SafepointSynchronize::is_cleanup_needed()) {
 556       long interval          = SafepointSynchronize::last_non_safepoint_interval();
 557       bool max_time_exceeded = GuaranteedSafepointInterval != 0 && (interval > GuaranteedSafepointInterval);
 558       if (SafepointALot || max_time_exceeded) {
 559         HandleMark hm(VMThread::vm_thread());
 560         SafepointSynchronize::begin();
 561         SafepointSynchronize::end();
 562       }
 563     }
 564   }
 565 }
 566 
 567 void VMThread::execute(VM_Operation* op) {
 568   Thread* t = Thread::current();
 569 
 570   if (!t->is_VM_thread()) {
 571     SkipGCALot sgcalot(t);    // avoid re-entrant attempts to gc-a-lot
 572     // JavaThread or WatcherThread



 573     t->check_for_valid_safepoint_state(true);

 574 
 575     // New request from Java thread, evaluate prologue
 576     if (!op->doit_prologue()) {
 577       return;   // op was cancelled
 578     }
 579 
 580     // Setup VM_operations for execution
 581     op->set_calling_thread(t, Thread::get_priority(t));
 582 
 583     // It does not make sense to execute the epilogue, if the VM operation object is getting
 584     // deallocated by the VM thread.
 585     bool concurrent     = op->evaluate_concurrently();
 586     bool execute_epilog = !op->is_cheap_allocated();
 587     assert(!concurrent || op->is_cheap_allocated(), "concurrent => cheap_allocated");
 588 
 589     // Get ticket number for non-concurrent VM operations
 590     int ticket = 0;
 591     if (!concurrent) {
 592       ticket = t->vm_operation_ticket();
 593     }
 594 
 595     // Add VM operation to list of waiting threads. We are guaranteed not to block while holding the
 596     // VMOperationQueue_lock, so we can block without a safepoint check. This allows vm operation requests
 597     // to be queued up during a safepoint synchronization.
 598     {
 599       VMOperationQueue_lock->lock_without_safepoint_check();
 600       bool ok = _vm_queue->add(op);
 601       op->set_timestamp(os::javaTimeMillis());
 602       VMOperationQueue_lock->notify();
 603       VMOperationQueue_lock->unlock();
 604       // VM_Operation got skipped
 605       if (!ok) {




 553     // We want to make sure that we get to a safepoint regularly.
 554     //
 555     if (SafepointALot || SafepointSynchronize::is_cleanup_needed()) {
 556       long interval          = SafepointSynchronize::last_non_safepoint_interval();
 557       bool max_time_exceeded = GuaranteedSafepointInterval != 0 && (interval > GuaranteedSafepointInterval);
 558       if (SafepointALot || max_time_exceeded) {
 559         HandleMark hm(VMThread::vm_thread());
 560         SafepointSynchronize::begin();
 561         SafepointSynchronize::end();
 562       }
 563     }
 564   }
 565 }
 566 
 567 void VMThread::execute(VM_Operation* op) {
 568   Thread* t = Thread::current();
 569 
 570   if (!t->is_VM_thread()) {
 571     SkipGCALot sgcalot(t);    // avoid re-entrant attempts to gc-a-lot
 572     // JavaThread or WatcherThread
 573     bool concurrent = op->evaluate_concurrently();
 574     // only blocking VM operations need to verify the caller's safepoint state:
 575     if (!concurrent) {
 576       t->check_for_valid_safepoint_state(true);
 577     }
 578 
 579     // New request from Java thread, evaluate prologue
 580     if (!op->doit_prologue()) {
 581       return;   // op was cancelled
 582     }
 583 
 584     // Setup VM_operations for execution
 585     op->set_calling_thread(t, Thread::get_priority(t));
 586 
 587     // It does not make sense to execute the epilogue, if the VM operation object is getting
 588     // deallocated by the VM thread.

 589     bool execute_epilog = !op->is_cheap_allocated();
 590     assert(!concurrent || op->is_cheap_allocated(), "concurrent => cheap_allocated");
 591 
 592     // Get ticket number for non-concurrent VM operations
 593     int ticket = 0;
 594     if (!concurrent) {
 595       ticket = t->vm_operation_ticket();
 596     }
 597 
 598     // Add VM operation to list of waiting threads. We are guaranteed not to block while holding the
 599     // VMOperationQueue_lock, so we can block without a safepoint check. This allows vm operation requests
 600     // to be queued up during a safepoint synchronization.
 601     {
 602       VMOperationQueue_lock->lock_without_safepoint_check();
 603       bool ok = _vm_queue->add(op);
 604       op->set_timestamp(os::javaTimeMillis());
 605       VMOperationQueue_lock->notify();
 606       VMOperationQueue_lock->unlock();
 607       // VM_Operation got skipped
 608       if (!ok) {