28 #include "code/codeCache.hpp" |
28 #include "code/codeCache.hpp" |
29 #include "compiler/oopMap.hpp" |
29 #include "compiler/oopMap.hpp" |
30 #include "gc/shared/barrierSet.hpp" |
30 #include "gc/shared/barrierSet.hpp" |
31 #include "gc/shared/barrierSetNMethod.hpp" |
31 #include "gc/shared/barrierSetNMethod.hpp" |
32 #include "gc/shared/oopStorageParState.inline.hpp" |
32 #include "gc/shared/oopStorageParState.inline.hpp" |
|
33 #include "gc/shared/oopStorageSet.hpp" |
33 #include "gc/shared/suspendibleThreadSet.hpp" |
34 #include "gc/shared/suspendibleThreadSet.hpp" |
34 #include "gc/z/zBarrierSetNMethod.hpp" |
35 #include "gc/z/zBarrierSetNMethod.hpp" |
35 #include "gc/z/zGlobals.hpp" |
36 #include "gc/z/zGlobals.hpp" |
36 #include "gc/z/zNMethod.hpp" |
37 #include "gc/z/zNMethod.hpp" |
37 #include "gc/z/zOopClosures.inline.hpp" |
38 #include "gc/z/zOopClosures.inline.hpp" |
41 #include "memory/resourceArea.hpp" |
42 #include "memory/resourceArea.hpp" |
42 #include "memory/universe.hpp" |
43 #include "memory/universe.hpp" |
43 #include "prims/jvmtiExport.hpp" |
44 #include "prims/jvmtiExport.hpp" |
44 #include "prims/resolvedMethodTable.hpp" |
45 #include "prims/resolvedMethodTable.hpp" |
45 #include "runtime/atomic.hpp" |
46 #include "runtime/atomic.hpp" |
46 #include "runtime/jniHandles.hpp" |
|
47 #include "runtime/thread.hpp" |
47 #include "runtime/thread.hpp" |
48 #include "runtime/safepoint.hpp" |
48 #include "runtime/safepoint.hpp" |
49 #include "runtime/synchronizer.hpp" |
49 #include "runtime/synchronizer.hpp" |
50 #include "services/management.hpp" |
50 #include "services/management.hpp" |
51 #include "utilities/debug.hpp" |
51 #include "utilities/debug.hpp" |
67 |
67 |
68 static const ZStatSubPhase ZSubPhaseConcurrentRootsSetup("Concurrent Roots Setup"); |
68 static const ZStatSubPhase ZSubPhaseConcurrentRootsSetup("Concurrent Roots Setup"); |
69 static const ZStatSubPhase ZSubPhaseConcurrentRoots("Concurrent Roots"); |
69 static const ZStatSubPhase ZSubPhaseConcurrentRoots("Concurrent Roots"); |
70 static const ZStatSubPhase ZSubPhaseConcurrentRootsTeardown("Concurrent Roots Teardown"); |
70 static const ZStatSubPhase ZSubPhaseConcurrentRootsTeardown("Concurrent Roots Teardown"); |
71 static const ZStatSubPhase ZSubPhaseConcurrentRootsJNIHandles("Concurrent Roots JNIHandles"); |
71 static const ZStatSubPhase ZSubPhaseConcurrentRootsJNIHandles("Concurrent Roots JNIHandles"); |
|
72 static const ZStatSubPhase ZSubPhaseConcurrentRootsVMHandles("Concurrent Roots VMHandles"); |
72 static const ZStatSubPhase ZSubPhaseConcurrentRootsClassLoaderDataGraph("Concurrent Roots ClassLoaderDataGraph"); |
73 static const ZStatSubPhase ZSubPhaseConcurrentRootsClassLoaderDataGraph("Concurrent Roots ClassLoaderDataGraph"); |
73 |
74 |
74 static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup"); |
75 static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup"); |
75 static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots"); |
76 static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots"); |
76 static const ZStatSubPhase ZSubPhasePauseWeakRootsTeardown("Pause Weak Roots Teardown"); |
77 static const ZStatSubPhase ZSubPhasePauseWeakRootsTeardown("Pause Weak Roots Teardown"); |
245 void ZRootsIterator::do_code_cache(ZRootsIteratorClosure* cl) { |
247 void ZRootsIterator::do_code_cache(ZRootsIteratorClosure* cl) { |
246 ZStatTimer timer(ZSubPhasePauseRootsCodeCache); |
248 ZStatTimer timer(ZSubPhasePauseRootsCodeCache); |
247 ZNMethod::oops_do(cl); |
249 ZNMethod::oops_do(cl); |
248 } |
250 } |
249 |
251 |
250 void ZRootsIterator::oops_do(ZRootsIteratorClosure* cl, bool visit_jvmti_weak_export) { |
252 void ZRootsIterator::oops_do(ZRootsIteratorClosure* cl) { |
251 ZStatTimer timer(ZSubPhasePauseRoots); |
253 ZStatTimer timer(ZSubPhasePauseRoots); |
252 _universe.oops_do(cl); |
254 _universe.oops_do(cl); |
253 _object_synchronizer.oops_do(cl); |
255 _object_synchronizer.oops_do(cl); |
254 _management.oops_do(cl); |
256 _management.oops_do(cl); |
255 _jvmti_export.oops_do(cl); |
257 _jvmti_export.oops_do(cl); |
256 _system_dictionary.oops_do(cl); |
258 _system_dictionary.oops_do(cl); |
257 _threads.oops_do(cl); |
259 _threads.oops_do(cl); |
258 if (!ClassUnloading) { |
260 if (!ClassUnloading) { |
259 _code_cache.oops_do(cl); |
261 _code_cache.oops_do(cl); |
260 } |
262 } |
261 if (visit_jvmti_weak_export) { |
263 if (_visit_jvmti_weak_export) { |
262 _jvmti_weak_export.oops_do(cl); |
264 _jvmti_weak_export.oops_do(cl); |
263 } |
265 } |
264 } |
266 } |
265 |
267 |
266 ZConcurrentRootsIterator::ZConcurrentRootsIterator(bool marking) : |
268 ZConcurrentRootsIterator::ZConcurrentRootsIterator(int cld_claim) : |
267 _marking(marking), |
269 _jni_handles_iter(OopStorageSet::jni_global()), |
268 _sts_joiner(marking /* active */), |
270 _vm_handles_iter(OopStorageSet::vm_global()), |
269 _jni_handles_iter(JNIHandles::global_handles()), |
271 _cld_claim(cld_claim), |
270 _jni_handles(this), |
272 _jni_handles(this), |
|
273 _vm_handles(this), |
271 _class_loader_data_graph(this) { |
274 _class_loader_data_graph(this) { |
272 ZStatTimer timer(ZSubPhaseConcurrentRootsSetup); |
275 ZStatTimer timer(ZSubPhaseConcurrentRootsSetup); |
273 if (_marking) { |
276 ClassLoaderDataGraph::clear_claimed_marks(cld_claim); |
274 ClassLoaderDataGraph_lock->lock(); |
|
275 ClassLoaderDataGraph::clear_claimed_marks(); |
|
276 } |
|
277 } |
277 } |
278 |
278 |
279 ZConcurrentRootsIterator::~ZConcurrentRootsIterator() { |
279 ZConcurrentRootsIterator::~ZConcurrentRootsIterator() { |
280 ZStatTimer timer(ZSubPhaseConcurrentRootsTeardown); |
280 ZStatTimer timer(ZSubPhaseConcurrentRootsTeardown); |
281 if (_marking) { |
|
282 ClassLoaderDataGraph_lock->unlock(); |
|
283 } |
|
284 } |
281 } |
285 |
282 |
286 void ZConcurrentRootsIterator::do_jni_handles(ZRootsIteratorClosure* cl) { |
283 void ZConcurrentRootsIterator::do_jni_handles(ZRootsIteratorClosure* cl) { |
287 ZStatTimer timer(ZSubPhaseConcurrentRootsJNIHandles); |
284 ZStatTimer timer(ZSubPhaseConcurrentRootsJNIHandles); |
288 _jni_handles_iter.oops_do(cl); |
285 _jni_handles_iter.oops_do(cl); |
289 } |
286 } |
290 |
287 |
|
288 void ZConcurrentRootsIterator::do_vm_handles(ZRootsIteratorClosure* cl) { |
|
289 ZStatTimer timer(ZSubPhaseConcurrentRootsVMHandles); |
|
290 _vm_handles_iter.oops_do(cl); |
|
291 } |
|
292 |
291 void ZConcurrentRootsIterator::do_class_loader_data_graph(ZRootsIteratorClosure* cl) { |
293 void ZConcurrentRootsIterator::do_class_loader_data_graph(ZRootsIteratorClosure* cl) { |
292 ZStatTimer timer(ZSubPhaseConcurrentRootsClassLoaderDataGraph); |
294 ZStatTimer timer(ZSubPhaseConcurrentRootsClassLoaderDataGraph); |
293 if (_marking) { |
295 CLDToOopClosure cld_cl(cl, _cld_claim); |
294 CLDToOopClosure cld_cl(cl, ClassLoaderData::_claim_strong); |
296 ClassLoaderDataGraph::always_strong_cld_do(&cld_cl); |
295 ClassLoaderDataGraph::always_strong_cld_do(&cld_cl); |
|
296 } else { |
|
297 CLDToOopClosure cld_cl(cl, ClassLoaderData::_claim_none); |
|
298 ClassLoaderDataGraph::cld_do(&cld_cl); |
|
299 } |
|
300 } |
297 } |
301 |
298 |
302 void ZConcurrentRootsIterator::oops_do(ZRootsIteratorClosure* cl) { |
299 void ZConcurrentRootsIterator::oops_do(ZRootsIteratorClosure* cl) { |
303 ZStatTimer timer(ZSubPhaseConcurrentRoots); |
300 ZStatTimer timer(ZSubPhaseConcurrentRoots); |
304 _jni_handles.oops_do(cl); |
301 _jni_handles.oops_do(cl); |
|
302 _vm_handles.oops_do(cl), |
305 _class_loader_data_graph.oops_do(cl); |
303 _class_loader_data_graph.oops_do(cl); |
306 } |
304 } |
307 |
305 |
308 ZWeakRootsIterator::ZWeakRootsIterator() : |
306 ZWeakRootsIterator::ZWeakRootsIterator() : |
309 _jvmti_weak_export(this), |
307 _jvmti_weak_export(this), |
338 AlwaysTrueClosure always_alive; |
336 AlwaysTrueClosure always_alive; |
339 weak_oops_do(&always_alive, cl); |
337 weak_oops_do(&always_alive, cl); |
340 } |
338 } |
341 |
339 |
342 ZConcurrentWeakRootsIterator::ZConcurrentWeakRootsIterator() : |
340 ZConcurrentWeakRootsIterator::ZConcurrentWeakRootsIterator() : |
343 _vm_weak_handles_iter(SystemDictionary::vm_weak_oop_storage()), |
341 _vm_weak_handles_iter(OopStorageSet::vm_weak()), |
344 _jni_weak_handles_iter(JNIHandles::weak_global_handles()), |
342 _jni_weak_handles_iter(OopStorageSet::jni_weak()), |
345 _string_table_iter(StringTable::weak_storage()), |
343 _string_table_iter(OopStorageSet::string_table_weak()), |
346 _resolved_method_table_iter(ResolvedMethodTable::weak_storage()), |
344 _resolved_method_table_iter(OopStorageSet::resolved_method_table_weak()), |
347 _vm_weak_handles(this), |
345 _vm_weak_handles(this), |
348 _jni_weak_handles(this), |
346 _jni_weak_handles(this), |
349 _string_table(this), |
347 _string_table(this), |
350 _resolved_method_table(this) { |
348 _resolved_method_table(this) { |
351 StringTable::reset_dead_counter(); |
349 StringTable::reset_dead_counter(); |
411 _vm_weak_handles.oops_do(cl); |
409 _vm_weak_handles.oops_do(cl); |
412 _jni_weak_handles.oops_do(cl); |
410 _jni_weak_handles.oops_do(cl); |
413 _string_table.oops_do(cl); |
411 _string_table.oops_do(cl); |
414 _resolved_method_table.oops_do(cl); |
412 _resolved_method_table.oops_do(cl); |
415 } |
413 } |
416 |
|
417 ZThreadRootsIterator::ZThreadRootsIterator() : |
|
418 _threads(this) { |
|
419 assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); |
|
420 ZStatTimer timer(ZSubPhasePauseRootsSetup); |
|
421 Threads::change_thread_claim_token(); |
|
422 } |
|
423 |
|
424 ZThreadRootsIterator::~ZThreadRootsIterator() { |
|
425 ZStatTimer timer(ZSubPhasePauseRootsTeardown); |
|
426 Threads::assert_all_threads_claimed(); |
|
427 } |
|
428 |
|
429 void ZThreadRootsIterator::do_threads(ZRootsIteratorClosure* cl) { |
|
430 ZStatTimer timer(ZSubPhasePauseRootsThreads); |
|
431 ResourceMark rm; |
|
432 Threads::possibly_parallel_oops_do(true, cl, NULL); |
|
433 } |
|
434 |
|
435 void ZThreadRootsIterator::oops_do(ZRootsIteratorClosure* cl) { |
|
436 ZStatTimer timer(ZSubPhasePauseRoots); |
|
437 _threads.oops_do(cl); |
|
438 } |
|