26 #include "classfile/stringTable.hpp" |
26 #include "classfile/stringTable.hpp" |
27 #include "classfile/systemDictionary.hpp" |
27 #include "classfile/systemDictionary.hpp" |
28 #include "code/codeCache.hpp" |
28 #include "code/codeCache.hpp" |
29 #include "compiler/oopMap.hpp" |
29 #include "compiler/oopMap.hpp" |
30 #include "gc/shared/oopStorageParState.inline.hpp" |
30 #include "gc/shared/oopStorageParState.inline.hpp" |
|
31 #include "gc/shared/suspendibleThreadSet.hpp" |
31 #include "gc/z/zGlobals.hpp" |
32 #include "gc/z/zGlobals.hpp" |
32 #include "gc/z/zNMethodTable.hpp" |
33 #include "gc/z/zNMethodTable.hpp" |
33 #include "gc/z/zOopClosures.inline.hpp" |
34 #include "gc/z/zOopClosures.inline.hpp" |
34 #include "gc/z/zRootsIterator.hpp" |
35 #include "gc/z/zRootsIterator.hpp" |
35 #include "gc/z/zStat.hpp" |
36 #include "gc/z/zStat.hpp" |
50 |
51 |
51 static const ZStatSubPhase ZSubPhasePauseRootsSetup("Pause Roots Setup"); |
52 static const ZStatSubPhase ZSubPhasePauseRootsSetup("Pause Roots Setup"); |
52 static const ZStatSubPhase ZSubPhasePauseRoots("Pause Roots"); |
53 static const ZStatSubPhase ZSubPhasePauseRoots("Pause Roots"); |
53 static const ZStatSubPhase ZSubPhasePauseRootsTeardown("Pause Roots Teardown"); |
54 static const ZStatSubPhase ZSubPhasePauseRootsTeardown("Pause Roots Teardown"); |
54 static const ZStatSubPhase ZSubPhasePauseRootsUniverse("Pause Roots Universe"); |
55 static const ZStatSubPhase ZSubPhasePauseRootsUniverse("Pause Roots Universe"); |
55 static const ZStatSubPhase ZSubPhasePauseRootsJNIHandles("Pause Roots JNIHandles"); |
|
56 static const ZStatSubPhase ZSubPhasePauseRootsObjectSynchronizer("Pause Roots ObjectSynchronizer"); |
56 static const ZStatSubPhase ZSubPhasePauseRootsObjectSynchronizer("Pause Roots ObjectSynchronizer"); |
57 static const ZStatSubPhase ZSubPhasePauseRootsManagement("Pause Roots Management"); |
57 static const ZStatSubPhase ZSubPhasePauseRootsManagement("Pause Roots Management"); |
58 static const ZStatSubPhase ZSubPhasePauseRootsJVMTIExport("Pause Roots JVMTIExport"); |
58 static const ZStatSubPhase ZSubPhasePauseRootsJVMTIExport("Pause Roots JVMTIExport"); |
59 static const ZStatSubPhase ZSubPhasePauseRootsJVMTIWeakExport("Pause Roots JVMTIWeakExport"); |
59 static const ZStatSubPhase ZSubPhasePauseRootsJVMTIWeakExport("Pause Roots JVMTIWeakExport"); |
60 static const ZStatSubPhase ZSubPhasePauseRootsSystemDictionary("Pause Roots SystemDictionary"); |
60 static const ZStatSubPhase ZSubPhasePauseRootsSystemDictionary("Pause Roots SystemDictionary"); |
61 static const ZStatSubPhase ZSubPhasePauseRootsClassLoaderDataGraph("Pause Roots ClassLoaderDataGraph"); |
|
62 static const ZStatSubPhase ZSubPhasePauseRootsThreads("Pause Roots Threads"); |
61 static const ZStatSubPhase ZSubPhasePauseRootsThreads("Pause Roots Threads"); |
63 static const ZStatSubPhase ZSubPhasePauseRootsCodeCache("Pause Roots CodeCache"); |
62 static const ZStatSubPhase ZSubPhasePauseRootsCodeCache("Pause Roots CodeCache"); |
|
63 |
|
64 static const ZStatSubPhase ZSubPhaseConcurrentRootsSetup("Concurrent Roots Setup"); |
|
65 static const ZStatSubPhase ZSubPhaseConcurrentRoots("Concurrent Roots"); |
|
66 static const ZStatSubPhase ZSubPhaseConcurrentRootsTeardown("Concurrent Roots Teardown"); |
|
67 static const ZStatSubPhase ZSubPhaseConcurrentRootsJNIHandles("Concurrent Roots JNIHandles"); |
|
68 static const ZStatSubPhase ZSubPhaseConcurrentRootsClassLoaderDataGraph("Concurrent Roots ClassLoaderDataGraph"); |
64 |
69 |
65 static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup"); |
70 static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup"); |
66 static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots"); |
71 static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots"); |
67 static const ZStatSubPhase ZSubPhasePauseWeakRootsTeardown("Pause Weak Roots Teardown"); |
72 static const ZStatSubPhase ZSubPhasePauseWeakRootsTeardown("Pause Weak Roots Teardown"); |
68 static const ZStatSubPhase ZSubPhasePauseWeakRootsJVMTIWeakExport("Pause Weak Roots JVMTIWeakExport"); |
73 static const ZStatSubPhase ZSubPhasePauseWeakRootsJVMTIWeakExport("Pause Weak Roots JVMTIWeakExport"); |
126 } |
131 } |
127 } |
132 } |
128 } |
133 } |
129 |
134 |
130 ZRootsIterator::ZRootsIterator() : |
135 ZRootsIterator::ZRootsIterator() : |
131 _jni_handles_iter(JNIHandles::global_handles()), |
|
132 _universe(this), |
136 _universe(this), |
133 _object_synchronizer(this), |
137 _object_synchronizer(this), |
134 _management(this), |
138 _management(this), |
135 _jvmti_export(this), |
139 _jvmti_export(this), |
136 _jvmti_weak_export(this), |
140 _jvmti_weak_export(this), |
137 _system_dictionary(this), |
141 _system_dictionary(this), |
138 _jni_handles(this), |
|
139 _class_loader_data_graph(this), |
|
140 _threads(this), |
142 _threads(this), |
141 _code_cache(this) { |
143 _code_cache(this) { |
142 assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); |
144 assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); |
143 ZStatTimer timer(ZSubPhasePauseRootsSetup); |
145 ZStatTimer timer(ZSubPhasePauseRootsSetup); |
144 Threads::change_thread_claim_parity(); |
146 Threads::change_thread_claim_parity(); |
145 ClassLoaderDataGraph::clear_claimed_marks(); |
|
146 COMPILER2_PRESENT(DerivedPointerTable::clear()); |
147 COMPILER2_PRESENT(DerivedPointerTable::clear()); |
147 CodeCache::gc_prologue(); |
148 CodeCache::gc_prologue(); |
148 ZNMethodTable::gc_prologue(); |
149 ZNMethodTable::gc_prologue(); |
149 } |
150 } |
150 |
151 |
161 void ZRootsIterator::do_universe(ZRootsIteratorClosure* cl) { |
162 void ZRootsIterator::do_universe(ZRootsIteratorClosure* cl) { |
162 ZStatTimer timer(ZSubPhasePauseRootsUniverse); |
163 ZStatTimer timer(ZSubPhasePauseRootsUniverse); |
163 Universe::oops_do(cl); |
164 Universe::oops_do(cl); |
164 } |
165 } |
165 |
166 |
166 void ZRootsIterator::do_jni_handles(ZRootsIteratorClosure* cl) { |
|
167 ZStatTimer timer(ZSubPhasePauseRootsJNIHandles); |
|
168 _jni_handles_iter.oops_do(cl); |
|
169 } |
|
170 |
|
171 void ZRootsIterator::do_object_synchronizer(ZRootsIteratorClosure* cl) { |
167 void ZRootsIterator::do_object_synchronizer(ZRootsIteratorClosure* cl) { |
172 ZStatTimer timer(ZSubPhasePauseRootsObjectSynchronizer); |
168 ZStatTimer timer(ZSubPhasePauseRootsObjectSynchronizer); |
173 ObjectSynchronizer::oops_do(cl); |
169 ObjectSynchronizer::oops_do(cl); |
174 } |
170 } |
175 |
171 |
190 } |
186 } |
191 |
187 |
192 void ZRootsIterator::do_system_dictionary(ZRootsIteratorClosure* cl) { |
188 void ZRootsIterator::do_system_dictionary(ZRootsIteratorClosure* cl) { |
193 ZStatTimer timer(ZSubPhasePauseRootsSystemDictionary); |
189 ZStatTimer timer(ZSubPhasePauseRootsSystemDictionary); |
194 SystemDictionary::oops_do(cl); |
190 SystemDictionary::oops_do(cl); |
195 } |
|
196 |
|
197 void ZRootsIterator::do_class_loader_data_graph(ZRootsIteratorClosure* cl) { |
|
198 ZStatTimer timer(ZSubPhasePauseRootsClassLoaderDataGraph); |
|
199 CLDToOopClosure cld_cl(cl); |
|
200 ClassLoaderDataGraph::cld_do(&cld_cl); |
|
201 } |
191 } |
202 |
192 |
203 void ZRootsIterator::do_threads(ZRootsIteratorClosure* cl) { |
193 void ZRootsIterator::do_threads(ZRootsIteratorClosure* cl) { |
204 ZStatTimer timer(ZSubPhasePauseRootsThreads); |
194 ZStatTimer timer(ZSubPhasePauseRootsThreads); |
205 ResourceMark rm; |
195 ResourceMark rm; |
216 _universe.oops_do(cl); |
206 _universe.oops_do(cl); |
217 _object_synchronizer.oops_do(cl); |
207 _object_synchronizer.oops_do(cl); |
218 _management.oops_do(cl); |
208 _management.oops_do(cl); |
219 _jvmti_export.oops_do(cl); |
209 _jvmti_export.oops_do(cl); |
220 _system_dictionary.oops_do(cl); |
210 _system_dictionary.oops_do(cl); |
221 _jni_handles.oops_do(cl); |
|
222 _class_loader_data_graph.oops_do(cl); |
|
223 _threads.oops_do(cl); |
211 _threads.oops_do(cl); |
224 _code_cache.oops_do(cl); |
212 _code_cache.oops_do(cl); |
225 if (visit_jvmti_weak_export) { |
213 if (visit_jvmti_weak_export) { |
226 _jvmti_weak_export.oops_do(cl); |
214 _jvmti_weak_export.oops_do(cl); |
227 } |
215 } |
|
216 } |
|
217 |
|
218 ZConcurrentRootsIterator::ZConcurrentRootsIterator(bool marking) : |
|
219 _marking(marking), |
|
220 _sts_joiner(marking /* active */), |
|
221 _jni_handles_iter(JNIHandles::global_handles()), |
|
222 _jni_handles(this), |
|
223 _class_loader_data_graph(this) { |
|
224 ZStatTimer timer(ZSubPhaseConcurrentRootsSetup); |
|
225 if (_marking) { |
|
226 ClassLoaderDataGraph_lock->lock(); |
|
227 ClassLoaderDataGraph::clear_claimed_marks(); |
|
228 } |
|
229 } |
|
230 |
|
231 ZConcurrentRootsIterator::~ZConcurrentRootsIterator() { |
|
232 ZStatTimer timer(ZSubPhaseConcurrentRootsTeardown); |
|
233 if (_marking) { |
|
234 ClassLoaderDataGraph_lock->unlock(); |
|
235 } |
|
236 } |
|
237 |
|
238 void ZConcurrentRootsIterator::do_jni_handles(ZRootsIteratorClosure* cl) { |
|
239 ZStatTimer timer(ZSubPhaseConcurrentRootsJNIHandles); |
|
240 _jni_handles_iter.oops_do(cl); |
|
241 } |
|
242 |
|
243 void ZConcurrentRootsIterator::do_class_loader_data_graph(ZRootsIteratorClosure* cl) { |
|
244 ZStatTimer timer(ZSubPhaseConcurrentRootsClassLoaderDataGraph); |
|
245 CLDToOopClosure cld_cl(cl, _marking /* must_claim */); |
|
246 ClassLoaderDataGraph::cld_do(&cld_cl); |
|
247 } |
|
248 |
|
249 void ZConcurrentRootsIterator::oops_do(ZRootsIteratorClosure* cl) { |
|
250 ZStatTimer timer(ZSubPhaseConcurrentRoots); |
|
251 _jni_handles.oops_do(cl); |
|
252 _class_loader_data_graph.oops_do(cl); |
228 } |
253 } |
229 |
254 |
230 ZWeakRootsIterator::ZWeakRootsIterator() : |
255 ZWeakRootsIterator::ZWeakRootsIterator() : |
231 _jvmti_weak_export(this), |
256 _jvmti_weak_export(this), |
232 _jfr_weak(this) { |
257 _jfr_weak(this) { |