8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
25 #define SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
26
27 #include "classfile/classLoaderDataGraph.hpp"
28 #include "gc/shared/oopStorageParState.inline.hpp"
29 #include "gc/shenandoah/shenandoahHeuristics.hpp"
30 #include "gc/shenandoah/shenandoahRootProcessor.hpp"
31 #include "gc/shenandoah/shenandoahTimingTracker.hpp"
32 #include "gc/shenandoah/shenandoahUtils.hpp"
33 #include "memory/resourceArea.hpp"
34
35 template <bool CONCURRENT>
36 ShenandoahJNIHandleRoots<CONCURRENT>::ShenandoahJNIHandleRoots() :
37 _itr(JNIHandles::global_handles()) {
38 }
39
40 template <bool CONCURRENT>
41 template <typename T>
42 void ShenandoahJNIHandleRoots<CONCURRENT>::oops_do(T* cl, uint worker_id) {
43 if (CONCURRENT) {
44 _itr.oops_do(cl);
45 } else {
46 ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
47 ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::JNIRoots, worker_id);
48 _itr.oops_do(cl);
49 }
50 }
51
52 template <typename IsAlive, typename KeepAlive>
53 void ShenandoahWeakRoots::oops_do(IsAlive* is_alive, KeepAlive* keep_alive, uint worker_id) {
54 _task.work<IsAlive, KeepAlive>(worker_id, is_alive, keep_alive);
55 }
56
57 template <typename ITR>
58 ShenandoahCodeCacheRoots<ITR>::ShenandoahCodeCacheRoots() {
59 nmethod::oops_do_marking_prologue();
60 }
61
62 template <typename ITR>
63 void ShenandoahCodeCacheRoots<ITR>::code_blobs_do(CodeBlobClosure* blob_cl, uint worker_id) {
64 ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
65 ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::CodeCacheRoots, worker_id);
66 _coderoots_iterator.possibly_parallel_blobs_do(blob_cl);
67 }
68
69 template <typename ITR>
70 ShenandoahCodeCacheRoots<ITR>::~ShenandoahCodeCacheRoots() {
71 nmethod::oops_do_marking_epilogue();
72 }
73
74 class ShenandoahParallelOopsDoThreadClosure : public ThreadClosure {
75 private:
76 OopClosure* _f;
168 _cld_roots.clds_do(clds, NULL, worker_id);
169 _thread_roots.threads_do(&tc_cl, worker_id);
170 }
171
172 template <typename IsAlive, typename KeepAlive>
173 void ShenandoahRootUpdater::roots_do(uint worker_id, IsAlive* is_alive, KeepAlive* keep_alive) {
174 CodeBlobToOopClosure update_blobs(keep_alive, CodeBlobToOopClosure::FixRelocations);
175 CLDToOopClosure clds(keep_alive, ClassLoaderData::_claim_strong);
176 CLDToOopClosure* weak_clds = ShenandoahHeap::heap()->unload_classes() ? NULL : &clds;
177
178 _serial_roots.oops_do(keep_alive, worker_id);
179 _jni_roots.oops_do(keep_alive, worker_id);
180
181 _thread_roots.oops_do(keep_alive, NULL, worker_id);
182 _cld_roots.clds_do(&clds, weak_clds, worker_id);
183
184 if(_update_code_cache) {
185 _code_roots.code_blobs_do(&update_blobs, worker_id);
186 }
187
188 _weak_roots.oops_do<IsAlive, KeepAlive>(is_alive, keep_alive, worker_id);
189 _dedup_roots.oops_do(is_alive, keep_alive, worker_id);
190 }
191
192 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
|
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
25 #define SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
26
27 #include "classfile/classLoaderDataGraph.hpp"
28 #include "classfile/stringTable.hpp"
29 #include "classfile/systemDictionary.hpp"
30 #include "gc/shared/oopStorageParState.inline.hpp"
31 #include "gc/shenandoah/shenandoahHeuristics.hpp"
32 #include "gc/shenandoah/shenandoahRootProcessor.hpp"
33 #include "gc/shenandoah/shenandoahTimingTracker.hpp"
34 #include "gc/shenandoah/shenandoahUtils.hpp"
35 #include "prims/resolvedMethodTable.hpp"
36 #include "memory/resourceArea.hpp"
37
38 template <bool CONCURRENT>
39 inline ShenandoahWeakRoot<CONCURRENT>::ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase) :
40 _itr(storage), _phase(phase) {
41 }
42
43 template <bool CONCURRENT>
44 template <typename Closure>
45 inline void ShenandoahWeakRoot<CONCURRENT>::oops_do(Closure* cl, uint worker_id) {
46 if (CONCURRENT) {
47 _itr.oops_do(cl);
48 } else {
49 ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
50 ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::ThreadRoots, worker_id);
51 _itr.oops_do(cl);
52 }
53 }
54
55 inline ShenandoahWeakRoot<false>::ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase) :
56 _itr(storage), _phase(phase) {
57 }
58
59 template <typename IsAliveClosure, typename KeepAliveClosure>
60 void ShenandoahWeakRoot<false /* concurrent */>::weak_oops_do(IsAliveClosure* is_alive, KeepAliveClosure* keep_alive, uint worker_id) {
61 ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
62 ShenandoahWorkerTimingsTracker timer(worker_times, _phase, worker_id);
63 _itr.weak_oops_do(is_alive, keep_alive);
64 }
65
66 template <bool CONCURRENT>
67 ShenandoahWeakRoots<CONCURRENT>::ShenandoahWeakRoots() :
68 _jni_roots(JNIHandles::weak_global_handles(), ShenandoahPhaseTimings::JNIWeakRoots),
69 _string_table_roots(StringTable::weak_storage(), ShenandoahPhaseTimings::StringTableRoots),
70 _resolved_method_table_roots(ResolvedMethodTable::weak_storage(), ShenandoahPhaseTimings::ResolvedMethodTableRoots),
71 _vm_roots(SystemDictionary::vm_weak_oop_storage(), ShenandoahPhaseTimings::VMWeakRoots) {
72 }
73
74 template <bool CONCURRENT>
75 template <typename Closure>
76 void ShenandoahWeakRoots<CONCURRENT>::oops_do(Closure* cl, uint worker_id) {
77 _jni_roots.oops_do(cl, worker_id);
78 _string_table_roots.oops_do(cl, worker_id);
79 _resolved_method_table_roots.oops_do(cl, worker_id);
80 _vm_roots.oops_do(cl, worker_id);
81 }
82
83 inline ShenandoahWeakRoots<false /* concurrent */>::ShenandoahWeakRoots() :
84 _jni_roots(JNIHandles::weak_global_handles(), ShenandoahPhaseTimings::JNIWeakRoots),
85 _string_table_roots(StringTable::weak_storage(), ShenandoahPhaseTimings::StringTableRoots),
86 _resolved_method_table_roots(ResolvedMethodTable::weak_storage(), ShenandoahPhaseTimings::ResolvedMethodTableRoots),
87 _vm_roots(SystemDictionary::vm_weak_oop_storage(), ShenandoahPhaseTimings::VMWeakRoots) {
88 }
89
90 template <typename IsAliveClosure, typename KeepAliveClosure>
91 void ShenandoahWeakRoots<false /* concurrent*/>::weak_oops_do(IsAliveClosure* is_alive, KeepAliveClosure* keep_alive, uint worker_id) {
92 _jni_roots.weak_oops_do(is_alive, keep_alive, worker_id);
93 _string_table_roots.weak_oops_do(is_alive, keep_alive, worker_id);
94 _resolved_method_table_roots.weak_oops_do(is_alive, keep_alive, worker_id);
95 _vm_roots.weak_oops_do(is_alive, keep_alive, worker_id);
96 }
97
98 template <typename Closure>
99 void ShenandoahWeakRoots<false /* concurrent */>::oops_do(Closure* cl, uint worker_id) {
100 AlwaysTrueClosure always_true;
101 weak_oops_do<AlwaysTrueClosure, Closure>(&always_true, cl, worker_id);
102 }
103
104 template <bool CONCURRENT>
105 ShenandoahJNIHandleRoots<CONCURRENT>::ShenandoahJNIHandleRoots() :
106 _itr(JNIHandles::global_handles()) {
107 }
108
109 template <bool CONCURRENT>
110 template <typename T>
111 void ShenandoahJNIHandleRoots<CONCURRENT>::oops_do(T* cl, uint worker_id) {
112 if (CONCURRENT) {
113 _itr.oops_do(cl);
114 } else {
115 ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
116 ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::JNIRoots, worker_id);
117 _itr.oops_do(cl);
118 }
119 }
120
121 template <typename ITR>
122 ShenandoahCodeCacheRoots<ITR>::ShenandoahCodeCacheRoots() {
123 nmethod::oops_do_marking_prologue();
124 }
125
126 template <typename ITR>
127 void ShenandoahCodeCacheRoots<ITR>::code_blobs_do(CodeBlobClosure* blob_cl, uint worker_id) {
128 ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
129 ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::CodeCacheRoots, worker_id);
130 _coderoots_iterator.possibly_parallel_blobs_do(blob_cl);
131 }
132
133 template <typename ITR>
134 ShenandoahCodeCacheRoots<ITR>::~ShenandoahCodeCacheRoots() {
135 nmethod::oops_do_marking_epilogue();
136 }
137
138 class ShenandoahParallelOopsDoThreadClosure : public ThreadClosure {
139 private:
140 OopClosure* _f;
232 _cld_roots.clds_do(clds, NULL, worker_id);
233 _thread_roots.threads_do(&tc_cl, worker_id);
234 }
235
236 template <typename IsAlive, typename KeepAlive>
237 void ShenandoahRootUpdater::roots_do(uint worker_id, IsAlive* is_alive, KeepAlive* keep_alive) {
238 CodeBlobToOopClosure update_blobs(keep_alive, CodeBlobToOopClosure::FixRelocations);
239 CLDToOopClosure clds(keep_alive, ClassLoaderData::_claim_strong);
240 CLDToOopClosure* weak_clds = ShenandoahHeap::heap()->unload_classes() ? NULL : &clds;
241
242 _serial_roots.oops_do(keep_alive, worker_id);
243 _jni_roots.oops_do(keep_alive, worker_id);
244
245 _thread_roots.oops_do(keep_alive, NULL, worker_id);
246 _cld_roots.clds_do(&clds, weak_clds, worker_id);
247
248 if(_update_code_cache) {
249 _code_roots.code_blobs_do(&update_blobs, worker_id);
250 }
251
252 _serial_weak_roots.weak_oops_do(is_alive, keep_alive, worker_id);
253 _weak_roots.weak_oops_do(is_alive, keep_alive, worker_id);
254 _dedup_roots.oops_do(is_alive, keep_alive, worker_id);
255 }
256
257 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
|