20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26
27 #include "classfile/stringTable.hpp"
28 #include "classfile/systemDictionary.hpp"
29 #include "code/codeCache.hpp"
30 #include "gc/g1/bufferingOopClosure.hpp"
31 #include "gc/g1/g1CodeBlobClosure.hpp"
32 #include "gc/g1/g1CollectedHeap.inline.hpp"
33 #include "gc/g1/g1CollectorState.hpp"
34 #include "gc/g1/g1GCPhaseTimes.hpp"
35 #include "gc/g1/g1Policy.hpp"
36 #include "gc/g1/g1RootClosures.hpp"
37 #include "gc/g1/g1RootProcessor.hpp"
38 #include "gc/g1/heapRegion.inline.hpp"
39 #include "memory/allocation.inline.hpp"
40 #include "runtime/fprofiler.hpp"
41 #include "runtime/mutex.hpp"
42 #include "services/management.hpp"
43
44 void G1RootProcessor::worker_has_discovered_all_strong_classes() {
45 assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
46
47 uint new_value = (uint)Atomic::add(1, &_n_workers_discovered_strong_classes);
48 if (new_value == n_workers()) {
49 // This thread is last. Notify the others.
50 MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag);
51 _lock.notify_all();
52 }
53 }
54
55 void G1RootProcessor::wait_until_all_strong_classes_discovered() {
56 assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
57
58 if ((uint)_n_workers_discovered_strong_classes != n_workers()) {
59 MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag);
273 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::FlatProfilerRoots, worker_i);
274 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_FlatProfiler_oops_do)) {
275 FlatProfiler::oops_do(strong_roots);
276 }
277 }
278
279 {
280 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ManagementRoots, worker_i);
281 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_Management_oops_do)) {
282 Management::oops_do(strong_roots);
283 }
284 }
285
286 {
287 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::JVMTIRoots, worker_i);
288 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_jvmti_oops_do)) {
289 JvmtiExport::oops_do(strong_roots);
290 }
291 }
292
293 {
294 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::SystemDictionaryRoots, worker_i);
295 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_SystemDictionary_oops_do)) {
296 SystemDictionary::roots_oops_do(strong_roots, weak_roots);
297 }
298 }
299 }
300
301 void G1RootProcessor::process_string_table_roots(G1RootClosures* closures,
302 G1GCPhaseTimes* phase_times,
303 uint worker_i) {
304 assert(closures->weak_oops() != NULL, "Should only be called when all roots are processed");
305 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::StringTableRoots, worker_i);
306 // All threads execute the following. A specific chunk of buckets
307 // from the StringTable are the individual tasks.
308 StringTable::possibly_parallel_oops_do(closures->weak_oops());
309 }
310
311 void G1RootProcessor::process_code_cache_roots(CodeBlobClosure* code_closure,
312 G1GCPhaseTimes* phase_times,
|
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26
27 #include "classfile/stringTable.hpp"
28 #include "classfile/systemDictionary.hpp"
29 #include "code/codeCache.hpp"
30 #include "gc/g1/bufferingOopClosure.hpp"
31 #include "gc/g1/g1CodeBlobClosure.hpp"
32 #include "gc/g1/g1CollectedHeap.inline.hpp"
33 #include "gc/g1/g1CollectorState.hpp"
34 #include "gc/g1/g1GCPhaseTimes.hpp"
35 #include "gc/g1/g1Policy.hpp"
36 #include "gc/g1/g1RootClosures.hpp"
37 #include "gc/g1/g1RootProcessor.hpp"
38 #include "gc/g1/heapRegion.inline.hpp"
39 #include "memory/allocation.inline.hpp"
40 #include "aot/aotLoader.hpp"
41 #include "runtime/fprofiler.hpp"
42 #include "runtime/mutex.hpp"
43 #include "services/management.hpp"
44
45 void G1RootProcessor::worker_has_discovered_all_strong_classes() {
46 assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
47
48 uint new_value = (uint)Atomic::add(1, &_n_workers_discovered_strong_classes);
49 if (new_value == n_workers()) {
50 // This thread is last. Notify the others.
51 MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag);
52 _lock.notify_all();
53 }
54 }
55
56 void G1RootProcessor::wait_until_all_strong_classes_discovered() {
57 assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
58
59 if ((uint)_n_workers_discovered_strong_classes != n_workers()) {
60 MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag);
274 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::FlatProfilerRoots, worker_i);
275 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_FlatProfiler_oops_do)) {
276 FlatProfiler::oops_do(strong_roots);
277 }
278 }
279
280 {
281 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ManagementRoots, worker_i);
282 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_Management_oops_do)) {
283 Management::oops_do(strong_roots);
284 }
285 }
286
287 {
288 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::JVMTIRoots, worker_i);
289 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_jvmti_oops_do)) {
290 JvmtiExport::oops_do(strong_roots);
291 }
292 }
293
294 #if INCLUDE_AOT
295 if (UseAOT) {
296 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::AOTCodeRoots, worker_i);
297 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_aot_oops_do)) {
298 AOTLoader::oops_do(strong_roots);
299 }
300 }
301 #endif
302
303 {
304 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::SystemDictionaryRoots, worker_i);
305 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_SystemDictionary_oops_do)) {
306 SystemDictionary::roots_oops_do(strong_roots, weak_roots);
307 }
308 }
309 }
310
311 void G1RootProcessor::process_string_table_roots(G1RootClosures* closures,
312 G1GCPhaseTimes* phase_times,
313 uint worker_i) {
314 assert(closures->weak_oops() != NULL, "Should only be called when all roots are processed");
315 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::StringTableRoots, worker_i);
316 // All threads execute the following. A specific chunk of buckets
317 // from the StringTable are the individual tasks.
318 StringTable::possibly_parallel_oops_do(closures->weak_oops());
319 }
320
321 void G1RootProcessor::process_code_cache_roots(CodeBlobClosure* code_closure,
322 G1GCPhaseTimes* phase_times,
|