8210881: ZGC: Introduce ZRootsIteratorClosure

Reviewed-by: eosterlund
This commit is contained in:
Per Lidén 2018-09-19 19:12:18 +02:00
parent a69f014ad7
commit 85e31a838e
8 changed files with 134 additions and 126 deletions

View File

@ -304,6 +304,17 @@ void ZHeap::mark_flush_and_free(Thread* thread) {
_mark.flush_and_free(thread); _mark.flush_and_free(thread);
} }
class ZFixupPartialLoadsClosure : public ZRootsIteratorClosure {
public:
virtual void do_oop(oop* p) {
ZBarrier::mark_barrier_on_root_oop_field(p);
}
virtual void do_oop(narrowOop* p) {
ShouldNotReachHere();
}
};
class ZFixupPartialLoadsTask : public ZTask { class ZFixupPartialLoadsTask : public ZTask {
private: private:
ZThreadRootsIterator _thread_roots; ZThreadRootsIterator _thread_roots;
@ -314,7 +325,7 @@ public:
_thread_roots() {} _thread_roots() {}
virtual void work() { virtual void work() {
ZMarkRootOopClosure cl; ZFixupPartialLoadsClosure cl;
_thread_roots.oops_do(&cl); _thread_roots.oops_do(&cl);
} }
}; };

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -51,7 +51,7 @@ public:
} }
}; };
class ZHeapIteratorRootOopClosure : public OopClosure { class ZHeapIteratorRootOopClosure : public ZRootsIteratorClosure {
private: private:
ZHeapIterator* const _iter; ZHeapIterator* const _iter;
ObjectClosure* const _cl; ObjectClosure* const _cl;

View File

@ -117,6 +117,24 @@ void ZMark::prepare_mark() {
} }
} }
class ZMarkRootsIteratorClosure : public ZRootsIteratorClosure {
public:
virtual void do_thread(Thread* thread) {
ZRootsIteratorClosure::do_thread(thread);
// Update thread local address bad mask
ZThreadLocalData::set_address_bad_mask(thread, ZAddressBadMask);
}
virtual void do_oop(oop* p) {
ZBarrier::mark_barrier_on_root_oop_field(p);
}
virtual void do_oop(narrowOop* p) {
ShouldNotReachHere();
}
};
class ZMarkRootsTask : public ZTask { class ZMarkRootsTask : public ZTask {
private: private:
ZMark* const _mark; ZMark* const _mark;
@ -129,7 +147,7 @@ public:
_roots() {} _roots() {}
virtual void work() { virtual void work() {
ZMarkRootOopClosure cl; ZMarkRootsIteratorClosure cl;
_roots.oops_do(&cl); _roots.oops_do(&cl);
// Flush and free worker stacks. Needed here since // Flush and free worker stacks. Needed here since

View File

@ -25,6 +25,7 @@
#define SHARE_GC_Z_ZOOPCLOSURES_HPP #define SHARE_GC_Z_ZOOPCLOSURES_HPP
#include "memory/iterator.hpp" #include "memory/iterator.hpp"
#include "gc/z/zRootsIterator.hpp"
class ZLoadBarrierOopClosure : public BasicOopIterateClosure { class ZLoadBarrierOopClosure : public BasicOopIterateClosure {
public: public:
@ -38,18 +39,6 @@ public:
#endif #endif
}; };
class ZMarkRootOopClosure : public OopClosure {
public:
virtual void do_oop(oop* p);
virtual void do_oop(narrowOop* p);
};
class ZRelocateRootOopClosure : public OopClosure {
public:
virtual void do_oop(oop* p);
virtual void do_oop(narrowOop* p);
};
template <bool finalizable> template <bool finalizable>
class ZMarkBarrierOopClosure : public BasicOopIterateClosure { class ZMarkBarrierOopClosure : public BasicOopIterateClosure {
public: public:
@ -70,13 +59,13 @@ public:
virtual bool do_object_b(oop o); virtual bool do_object_b(oop o);
}; };
class ZPhantomKeepAliveOopClosure : public OopClosure { class ZPhantomKeepAliveOopClosure : public ZRootsIteratorClosure {
public: public:
virtual void do_oop(oop* p); virtual void do_oop(oop* p);
virtual void do_oop(narrowOop* p); virtual void do_oop(narrowOop* p);
}; };
class ZPhantomCleanOopClosure : public OopClosure { class ZPhantomCleanOopClosure : public ZRootsIteratorClosure {
public: public:
virtual void do_oop(oop* p); virtual void do_oop(oop* p);
virtual void do_oop(narrowOop* p); virtual void do_oop(narrowOop* p);
@ -97,7 +86,7 @@ public:
#endif #endif
}; };
class ZVerifyRootOopClosure : public OopClosure { class ZVerifyRootOopClosure : public ZRootsIteratorClosure {
public: public:
ZVerifyRootOopClosure(); ZVerifyRootOopClosure();

View File

@ -40,22 +40,6 @@ inline void ZLoadBarrierOopClosure::do_oop(narrowOop* p) {
ShouldNotReachHere(); ShouldNotReachHere();
} }
inline void ZMarkRootOopClosure::do_oop(oop* p) {
ZBarrier::mark_barrier_on_root_oop_field(p);
}
inline void ZMarkRootOopClosure::do_oop(narrowOop* p) {
ShouldNotReachHere();
}
inline void ZRelocateRootOopClosure::do_oop(oop* p) {
ZBarrier::relocate_barrier_on_root_oop_field(p);
}
inline void ZRelocateRootOopClosure::do_oop(narrowOop* p) {
ShouldNotReachHere();
}
template <bool finalizable> template <bool finalizable>
inline ZMarkBarrierOopClosure<finalizable>::ZMarkBarrierOopClosure() : inline ZMarkBarrierOopClosure<finalizable>::ZMarkBarrierOopClosure() :
BasicOopIterateClosure(finalizable ? NULL : ZHeap::heap()->reference_discoverer()) {} BasicOopIterateClosure(finalizable ? NULL : ZHeap::heap()->reference_discoverer()) {}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -34,6 +34,24 @@
ZRelocate::ZRelocate(ZWorkers* workers) : ZRelocate::ZRelocate(ZWorkers* workers) :
_workers(workers) {} _workers(workers) {}
class ZRelocateRootsIteratorClosure : public ZRootsIteratorClosure {
public:
virtual void do_thread(Thread* thread) {
ZRootsIteratorClosure::do_thread(thread);
// Update thread local address bad mask
ZThreadLocalData::set_address_bad_mask(thread, ZAddressBadMask);
}
virtual void do_oop(oop* p) {
ZBarrier::relocate_barrier_on_root_oop_field(p);
}
virtual void do_oop(narrowOop* p) {
ShouldNotReachHere();
}
};
class ZRelocateRootsTask : public ZTask { class ZRelocateRootsTask : public ZTask {
private: private:
ZRootsIterator _roots; ZRootsIterator _roots;
@ -46,7 +64,7 @@ public:
virtual void work() { virtual void work() {
// During relocation we need to visit the JVMTI // During relocation we need to visit the JVMTI
// export weak roots to rehash the JVMTI tag map // export weak roots to rehash the JVMTI tag map
ZRelocateRootOopClosure cl; ZRelocateRootsIteratorClosure cl;
_roots.oops_do(&cl, true /* visit_jvmti_weak_export */); _roots.oops_do(&cl, true /* visit_jvmti_weak_export */);
} }
}; };

View File

@ -73,25 +73,25 @@ static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsVMWeakHandles("Concurrent
static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsJNIWeakHandles("Concurrent Weak Roots JNIWeakHandles"); static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsJNIWeakHandles("Concurrent Weak Roots JNIWeakHandles");
static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsStringTable("Concurrent Weak Roots StringTable"); static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsStringTable("Concurrent Weak Roots StringTable");
template <typename T, void (T::*F)(OopClosure*)> template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
ZSerialOopsDo<T, F>::ZSerialOopsDo(T* iter) : ZSerialOopsDo<T, F>::ZSerialOopsDo(T* iter) :
_iter(iter), _iter(iter),
_claimed(false) {} _claimed(false) {}
template <typename T, void (T::*F)(OopClosure*)> template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
void ZSerialOopsDo<T, F>::oops_do(OopClosure* cl) { void ZSerialOopsDo<T, F>::oops_do(ZRootsIteratorClosure* cl) {
if (!_claimed && Atomic::cmpxchg(true, &_claimed, false) == false) { if (!_claimed && Atomic::cmpxchg(true, &_claimed, false) == false) {
(_iter->*F)(cl); (_iter->*F)(cl);
} }
} }
template <typename T, void (T::*F)(OopClosure*)> template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
ZParallelOopsDo<T, F>::ZParallelOopsDo(T* iter) : ZParallelOopsDo<T, F>::ZParallelOopsDo(T* iter) :
_iter(iter), _iter(iter),
_completed(false) {} _completed(false) {}
template <typename T, void (T::*F)(OopClosure*)> template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
void ZParallelOopsDo<T, F>::oops_do(OopClosure* cl) { void ZParallelOopsDo<T, F>::oops_do(ZRootsIteratorClosure* cl) {
if (!_completed) { if (!_completed) {
(_iter->*F)(cl); (_iter->*F)(cl);
if (!_completed) { if (!_completed) {
@ -100,25 +100,25 @@ void ZParallelOopsDo<T, F>::oops_do(OopClosure* cl) {
} }
} }
template <typename T, void (T::*F)(BoolObjectClosure*, OopClosure*)> template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
ZSerialWeakOopsDo<T, F>::ZSerialWeakOopsDo(T* iter) : ZSerialWeakOopsDo<T, F>::ZSerialWeakOopsDo(T* iter) :
_iter(iter), _iter(iter),
_claimed(false) {} _claimed(false) {}
template <typename T, void (T::*F)(BoolObjectClosure*, OopClosure*)> template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
void ZSerialWeakOopsDo<T, F>::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* cl) { void ZSerialWeakOopsDo<T, F>::weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
if (!_claimed && Atomic::cmpxchg(true, &_claimed, false) == false) { if (!_claimed && Atomic::cmpxchg(true, &_claimed, false) == false) {
(_iter->*F)(is_alive, cl); (_iter->*F)(is_alive, cl);
} }
} }
template <typename T, void (T::*F)(BoolObjectClosure*, OopClosure*)> template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
ZParallelWeakOopsDo<T, F>::ZParallelWeakOopsDo(T* iter) : ZParallelWeakOopsDo<T, F>::ZParallelWeakOopsDo(T* iter) :
_iter(iter), _iter(iter),
_completed(false) {} _completed(false) {}
template <typename T, void (T::*F)(BoolObjectClosure*, OopClosure*)> template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
void ZParallelWeakOopsDo<T, F>::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* cl) { void ZParallelWeakOopsDo<T, F>::weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
if (!_completed) { if (!_completed) {
(_iter->*F)(is_alive, cl); (_iter->*F)(is_alive, cl);
if (!_completed) { if (!_completed) {
@ -158,80 +158,60 @@ ZRootsIterator::~ZRootsIterator() {
Threads::assert_all_threads_claimed(); Threads::assert_all_threads_claimed();
} }
void ZRootsIterator::do_universe(OopClosure* cl) { void ZRootsIterator::do_universe(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsUniverse); ZStatTimer timer(ZSubPhasePauseRootsUniverse);
Universe::oops_do(cl); Universe::oops_do(cl);
} }
void ZRootsIterator::do_jni_handles(OopClosure* cl) { void ZRootsIterator::do_jni_handles(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsJNIHandles); ZStatTimer timer(ZSubPhasePauseRootsJNIHandles);
_jni_handles_iter.oops_do(cl); _jni_handles_iter.oops_do(cl);
} }
void ZRootsIterator::do_object_synchronizer(OopClosure* cl) { void ZRootsIterator::do_object_synchronizer(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsObjectSynchronizer); ZStatTimer timer(ZSubPhasePauseRootsObjectSynchronizer);
ObjectSynchronizer::oops_do(cl); ObjectSynchronizer::oops_do(cl);
} }
void ZRootsIterator::do_management(OopClosure* cl) { void ZRootsIterator::do_management(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsManagement); ZStatTimer timer(ZSubPhasePauseRootsManagement);
Management::oops_do(cl); Management::oops_do(cl);
} }
void ZRootsIterator::do_jvmti_export(OopClosure* cl) { void ZRootsIterator::do_jvmti_export(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsJVMTIExport); ZStatTimer timer(ZSubPhasePauseRootsJVMTIExport);
JvmtiExport::oops_do(cl); JvmtiExport::oops_do(cl);
} }
void ZRootsIterator::do_jvmti_weak_export(OopClosure* cl) { void ZRootsIterator::do_jvmti_weak_export(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsJVMTIWeakExport); ZStatTimer timer(ZSubPhasePauseRootsJVMTIWeakExport);
AlwaysTrueClosure always_alive; AlwaysTrueClosure always_alive;
JvmtiExport::weak_oops_do(&always_alive, cl); JvmtiExport::weak_oops_do(&always_alive, cl);
} }
void ZRootsIterator::do_system_dictionary(OopClosure* cl) { void ZRootsIterator::do_system_dictionary(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsSystemDictionary); ZStatTimer timer(ZSubPhasePauseRootsSystemDictionary);
SystemDictionary::oops_do(cl); SystemDictionary::oops_do(cl);
} }
void ZRootsIterator::do_class_loader_data_graph(OopClosure* cl) { void ZRootsIterator::do_class_loader_data_graph(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsClassLoaderDataGraph); ZStatTimer timer(ZSubPhasePauseRootsClassLoaderDataGraph);
CLDToOopClosure cld_cl(cl); CLDToOopClosure cld_cl(cl);
ClassLoaderDataGraph::cld_do(&cld_cl); ClassLoaderDataGraph::cld_do(&cld_cl);
} }
class ZRootsIteratorThreadClosure : public ThreadClosure { void ZRootsIterator::do_threads(ZRootsIteratorClosure* cl) {
private:
OopClosure* const _cl;
public:
ZRootsIteratorThreadClosure(OopClosure* cl) :
_cl(cl) {}
virtual void do_thread(Thread* thread) {
if (thread->is_Java_thread()) {
// Update thread local address bad mask
ZThreadLocalData::set_address_bad_mask(thread, ZAddressBadMask);
}
// Process thread oops
thread->oops_do(_cl, NULL);
}
};
void ZRootsIterator::do_threads(OopClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsThreads); ZStatTimer timer(ZSubPhasePauseRootsThreads);
ResourceMark rm; ResourceMark rm;
ZRootsIteratorThreadClosure thread_cl(cl); Threads::possibly_parallel_threads_do(true, cl);
Threads::possibly_parallel_threads_do(true, &thread_cl);
} }
void ZRootsIterator::do_code_cache(OopClosure* cl) { void ZRootsIterator::do_code_cache(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsCodeCache); ZStatTimer timer(ZSubPhasePauseRootsCodeCache);
ZNMethodTable::oops_do(cl); ZNMethodTable::oops_do(cl);
} }
void ZRootsIterator::oops_do(OopClosure* cl, bool visit_jvmti_weak_export) { void ZRootsIterator::oops_do(ZRootsIteratorClosure* cl, bool visit_jvmti_weak_export) {
ZStatTimer timer(ZSubPhasePauseRoots); ZStatTimer timer(ZSubPhasePauseRoots);
_universe.oops_do(cl); _universe.oops_do(cl);
_object_synchronizer.oops_do(cl); _object_synchronizer.oops_do(cl);
@ -258,25 +238,25 @@ ZWeakRootsIterator::~ZWeakRootsIterator() {
ZStatTimer timer(ZSubPhasePauseWeakRootsTeardown); ZStatTimer timer(ZSubPhasePauseWeakRootsTeardown);
} }
void ZWeakRootsIterator::do_jvmti_weak_export(BoolObjectClosure* is_alive, OopClosure* cl) { void ZWeakRootsIterator::do_jvmti_weak_export(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseWeakRootsJVMTIWeakExport); ZStatTimer timer(ZSubPhasePauseWeakRootsJVMTIWeakExport);
JvmtiExport::weak_oops_do(is_alive, cl); JvmtiExport::weak_oops_do(is_alive, cl);
} }
void ZWeakRootsIterator::do_jfr_weak(BoolObjectClosure* is_alive, OopClosure* cl) { void ZWeakRootsIterator::do_jfr_weak(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
#if INCLUDE_JFR #if INCLUDE_JFR
ZStatTimer timer(ZSubPhasePauseWeakRootsJFRWeak); ZStatTimer timer(ZSubPhasePauseWeakRootsJFRWeak);
Jfr::weak_oops_do(is_alive, cl); Jfr::weak_oops_do(is_alive, cl);
#endif #endif
} }
void ZWeakRootsIterator::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* cl) { void ZWeakRootsIterator::weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseWeakRoots); ZStatTimer timer(ZSubPhasePauseWeakRoots);
_jvmti_weak_export.weak_oops_do(is_alive, cl); _jvmti_weak_export.weak_oops_do(is_alive, cl);
_jfr_weak.weak_oops_do(is_alive, cl); _jfr_weak.weak_oops_do(is_alive, cl);
} }
void ZWeakRootsIterator::oops_do(OopClosure* cl) { void ZWeakRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
AlwaysTrueClosure always_alive; AlwaysTrueClosure always_alive;
weak_oops_do(&always_alive, cl); weak_oops_do(&always_alive, cl);
} }
@ -295,27 +275,27 @@ ZConcurrentWeakRootsIterator::~ZConcurrentWeakRootsIterator() {
StringTable::finish_dead_counter(); StringTable::finish_dead_counter();
} }
void ZConcurrentWeakRootsIterator::do_vm_weak_handles(OopClosure* cl) { void ZConcurrentWeakRootsIterator::do_vm_weak_handles(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhaseConcurrentWeakRootsVMWeakHandles); ZStatTimer timer(ZSubPhaseConcurrentWeakRootsVMWeakHandles);
_vm_weak_handles_iter.oops_do(cl); _vm_weak_handles_iter.oops_do(cl);
} }
void ZConcurrentWeakRootsIterator::do_jni_weak_handles(OopClosure* cl) { void ZConcurrentWeakRootsIterator::do_jni_weak_handles(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhaseConcurrentWeakRootsJNIWeakHandles); ZStatTimer timer(ZSubPhaseConcurrentWeakRootsJNIWeakHandles);
_jni_weak_handles_iter.oops_do(cl); _jni_weak_handles_iter.oops_do(cl);
} }
class ZStringTableDeadCounterOopClosure : public OopClosure { class ZStringTableDeadCounterClosure : public ZRootsIteratorClosure {
private: private:
OopClosure* const _cl; ZRootsIteratorClosure* const _cl;
size_t _ndead; size_t _ndead;
public: public:
ZStringTableDeadCounterOopClosure(OopClosure* cl) : ZStringTableDeadCounterClosure(ZRootsIteratorClosure* cl) :
_cl(cl), _cl(cl),
_ndead(0) {} _ndead(0) {}
~ZStringTableDeadCounterOopClosure() { ~ZStringTableDeadCounterClosure() {
StringTable::inc_dead_counter(_ndead); StringTable::inc_dead_counter(_ndead);
} }
@ -331,13 +311,13 @@ public:
} }
}; };
void ZConcurrentWeakRootsIterator::do_string_table(OopClosure* cl) { void ZConcurrentWeakRootsIterator::do_string_table(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhaseConcurrentWeakRootsStringTable); ZStatTimer timer(ZSubPhaseConcurrentWeakRootsStringTable);
ZStringTableDeadCounterOopClosure counter_cl(cl); ZStringTableDeadCounterClosure counter_cl(cl);
_string_table_iter.oops_do(&counter_cl); _string_table_iter.oops_do(&counter_cl);
} }
void ZConcurrentWeakRootsIterator::oops_do(OopClosure* cl) { void ZConcurrentWeakRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhaseConcurrentWeakRoots); ZStatTimer timer(ZSubPhaseConcurrentWeakRoots);
_vm_weak_handles.oops_do(cl); _vm_weak_handles.oops_do(cl);
_jni_weak_handles.oops_do(cl); _jni_weak_handles.oops_do(cl);
@ -356,13 +336,13 @@ ZThreadRootsIterator::~ZThreadRootsIterator() {
Threads::assert_all_threads_claimed(); Threads::assert_all_threads_claimed();
} }
void ZThreadRootsIterator::do_threads(OopClosure* cl) { void ZThreadRootsIterator::do_threads(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsThreads); ZStatTimer timer(ZSubPhasePauseRootsThreads);
ResourceMark rm; ResourceMark rm;
Threads::possibly_parallel_oops_do(true, cl, NULL); Threads::possibly_parallel_oops_do(true, cl, NULL);
} }
void ZThreadRootsIterator::oops_do(OopClosure* cl) { void ZThreadRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRoots); ZStatTimer timer(ZSubPhasePauseRoots);
_threads.oops_do(cl); _threads.oops_do(cl);
} }

View File

@ -27,12 +27,20 @@
#include "gc/shared/oopStorageParState.hpp" #include "gc/shared/oopStorageParState.hpp"
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "memory/iterator.hpp" #include "memory/iterator.hpp"
#include "runtime/thread.hpp"
#include "utilities/globalDefinitions.hpp" #include "utilities/globalDefinitions.hpp"
class ZRootsIteratorClosure : public OopClosure, public ThreadClosure {
public:
virtual void do_thread(Thread* thread) {
thread->oops_do(this, NULL);
}
};
typedef OopStorage::ParState<false /* concurrent */, false /* is_const */> ZOopStorageIterator; typedef OopStorage::ParState<false /* concurrent */, false /* is_const */> ZOopStorageIterator;
typedef OopStorage::ParState<true /* concurrent */, false /* is_const */> ZConcurrentOopStorageIterator; typedef OopStorage::ParState<true /* concurrent */, false /* is_const */> ZConcurrentOopStorageIterator;
template <typename T, void (T::*F)(OopClosure*)> template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
class ZSerialOopsDo { class ZSerialOopsDo {
private: private:
T* const _iter; T* const _iter;
@ -40,10 +48,10 @@ private:
public: public:
ZSerialOopsDo(T* iter); ZSerialOopsDo(T* iter);
void oops_do(OopClosure* cl); void oops_do(ZRootsIteratorClosure* cl);
}; };
template <typename T, void (T::*F)(OopClosure*)> template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
class ZParallelOopsDo { class ZParallelOopsDo {
private: private:
T* const _iter; T* const _iter;
@ -51,10 +59,10 @@ private:
public: public:
ZParallelOopsDo(T* iter); ZParallelOopsDo(T* iter);
void oops_do(OopClosure* cl); void oops_do(ZRootsIteratorClosure* cl);
}; };
template <typename T, void (T::*F)(BoolObjectClosure*, OopClosure*)> template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
class ZSerialWeakOopsDo { class ZSerialWeakOopsDo {
private: private:
T* const _iter; T* const _iter;
@ -62,10 +70,10 @@ private:
public: public:
ZSerialWeakOopsDo(T* iter); ZSerialWeakOopsDo(T* iter);
void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* cl); void weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);
}; };
template <typename T, void (T::*F)(BoolObjectClosure*, OopClosure*)> template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
class ZParallelWeakOopsDo { class ZParallelWeakOopsDo {
private: private:
T* const _iter; T* const _iter;
@ -73,23 +81,23 @@ private:
public: public:
ZParallelWeakOopsDo(T* iter); ZParallelWeakOopsDo(T* iter);
void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* cl); void weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);
}; };
class ZRootsIterator { class ZRootsIterator {
private: private:
ZOopStorageIterator _jni_handles_iter; ZOopStorageIterator _jni_handles_iter;
void do_universe(OopClosure* cl); void do_universe(ZRootsIteratorClosure* cl);
void do_jni_handles(OopClosure* cl); void do_jni_handles(ZRootsIteratorClosure* cl);
void do_object_synchronizer(OopClosure* cl); void do_object_synchronizer(ZRootsIteratorClosure* cl);
void do_management(OopClosure* cl); void do_management(ZRootsIteratorClosure* cl);
void do_jvmti_export(OopClosure* cl); void do_jvmti_export(ZRootsIteratorClosure* cl);
void do_jvmti_weak_export(OopClosure* cl); void do_jvmti_weak_export(ZRootsIteratorClosure* cl);
void do_system_dictionary(OopClosure* cl); void do_system_dictionary(ZRootsIteratorClosure* cl);
void do_class_loader_data_graph(OopClosure* cl); void do_class_loader_data_graph(ZRootsIteratorClosure* cl);
void do_threads(OopClosure* cl); void do_threads(ZRootsIteratorClosure* cl);
void do_code_cache(OopClosure* cl); void do_code_cache(ZRootsIteratorClosure* cl);
ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_universe> _universe; ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_universe> _universe;
ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_object_synchronizer> _object_synchronizer; ZSerialOopsDo<ZRootsIterator, &ZRootsIterator::do_object_synchronizer> _object_synchronizer;
@ -106,13 +114,13 @@ public:
ZRootsIterator(); ZRootsIterator();
~ZRootsIterator(); ~ZRootsIterator();
void oops_do(OopClosure* cl, bool visit_jvmti_weak_export = false); void oops_do(ZRootsIteratorClosure* cl, bool visit_jvmti_weak_export = false);
}; };
class ZWeakRootsIterator { class ZWeakRootsIterator {
private: private:
void do_jvmti_weak_export(BoolObjectClosure* is_alive, OopClosure* cl); void do_jvmti_weak_export(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);
void do_jfr_weak(BoolObjectClosure* is_alive, OopClosure* cl); void do_jfr_weak(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);
ZSerialWeakOopsDo<ZWeakRootsIterator, &ZWeakRootsIterator::do_jvmti_weak_export> _jvmti_weak_export; ZSerialWeakOopsDo<ZWeakRootsIterator, &ZWeakRootsIterator::do_jvmti_weak_export> _jvmti_weak_export;
ZSerialWeakOopsDo<ZWeakRootsIterator, &ZWeakRootsIterator::do_jfr_weak> _jfr_weak; ZSerialWeakOopsDo<ZWeakRootsIterator, &ZWeakRootsIterator::do_jfr_weak> _jfr_weak;
@ -121,8 +129,8 @@ public:
ZWeakRootsIterator(); ZWeakRootsIterator();
~ZWeakRootsIterator(); ~ZWeakRootsIterator();
void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* cl); void weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl);
void oops_do(OopClosure* cl); void oops_do(ZRootsIteratorClosure* cl);
}; };
class ZConcurrentWeakRootsIterator { class ZConcurrentWeakRootsIterator {
@ -131,9 +139,9 @@ private:
ZConcurrentOopStorageIterator _jni_weak_handles_iter; ZConcurrentOopStorageIterator _jni_weak_handles_iter;
ZConcurrentOopStorageIterator _string_table_iter; ZConcurrentOopStorageIterator _string_table_iter;
void do_vm_weak_handles(OopClosure* cl); void do_vm_weak_handles(ZRootsIteratorClosure* cl);
void do_jni_weak_handles(OopClosure* cl); void do_jni_weak_handles(ZRootsIteratorClosure* cl);
void do_string_table(OopClosure* cl); void do_string_table(ZRootsIteratorClosure* cl);
ZParallelOopsDo<ZConcurrentWeakRootsIterator, &ZConcurrentWeakRootsIterator::do_vm_weak_handles> _vm_weak_handles; ZParallelOopsDo<ZConcurrentWeakRootsIterator, &ZConcurrentWeakRootsIterator::do_vm_weak_handles> _vm_weak_handles;
ZParallelOopsDo<ZConcurrentWeakRootsIterator, &ZConcurrentWeakRootsIterator::do_jni_weak_handles> _jni_weak_handles; ZParallelOopsDo<ZConcurrentWeakRootsIterator, &ZConcurrentWeakRootsIterator::do_jni_weak_handles> _jni_weak_handles;
@ -143,12 +151,12 @@ public:
ZConcurrentWeakRootsIterator(); ZConcurrentWeakRootsIterator();
~ZConcurrentWeakRootsIterator(); ~ZConcurrentWeakRootsIterator();
void oops_do(OopClosure* cl); void oops_do(ZRootsIteratorClosure* cl);
}; };
class ZThreadRootsIterator { class ZThreadRootsIterator {
private: private:
void do_threads(OopClosure* cl); void do_threads(ZRootsIteratorClosure* cl);
ZParallelOopsDo<ZThreadRootsIterator, &ZThreadRootsIterator::do_threads> _threads; ZParallelOopsDo<ZThreadRootsIterator, &ZThreadRootsIterator::do_threads> _threads;
@ -156,7 +164,7 @@ public:
ZThreadRootsIterator(); ZThreadRootsIterator();
~ZThreadRootsIterator(); ~ZThreadRootsIterator();
void oops_do(OopClosure* cl); void oops_do(ZRootsIteratorClosure* cl);
}; };
#endif // SHARE_GC_Z_ZROOTSITERATOR_HPP #endif // SHARE_GC_Z_ZROOTSITERATOR_HPP