< prev index next >

src/hotspot/share/gc/g1/g1RootProcessor.cpp

Print this page
rev 56301 : imported patch 8159984-slow

*** 69,94 **** G1RootProcessor::G1RootProcessor(G1CollectedHeap* g1h, uint n_workers) : _g1h(g1h), _process_strong_tasks(G1RP_PS_NumElements), _srs(n_workers), ! _lock(Mutex::leaf, "G1 Root Scanning barrier lock", false, Monitor::_safepoint_check_never), _n_workers_discovered_strong_classes(0) {} void G1RootProcessor::evacuate_roots(G1ParScanThreadState* pss, uint worker_i) { G1GCPhaseTimes* phase_times = _g1h->phase_times(); G1EvacPhaseTimesTracker timer(phase_times, pss, G1GCPhaseTimes::ExtRootScan, worker_i); G1EvacuationRootClosures* closures = pss->closures(); ! process_java_roots(closures, phase_times, worker_i); ! ! // This is the point where this worker thread will not find more strong CLDs/nmethods. ! // Report this so G1 can synchronize the strong and weak CLDs/nmethods processing. ! if (closures->trace_metadata()) { ! worker_has_discovered_all_strong_classes(); ! } process_vm_roots(closures, phase_times, worker_i); { // Now the CM ref_processor roots. --- 69,88 ---- G1RootProcessor::G1RootProcessor(G1CollectedHeap* g1h, uint n_workers) : _g1h(g1h), _process_strong_tasks(G1RP_PS_NumElements), _srs(n_workers), ! _lock(Mutex::leaf, "G1 Root Scan barrier lock", false, Monitor::_safepoint_check_never), _n_workers_discovered_strong_classes(0) {} void G1RootProcessor::evacuate_roots(G1ParScanThreadState* pss, uint worker_i) { G1GCPhaseTimes* phase_times = _g1h->phase_times(); G1EvacPhaseTimesTracker timer(phase_times, pss, G1GCPhaseTimes::ExtRootScan, worker_i); G1EvacuationRootClosures* closures = pss->closures(); ! process_java_roots(closures, phase_times, worker_i, closures->trace_metadata() /* notify_claimed_roots_done */); process_vm_roots(closures, phase_times, worker_i); { // Now the CM ref_processor roots.
*** 101,127 **** _g1h->ref_processor_cm()->weak_oops_do(closures->strong_oops()); } } if (closures->trace_metadata()) { ! { ! G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::WaitForStrongCLD, worker_i); ! // Barrier to make sure all workers passed ! // the strong CLD and strong nmethods phases. wait_until_all_strong_classes_discovered(); } - // Now take the complement of the strong CLDs. - G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::WeakCLDRoots, worker_i); - assert(closures->second_pass_weak_clds() != NULL, "Should be non-null if we are tracing metadata."); - ClassLoaderDataGraph::roots_cld_do(NULL, closures->second_pass_weak_clds()); - } else { - phase_times->record_time_secs(G1GCPhaseTimes::WaitForStrongCLD, worker_i, 0.0); - phase_times->record_time_secs(G1GCPhaseTimes::WeakCLDRoots, worker_i, 0.0); - assert(closures->second_pass_weak_clds() == NULL, "Should be null if not tracing metadata."); - } - _process_strong_tasks.all_tasks_completed(n_workers()); } // Adaptor to pass the closures to the strong roots in the VM. class StrongRootsClosures : public G1RootClosures { --- 95,109 ---- _g1h->ref_processor_cm()->weak_oops_do(closures->strong_oops()); } } if (closures->trace_metadata()) { ! G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::WaitForStrongRoots, worker_i); ! // Wait here to make sure all workers passed the strong nmethods phase. wait_until_all_strong_classes_discovered(); } _process_strong_tasks.all_tasks_completed(n_workers()); } // Adaptor to pass the closures to the strong roots in the VM. class StrongRootsClosures : public G1RootClosures {
*** 187,214 **** _process_strong_tasks.all_tasks_completed(n_workers()); } void G1RootProcessor::process_java_roots(G1RootClosures* closures, G1GCPhaseTimes* phase_times, ! uint worker_i) { ! // Iterating over the CLDG and the Threads are done early to allow us to ! // first process the strong CLDs and nmethods and then, after a barrier, ! // let the thread process the weak CLDs and nmethods. ! { ! G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::CLDGRoots, worker_i); ! if (_process_strong_tasks.try_claim_task(G1RP_PS_ClassLoaderDataGraph_oops_do)) { ! ClassLoaderDataGraph::roots_cld_do(closures->strong_clds(), closures->weak_clds()); ! } ! } ! { G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ThreadRoots, worker_i); bool is_par = n_workers() > 1; Threads::possibly_parallel_oops_do(is_par, closures->strong_oops(), closures->strong_codeblobs()); } } void G1RootProcessor::process_vm_roots(G1RootClosures* closures, G1GCPhaseTimes* phase_times, uint worker_i) { --- 169,205 ---- _process_strong_tasks.all_tasks_completed(n_workers()); } void G1RootProcessor::process_java_roots(G1RootClosures* closures, G1GCPhaseTimes* phase_times, ! uint worker_i, ! bool notify_claimed_roots_done) { ! // Iterating over the the threads is done early to allow us to make sure that ! // the "strong" nmethods are processed first using the strong closure. After a barrier, ! // let the thread process the weak nmethods. ! // The problem is that nmethods are claimed to avoid duplicate iteration. This is ! // a way to make sure that for these nmethods we always apply the strong closure. { G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ThreadRoots, worker_i); bool is_par = n_workers() > 1; Threads::possibly_parallel_oops_do(is_par, closures->strong_oops(), closures->strong_codeblobs()); } + + // This is the point where this worker thread will not find more strong nmethods. + // Report this so G1 can synchronize the strong and weak CLDs/nmethods processing. + if (notify_claimed_roots_done) { + worker_has_discovered_all_strong_classes(); + } + + { + G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::CLDGRoots, worker_i); + if (_process_strong_tasks.try_claim_task(G1RP_PS_ClassLoaderDataGraph_oops_do)) { + ClassLoaderDataGraph::roots_cld_do(closures->strong_clds(), closures->weak_clds()); + } + } } void G1RootProcessor::process_vm_roots(G1RootClosures* closures, G1GCPhaseTimes* phase_times, uint worker_i) {
< prev index next >