1 /*
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
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 "aot/aotLoader.hpp"
28 #include "classfile/stringTable.hpp"
29 #include "classfile/systemDictionary.hpp"
30 #include "code/codeCache.hpp"
31 #include "gc/g1/bufferingOopClosure.hpp"
32 #include "gc/g1/g1CodeBlobClosure.hpp"
33 #include "gc/g1/g1CollectedHeap.inline.hpp"
34 #include "gc/g1/g1CollectorState.hpp"
35 #include "gc/g1/g1GCPhaseTimes.hpp"
36 #include "gc/g1/g1Policy.hpp"
37 #include "gc/g1/g1RootClosures.hpp"
38 #include "gc/g1/g1RootProcessor.hpp"
39 #include "gc/g1/heapRegion.inline.hpp"
40 #include "memory/allocation.inline.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);
61 while ((uint)_n_workers_discovered_strong_classes != n_workers()) {
254 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_Universe_oops_do)) {
255 Universe::oops_do(strong_roots);
256 }
257 }
258
259 {
260 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::JNIRoots, worker_i);
261 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_JNIHandles_oops_do)) {
262 JNIHandles::oops_do(strong_roots);
263 }
264 }
265
266 {
267 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ObjectSynchronizerRoots, worker_i);
268 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_ObjectSynchronizer_oops_do)) {
269 ObjectSynchronizer::oops_do(strong_roots);
270 }
271 }
272
273 {
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 }
|
1 /*
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
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 "aot/aotLoader.hpp"
28 #include "classfile/stringTable.hpp"
29 #include "classfile/systemDictionary.hpp"
30 #include "code/codeCache.hpp"
31 #include "gc/g1/bufferingOopClosure.hpp"
32 #include "gc/g1/g1CodeBlobClosure.hpp"
33 #include "gc/g1/g1CollectedHeap.inline.hpp"
34 #include "gc/g1/g1CollectorState.hpp"
35 #include "gc/g1/g1GCPhaseTimes.hpp"
36 #include "gc/g1/g1Policy.hpp"
37 #include "gc/g1/g1RootClosures.hpp"
38 #include "gc/g1/g1RootProcessor.hpp"
39 #include "gc/g1/heapRegion.inline.hpp"
40 #include "memory/allocation.inline.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);
60 while ((uint)_n_workers_discovered_strong_classes != n_workers()) {
253 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_Universe_oops_do)) {
254 Universe::oops_do(strong_roots);
255 }
256 }
257
258 {
259 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::JNIRoots, worker_i);
260 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_JNIHandles_oops_do)) {
261 JNIHandles::oops_do(strong_roots);
262 }
263 }
264
265 {
266 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ObjectSynchronizerRoots, worker_i);
267 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_ObjectSynchronizer_oops_do)) {
268 ObjectSynchronizer::oops_do(strong_roots);
269 }
270 }
271
272 {
273 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ManagementRoots, worker_i);
274 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_Management_oops_do)) {
275 Management::oops_do(strong_roots);
276 }
277 }
278
279 {
280 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::JVMTIRoots, worker_i);
281 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_jvmti_oops_do)) {
282 JvmtiExport::oops_do(strong_roots);
283 }
284 }
285
286 #if INCLUDE_AOT
287 if (UseAOT) {
288 G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::AOTCodeRoots, worker_i);
289 if (!_process_strong_tasks.is_task_claimed(G1RP_PS_aot_oops_do)) {
290 AOTLoader::oops_do(strong_roots);
291 }
292 }
|