< prev index next >

src/hotspot/share/runtime/vmThread.cpp

Print this page
rev 54213 : [mq]: 8220774-handshakealot-v3
rev 54214 : [mq]: 8220774-handshakealot-v4


 429   if (c_heap_allocated) {
 430     delete _cur_vm_operation;
 431   }
 432 }
 433 
 434 static VM_None    safepointALot_op("SafepointALot");
 435 static VM_Cleanup cleanup_op;
 436 
 437 class HandshakeALotTC : public ThreadClosure {
 438  public:
 439   virtual void do_thread(Thread* thread) {
 440 #ifdef ASSERT
 441     assert(thread->is_Java_thread(), "must be");
 442     JavaThread* jt = (JavaThread*)thread;
 443     jt->verify_states_for_handshake();
 444 #endif
 445   }
 446 };
 447 
 448 VM_Operation* VMThread::no_op_safepoint() {
 449   // Must check for handshakes first, since ops returns.
 450   if (HandshakeALot) {
 451     HandshakeALotTC haltc;
 452     Handshake::execute(&haltc);
 453   }
 454   // Check for a true cleanup first, trying to keep stats correct.
 455   long interval_ms = SafepointTracing::time_since_last_safepoint_ms();
 456   bool max_time_exceeded = GuaranteedSafepointInterval != 0 &&
 457                            (interval_ms >= GuaranteedSafepointInterval);
 458   if (max_time_exceeded && SafepointSynchronize::is_cleanup_needed()) {
 459     return &cleanup_op;
 460   }
 461   if (SafepointALot) {
 462     return &safepointALot_op;
 463   }
 464   // Nothing to be done.
 465   return NULL;
 466 }
 467 
 468 void VMThread::loop() {
 469   assert(_cur_vm_operation == NULL, "no current one should be executing");
 470 
 471   SafepointSynchronize::init(_vm_thread);
 472 
 473   while(true) {
 474     VM_Operation* safepoint_ops = NULL;


 614             // the completed count has been incremented; the waiting
 615             // thread may have already freed this memory.
 616             tty->print_cr("vm %s: %3.7f secs]", _cur_vm_operation->name(), secs);
 617           }
 618         } else {
 619           evaluate_operation(_cur_vm_operation);
 620         }
 621 
 622         _cur_vm_operation = NULL;
 623       }
 624     }
 625 
 626     //
 627     //  Notify (potential) waiting Java thread(s) - lock without safepoint
 628     //  check so that sneaking is not possible
 629     { MutexLockerEx mu(VMOperationRequest_lock,
 630                        Mutex::_no_safepoint_check_flag);
 631       VMOperationRequest_lock->notify_all();
 632     }
 633 
 634     //
 635     // We want to make sure that we get to a safepoint regularly.
 636     //
 637     if ((_cur_vm_operation = VMThread::no_op_safepoint()) != NULL) {
 638       HandleMark hm(VMThread::vm_thread());
 639       SafepointSynchronize::begin();
 640       SafepointSynchronize::end();
 641       _cur_vm_operation = NULL;
 642     }
 643   }
 644 }
 645 
 646 // A SkipGCALot object is used to elide the usual effect of gc-a-lot
 647 // over a section of execution by a thread. Currently, it's used only to
 648 // prevent re-entrant calls to GC.
 649 class SkipGCALot : public StackObj {
 650   private:
 651    bool _saved;
 652    Thread* _t;
 653 
 654   public:
 655 #ifdef ASSERT
 656     SkipGCALot(Thread* t) : _t(t) {




 429   if (c_heap_allocated) {
 430     delete _cur_vm_operation;
 431   }
 432 }
 433 
 434 static VM_None    safepointALot_op("SafepointALot");
 435 static VM_Cleanup cleanup_op;
 436 
 437 class HandshakeALotTC : public ThreadClosure {
 438  public:
 439   virtual void do_thread(Thread* thread) {
 440 #ifdef ASSERT
 441     assert(thread->is_Java_thread(), "must be");
 442     JavaThread* jt = (JavaThread*)thread;
 443     jt->verify_states_for_handshake();
 444 #endif
 445   }
 446 };
 447 
 448 VM_Operation* VMThread::no_op_safepoint() {
 449   // Check for handshakes first since we may need to return a VMop.
 450   if (HandshakeALot) {
 451     HandshakeALotTC haltc;
 452     Handshake::execute(&haltc);
 453   }
 454   // Check for a cleanup before SafepointALot to keep stats correct.
 455   long interval_ms = SafepointTracing::time_since_last_safepoint_ms();
 456   bool max_time_exceeded = GuaranteedSafepointInterval != 0 &&
 457                            (interval_ms >= GuaranteedSafepointInterval);
 458   if (max_time_exceeded && SafepointSynchronize::is_cleanup_needed()) {
 459     return &cleanup_op;
 460   }
 461   if (SafepointALot) {
 462     return &safepointALot_op;
 463   }
 464   // Nothing to be done.
 465   return NULL;
 466 }
 467 
 468 void VMThread::loop() {
 469   assert(_cur_vm_operation == NULL, "no current one should be executing");
 470 
 471   SafepointSynchronize::init(_vm_thread);
 472 
 473   while(true) {
 474     VM_Operation* safepoint_ops = NULL;


 614             // the completed count has been incremented; the waiting
 615             // thread may have already freed this memory.
 616             tty->print_cr("vm %s: %3.7f secs]", _cur_vm_operation->name(), secs);
 617           }
 618         } else {
 619           evaluate_operation(_cur_vm_operation);
 620         }
 621 
 622         _cur_vm_operation = NULL;
 623       }
 624     }
 625 
 626     //
 627     //  Notify (potential) waiting Java thread(s) - lock without safepoint
 628     //  check so that sneaking is not possible
 629     { MutexLockerEx mu(VMOperationRequest_lock,
 630                        Mutex::_no_safepoint_check_flag);
 631       VMOperationRequest_lock->notify_all();
 632     }
 633 
 634     // We want to make sure that we get to a safepoint regularly
 635     // even when executing VMops that don't require safepoints.

 636     if ((_cur_vm_operation = VMThread::no_op_safepoint()) != NULL) {
 637       HandleMark hm(VMThread::vm_thread());
 638       SafepointSynchronize::begin();
 639       SafepointSynchronize::end();
 640       _cur_vm_operation = NULL;
 641     }
 642   }
 643 }
 644 
 645 // A SkipGCALot object is used to elide the usual effect of gc-a-lot
 646 // over a section of execution by a thread. Currently, it's used only to
 647 // prevent re-entrant calls to GC.
 648 class SkipGCALot : public StackObj {
 649   private:
 650    bool _saved;
 651    Thread* _t;
 652 
 653   public:
 654 #ifdef ASSERT
 655     SkipGCALot(Thread* t) : _t(t) {


< prev index next >