1 /*
2 * Copyright (c) 2002, 2011, 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 *
33 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
34 #include "gc_implementation/parallelScavenge/psTasks.hpp"
35 #include "memory/iterator.hpp"
36 #include "memory/universe.hpp"
37 #include "oops/oop.inline.hpp"
38 #include "oops/oop.psgc.inline.hpp"
39 #include "runtime/fprofiler.hpp"
40 #include "runtime/thread.hpp"
41 #include "runtime/vmThread.hpp"
42 #include "services/management.hpp"
43 #include "utilities/taskqueue.hpp"
44
45 //
46 // ScavengeRootsTask
47 //
48
49 void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) {
50 assert(Universe::heap()->is_gc_active(), "called outside gc");
51
52 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
53 PSScavengeRootsClosure roots_closure(pm);
54
55 switch (_root_type) {
56 case universe:
57 Universe::oops_do(&roots_closure);
58 break;
59
60 case jni_handles:
61 JNIHandles::oops_do(&roots_closure);
62 break;
63
64 case threads:
65 {
66 ResourceMark rm;
67 Threads::oops_do(&roots_closure, NULL);
68 }
69 break;
70
71 case object_synchronizer:
72 ObjectSynchronizer::oops_do(&roots_closure);
73 break;
74
75 case flat_profiler:
76 FlatProfiler::oops_do(&roots_closure);
77 break;
78
79 case system_dictionary:
80 SystemDictionary::oops_do(&roots_closure);
81 break;
82
83 case management:
84 Management::oops_do(&roots_closure);
85 break;
86
87 case jvmti:
88 JvmtiExport::oops_do(&roots_closure);
89 break;
90
91
92 case code_cache:
93 {
94 CodeBlobToOopClosure each_scavengable_code_blob(&roots_closure, /*do_marking=*/ true);
95 CodeCache::scavenge_root_nmethods_do(&each_scavengable_code_blob);
96 }
97 break;
98
99 default:
100 fatal("Unknown root type");
101 }
102
103 // Do the real work
104 pm->drain_stacks(false);
105 }
106
107 //
108 // ThreadRootsTask
109 //
110
111 void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) {
112 assert(Universe::heap()->is_gc_active(), "called outside gc");
113
114 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
115 PSScavengeRootsClosure roots_closure(pm);
116 CodeBlobToOopClosure roots_in_blobs(&roots_closure, /*do_marking=*/ true);
117
118 if (_java_thread != NULL)
119 _java_thread->oops_do(&roots_closure, &roots_in_blobs);
120
121 if (_vm_thread != NULL)
122 _vm_thread->oops_do(&roots_closure, &roots_in_blobs);
123
124 // Do the real work
125 pm->drain_stacks(false);
126 }
127
128 //
129 // StealTask
130 //
131
132 StealTask::StealTask(ParallelTaskTerminator* t) :
133 _terminator(t) {}
134
135 void StealTask::do_it(GCTaskManager* manager, uint which) {
|
1 /*
2 * Copyright (c) 2002, 2012, 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 *
33 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
34 #include "gc_implementation/parallelScavenge/psTasks.hpp"
35 #include "memory/iterator.hpp"
36 #include "memory/universe.hpp"
37 #include "oops/oop.inline.hpp"
38 #include "oops/oop.psgc.inline.hpp"
39 #include "runtime/fprofiler.hpp"
40 #include "runtime/thread.hpp"
41 #include "runtime/vmThread.hpp"
42 #include "services/management.hpp"
43 #include "utilities/taskqueue.hpp"
44
45 //
46 // ScavengeRootsTask
47 //
48
49 void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) {
50 assert(Universe::heap()->is_gc_active(), "called outside gc");
51
52 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
53 PSScavengeRootsClosure</*promote_immediately=*/false> roots_closure(pm);
54 PSScavengeRootsClosure</*promote_immediately=*/true> roots_to_old_closure(pm);
55
56 switch (_root_type) {
57 case universe:
58 Universe::oops_do(&roots_closure);
59 break;
60
61 case jni_handles:
62 JNIHandles::oops_do(&roots_closure);
63 break;
64
65 case threads:
66 {
67 ResourceMark rm;
68 Threads::oops_do(&roots_closure, NULL);
69 }
70 break;
71
72 case object_synchronizer:
73 ObjectSynchronizer::oops_do(&roots_closure);
74 break;
75
76 case flat_profiler:
77 FlatProfiler::oops_do(&roots_closure);
78 break;
79
80 case system_dictionary:
81 SystemDictionary::oops_do(&roots_closure);
82 break;
83
84 case management:
85 Management::oops_do(&roots_closure);
86 break;
87
88 case jvmti:
89 JvmtiExport::oops_do(&roots_closure);
90 break;
91
92
93 case code_cache:
94 {
95 CodeBlobToOopClosure each_scavengable_code_blob(&roots_to_old_closure, /*do_marking=*/ true);
96 CodeCache::scavenge_root_nmethods_do(&each_scavengable_code_blob);
97 }
98 break;
99
100 default:
101 fatal("Unknown root type");
102 }
103
104 // Do the real work
105 pm->drain_stacks(false);
106 }
107
108 //
109 // ThreadRootsTask
110 //
111
112 void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) {
113 assert(Universe::heap()->is_gc_active(), "called outside gc");
114
115 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
116 PSScavengeRootsClosure</*promote_immediately=*/false> roots_closure(pm);
117 CodeBlobToOopClosure roots_in_blobs(&roots_closure, /*do_marking=*/ true);
118
119 if (_java_thread != NULL)
120 _java_thread->oops_do(&roots_closure, &roots_in_blobs);
121
122 if (_vm_thread != NULL)
123 _vm_thread->oops_do(&roots_closure, &roots_in_blobs);
124
125 // Do the real work
126 pm->drain_stacks(false);
127 }
128
129 //
130 // StealTask
131 //
132
133 StealTask::StealTask(ParallelTaskTerminator* t) :
134 _terminator(t) {}
135
136 void StealTask::do_it(GCTaskManager* manager, uint which) {
|