< prev index next >

src/hotspot/share/runtime/safepoint.cpp

Print this page
rev 54996 : Checkpoint latest preliminary review patches for full OpenJDK review; merge with 8222295.patch.
rev 54997 : imported patch dcubed.monitor_deflate_conc.v2.01
rev 55000 : [mq]: dcubed.monitor_deflate_conc.v2.04


 493 }
 494 
 495 // Wake up all threads, so they are ready to resume execution after the safepoint
 496 // operation has been carried out
 497 void SafepointSynchronize::end() {
 498   assert(Threads_lock->owned_by_self(), "must hold Threads_lock");
 499   EventSafepointEnd event;
 500   uint64_t safepoint_id = _safepoint_counter;
 501   assert(Thread::current()->is_VM_thread(), "Only VM thread can execute a safepoint");
 502 
 503   disarm_safepoint();
 504 
 505   Universe::heap()->safepoint_synchronize_end();
 506 
 507   SafepointTracing::end();
 508 
 509   post_safepoint_end_event(event, safepoint_id);
 510 }
 511 
 512 bool SafepointSynchronize::is_cleanup_needed() {
 513   // Need a safepoint if there are many monitors to deflate.
 514   if (ObjectSynchronizer::is_cleanup_needed()) return true;

 515   // Need a safepoint if some inline cache buffers is non-empty
 516   if (!InlineCacheBuffer::is_empty()) return true;
 517   if (StringTable::needs_rehashing()) return true;
 518   if (SymbolTable::needs_rehashing()) return true;
 519   return false;
 520 }
 521 
 522 class ParallelSPCleanupThreadClosure : public ThreadClosure {
 523 private:
 524   CodeBlobClosure* _nmethod_cl;
 525   DeflateMonitorCounters* _counters;
 526 
 527 public:
 528   ParallelSPCleanupThreadClosure(DeflateMonitorCounters* counters) :
 529     _nmethod_cl(UseCodeAging ? NMethodSweeper::prepare_reset_hotness_counters() : NULL),
 530     _counters(counters) {}
 531 
 532   void do_thread(Thread* thread) {




 533     ObjectSynchronizer::deflate_thread_local_monitors(thread, _counters);
 534     if (_nmethod_cl != NULL && thread->is_Java_thread() &&
 535         ! thread->is_Code_cache_sweeper_thread()) {
 536       JavaThread* jt = (JavaThread*) thread;
 537       jt->nmethods_do(_nmethod_cl);
 538     }
 539   }
 540 };
 541 
 542 class ParallelSPCleanupTask : public AbstractGangTask {
 543 private:
 544   SubTasksDone _subtasks;
 545   ParallelSPCleanupThreadClosure _cleanup_threads_cl;
 546   uint _num_workers;
 547   DeflateMonitorCounters* _counters;
 548 public:
 549   ParallelSPCleanupTask(uint num_workers, DeflateMonitorCounters* counters) :
 550     AbstractGangTask("Parallel Safepoint Cleanup"),
 551     _subtasks(SubTasksDone(SafepointSynchronize::SAFEPOINT_CLEANUP_NUM_TASKS)),
 552     _cleanup_threads_cl(ParallelSPCleanupThreadClosure(counters)),
 553     _num_workers(num_workers),
 554     _counters(counters) {}
 555 
 556   void work(uint worker_id) {
 557     uint64_t safepoint_id = SafepointSynchronize::safepoint_counter();
 558     // All threads deflate monitors and mark nmethods (if necessary).
 559     Threads::possibly_parallel_threads_do(true, &_cleanup_threads_cl);
 560 
 561     if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_DEFLATE_MONITORS)) {
 562       const char* name = "deflating global idle monitors";
 563       EventSafepointCleanupTask event;
 564       TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
 565       ObjectSynchronizer::deflate_idle_monitors(_counters);




 566 
 567       post_safepoint_cleanup_task_event(event, safepoint_id, name);
 568     }
 569 
 570     if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_UPDATE_INLINE_CACHES)) {
 571       const char* name = "updating inline caches";
 572       EventSafepointCleanupTask event;
 573       TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
 574       InlineCacheBuffer::update_inline_caches();
 575 
 576       post_safepoint_cleanup_task_event(event, safepoint_id, name);
 577     }
 578 
 579     if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_COMPILATION_POLICY)) {
 580       const char* name = "compilation policy safepoint handler";
 581       EventSafepointCleanupTask event;
 582       TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
 583       CompilationPolicy::policy()->do_safepoint_work();
 584 
 585       post_safepoint_cleanup_task_event(event, safepoint_id, name);




 493 }
 494 
 495 // Wake up all threads, so they are ready to resume execution after the safepoint
 496 // operation has been carried out
 497 void SafepointSynchronize::end() {
 498   assert(Threads_lock->owned_by_self(), "must hold Threads_lock");
 499   EventSafepointEnd event;
 500   uint64_t safepoint_id = _safepoint_counter;
 501   assert(Thread::current()->is_VM_thread(), "Only VM thread can execute a safepoint");
 502 
 503   disarm_safepoint();
 504 
 505   Universe::heap()->safepoint_synchronize_end();
 506 
 507   SafepointTracing::end();
 508 
 509   post_safepoint_end_event(event, safepoint_id);
 510 }
 511 
 512 bool SafepointSynchronize::is_cleanup_needed() {
 513   // Need a cleanup safepoint if there are too many monitors in use
 514   // and the monitor deflation needs to be done at a safepoint.
 515   if (ObjectSynchronizer::is_safepoint_deflation_needed()) return true;
 516   // Need a safepoint if some inline cache buffers is non-empty
 517   if (!InlineCacheBuffer::is_empty()) return true;
 518   if (StringTable::needs_rehashing()) return true;
 519   if (SymbolTable::needs_rehashing()) return true;
 520   return false;
 521 }
 522 
 523 class ParallelSPCleanupThreadClosure : public ThreadClosure {
 524 private:
 525   CodeBlobClosure* _nmethod_cl;
 526   DeflateMonitorCounters* _counters;
 527 
 528 public:
 529   ParallelSPCleanupThreadClosure(DeflateMonitorCounters* counters) :
 530     _nmethod_cl(UseCodeAging ? NMethodSweeper::prepare_reset_hotness_counters() : NULL),
 531     _counters(counters) {}
 532 
 533   void do_thread(Thread* thread) {
 534     // deflate_thread_local_monitors() handles or requests deflation of
 535     // this thread's idle monitors. If !AsyncDeflateIdleMonitors or if
 536     // there is a special cleanup request, deflation is handled now.
 537     // Otherwise, async deflation is requested via a flag.
 538     ObjectSynchronizer::deflate_thread_local_monitors(thread, _counters);
 539     if (_nmethod_cl != NULL && thread->is_Java_thread() &&
 540         ! thread->is_Code_cache_sweeper_thread()) {
 541       JavaThread* jt = (JavaThread*) thread;
 542       jt->nmethods_do(_nmethod_cl);
 543     }
 544   }
 545 };
 546 
 547 class ParallelSPCleanupTask : public AbstractGangTask {
 548 private:
 549   SubTasksDone _subtasks;
 550   ParallelSPCleanupThreadClosure _cleanup_threads_cl;
 551   uint _num_workers;
 552   DeflateMonitorCounters* _counters;
 553 public:
 554   ParallelSPCleanupTask(uint num_workers, DeflateMonitorCounters* counters) :
 555     AbstractGangTask("Parallel Safepoint Cleanup"),
 556     _subtasks(SubTasksDone(SafepointSynchronize::SAFEPOINT_CLEANUP_NUM_TASKS)),
 557     _cleanup_threads_cl(ParallelSPCleanupThreadClosure(counters)),
 558     _num_workers(num_workers),
 559     _counters(counters) {}
 560 
 561   void work(uint worker_id) {
 562     uint64_t safepoint_id = SafepointSynchronize::safepoint_counter();
 563     // All threads deflate monitors and mark nmethods (if necessary).
 564     Threads::possibly_parallel_threads_do(true, &_cleanup_threads_cl);
 565 
 566     if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_DEFLATE_MONITORS)) {
 567       const char* name = "deflating global idle monitors";
 568       EventSafepointCleanupTask event;
 569       TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
 570       // AsyncDeflateIdleMonitors only uses DeflateMonitorCounters
 571       // when a special cleanup has been requested.
 572       // Note: This logging output will include global idle monitor
 573       // elapsed times, but not global idle monitor deflation count.
 574       ObjectSynchronizer::do_safepoint_work(_counters);
 575 
 576       post_safepoint_cleanup_task_event(event, safepoint_id, name);
 577     }
 578 
 579     if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_UPDATE_INLINE_CACHES)) {
 580       const char* name = "updating inline caches";
 581       EventSafepointCleanupTask event;
 582       TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
 583       InlineCacheBuffer::update_inline_caches();
 584 
 585       post_safepoint_cleanup_task_event(event, safepoint_id, name);
 586     }
 587 
 588     if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_COMPILATION_POLICY)) {
 589       const char* name = "compilation policy safepoint handler";
 590       EventSafepointCleanupTask event;
 591       TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
 592       CompilationPolicy::policy()->do_safepoint_work();
 593 
 594       post_safepoint_cleanup_task_event(event, safepoint_id, name);


< prev index next >