< prev index next > src/hotspot/share/gc/z/zRootsIterator.cpp
Concurrent class unloading
#include "classfile/systemDictionary.hpp"
#include "code/codeCache.hpp"
#include "compiler/oopMap.hpp"
#include "gc/shared/oopStorageParState.inline.hpp"
#include "gc/z/zGlobals.hpp"
+#include "gc/z/zNMethodBarrier.hpp"
#include "gc/z/zNMethodTable.hpp"
#include "gc/z/zOopClosures.inline.hpp"
#include "gc/z/zRootsIterator.hpp"
#include "gc/z/zStat.hpp"
#include "gc/z/zThreadLocalData.hpp"
_completed = true;
}
}
}
-ZRootsIterator::ZRootsIterator() :
+ZRootsIterator::ZRootsIterator(bool strong_only) :
+ _strong_only(strong_only),
_vm_weak_handles_iter(SystemDictionary::vm_weak_oop_storage()),
_jni_handles_iter(JNIHandles::global_handles()),
_jni_weak_handles_iter(JNIHandles::weak_global_handles()),
_string_table_iter(StringTable::weak_storage()),
_universe(this),
_system_dictionary(this),
_vm_weak_handles(this),
_jni_handles(this),
_jni_weak_handles(this),
_class_loader_data_graph(this),
+ _class_loader_data_graph_strong_only(this),
_threads(this),
_code_cache(this),
_string_table(this) {
assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
ZStatTimer timer(ZSubPhasePauseRootsSetup);
Threads::change_thread_claim_parity();
ClassLoaderDataGraph::clear_claimed_marks();
COMPILER2_PRESENT(DerivedPointerTable::clear());
- CodeCache::gc_prologue();
- ZNMethodTable::gc_prologue();
+ if (!ClassUnloading) {
+ ZNMethodTable::gc_prologue();
+ }
}
ZRootsIterator::~ZRootsIterator() {
ZStatTimer timer(ZSubPhasePauseRootsTeardown);
ResourceMark rm;
- ZNMethodTable::gc_epilogue();
- CodeCache::gc_epilogue();
+ if (!ClassUnloading) {
+ ZNMethodTable::gc_epilogue();
+ }
JvmtiExport::gc_epilogue();
+
COMPILER2_PRESENT(DerivedPointerTable::update_pointers());
Threads::assert_all_threads_claimed();
}
void ZRootsIterator::do_universe(OopClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsClassLoaderDataGraph);
CLDToOopClosure cld_cl(cl);
ClassLoaderDataGraph::cld_do(&cld_cl);
}
+void ZRootsIterator::do_class_loader_data_graph_strong_only(OopClosure* cl) {
+ ZStatTimer timer(ZSubPhasePauseRootsClassLoaderDataGraph);
+ ClassLoaderDataGraph::always_strong_oops_do(cl, /* must_claim */ true);
+}
+
+class ZCodeBlobClosure : public CodeBlobToOopClosure {
+public:
+ ZCodeBlobClosure(OopClosure* cl) : CodeBlobToOopClosure(cl, true) {}
+ virtual void do_code_blob(CodeBlob* cb) {
+ CodeBlobToOopClosure::do_code_blob(cb);
+ if (cb->is_nmethod()) {
+ nmethod* nm = (nmethod*) cb;
+ nm->disarm_barrier();
+ }
+ }
+};
+
class ZRootsIteratorThreadClosure : public ThreadClosure {
private:
OopClosure* const _cl;
+ CodeBlobClosure* const _code_cl;
public:
- ZRootsIteratorThreadClosure(OopClosure* cl) :
- _cl(cl) {}
+ ZRootsIteratorThreadClosure(OopClosure* cl, CodeBlobClosure* code_cl) :
+ _cl(cl),
+ _code_cl(code_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);
+ thread->oops_do(_cl, _code_cl);
}
};
void ZRootsIterator::do_threads(OopClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsThreads);
ResourceMark rm;
- ZRootsIteratorThreadClosure thread_cl(cl);
+
+ ZCodeBlobClosure code_cl(cl);
+ ZRootsIteratorThreadClosure thread_cl(cl, ClassUnloading ? &code_cl : NULL);
Threads::possibly_parallel_threads_do(true, &thread_cl);
}
void ZRootsIterator::do_code_cache(OopClosure* cl) {
ZStatTimer timer(ZSubPhasePauseRootsCodeCache);
_object_synchronizer.oops_do(cl);
_management.oops_do(cl);
_jvmti_export.oops_do(cl);
_system_dictionary.oops_do(cl);
_jni_handles.oops_do(cl);
- _class_loader_data_graph.oops_do(cl);
_threads.oops_do(cl);
- _code_cache.oops_do(cl);
+
+ if (!ClassUnloading) {
+ _code_cache.oops_do(cl);
+ }
+
+ if (!ClassUnloading || !ZWeakRoots || !_strong_only) {
+ _class_loader_data_graph.oops_do(cl);
+ } else {
+ _class_loader_data_graph_strong_only.oops_do(cl);
+ }
+
if (!ZWeakRoots) {
_jvmti_weak_export.oops_do(cl);
_jfr_weak.oops_do(cl);
_vm_weak_handles.oops_do(cl);
_jni_weak_handles.oops_do(cl);
_jni_weak_handles(this),
_string_table(this) {
assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
ZStatTimer timer(ZSubPhasePauseWeakRootsSetup);
StringTable::reset_dead_counter();
+ ClassLoaderDataGraph::clear_claimed_marks();
}
ZWeakRootsIterator::~ZWeakRootsIterator() {
ZStatTimer timer(ZSubPhasePauseWeakRootsTeardown);
StringTable::finish_dead_counter();
< prev index next >