src/share/vm/memory/sharedHeap.cpp

Print this page

        

*** 157,186 **** } Monitor* SharedHeap::StrongRootsScope::_lock = new Monitor(Mutex::leaf, "StrongRootsScope lock", false); void SharedHeap::StrongRootsScope::mark_worker_done_with_threads(uint n_workers) { ! // The Thread work barrier is only needed by G1. // No need to use the barrier if this is single-threaded code. ! if (UseG1GC && n_workers > 0) { uint new_value = (uint)Atomic::add(1, &_n_workers_done_with_threads); if (new_value == n_workers) { // This thread is last. Notify the others. MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag); _lock->notify_all(); } } } void SharedHeap::StrongRootsScope::wait_until_all_workers_done_with_threads(uint n_workers) { // No need to use the barrier if this is single-threaded code. if (n_workers > 0 && (uint)_n_workers_done_with_threads != n_workers) { MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag); while ((uint)_n_workers_done_with_threads != n_workers) { _lock->wait(Mutex::_no_safepoint_check_flag, 0, false); } } } void SharedHeap::process_roots(bool activate_scope, ScanningOption so, OopClosure* strong_roots, --- 157,193 ---- } Monitor* SharedHeap::StrongRootsScope::_lock = new Monitor(Mutex::leaf, "StrongRootsScope lock", false); void SharedHeap::StrongRootsScope::mark_worker_done_with_threads(uint n_workers) { ! #if INCLUDE_ALL_GCS ! // The Thread work barrier is only needed by G1 Class Unloading. // No need to use the barrier if this is single-threaded code. ! if (UseG1GC && G1ClassUnloadingEnabled && n_workers > 0) { uint new_value = (uint)Atomic::add(1, &_n_workers_done_with_threads); if (new_value == n_workers) { // This thread is last. Notify the others. MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag); _lock->notify_all(); } } + #endif } void SharedHeap::StrongRootsScope::wait_until_all_workers_done_with_threads(uint n_workers) { + #if INCLUDE_ALL_GCS + assert(UseG1GC, "Currently only used by G1"); + assert(G1ClassUnloadingEnabled, "Currently only needed when doing G1 Class Unloading"); + // No need to use the barrier if this is single-threaded code. if (n_workers > 0 && (uint)_n_workers_done_with_threads != n_workers) { MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag); while ((uint)_n_workers_done_with_threads != n_workers) { _lock->wait(Mutex::_no_safepoint_check_flag, 0, false); } } + #endif } void SharedHeap::process_roots(bool activate_scope, ScanningOption so, OopClosure* strong_roots,