8226311: Shenandoah: Concurrent evacuation of OopStorage backed weak roots

Reviewed-by: rkennke
This commit is contained in:
Zhengyu Gu 2019-06-24 11:46:46 -04:00
parent 54dfd47fa8
commit cfb99c9382
7 changed files with 223 additions and 49 deletions

View file

@ -25,14 +25,83 @@
#define SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
#include "classfile/classLoaderDataGraph.hpp"
#include "classfile/stringTable.hpp"
#include "classfile/systemDictionary.hpp"
#include "gc/shared/oopStorageParState.inline.hpp"
#include "gc/shenandoah/shenandoahHeuristics.hpp"
#include "gc/shenandoah/shenandoahRootProcessor.hpp"
#include "gc/shenandoah/shenandoahTimingTracker.hpp"
#include "gc/shenandoah/shenandoahUtils.hpp"
#include "memory/resourceArea.hpp"
#include "prims/resolvedMethodTable.hpp"
#include "runtime/safepoint.hpp"
template <bool CONCURRENT>
inline ShenandoahWeakRoot<CONCURRENT>::ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase) :
_itr(storage), _phase(phase) {
}
template <bool CONCURRENT>
template <typename Closure>
inline void ShenandoahWeakRoot<CONCURRENT>::oops_do(Closure* cl, uint worker_id) {
if (CONCURRENT) {
_itr.oops_do(cl);
} else {
ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::ThreadRoots, worker_id);
_itr.oops_do(cl);
}
}
inline ShenandoahWeakRoot<false>::ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase) :
_itr(storage), _phase(phase) {
}
template <typename IsAliveClosure, typename KeepAliveClosure>
void ShenandoahWeakRoot<false /* concurrent */>::weak_oops_do(IsAliveClosure* is_alive, KeepAliveClosure* keep_alive, uint worker_id) {
ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
ShenandoahWorkerTimingsTracker timer(worker_times, _phase, worker_id);
_itr.weak_oops_do(is_alive, keep_alive);
}
template <bool CONCURRENT>
ShenandoahWeakRoots<CONCURRENT>::ShenandoahWeakRoots() :
_jni_roots(JNIHandles::weak_global_handles(), ShenandoahPhaseTimings::JNIWeakRoots),
_string_table_roots(StringTable::weak_storage(), ShenandoahPhaseTimings::StringTableRoots),
_resolved_method_table_roots(ResolvedMethodTable::weak_storage(), ShenandoahPhaseTimings::ResolvedMethodTableRoots),
_vm_roots(SystemDictionary::vm_weak_oop_storage(), ShenandoahPhaseTimings::VMWeakRoots) {
}
template <bool CONCURRENT>
template <typename Closure>
void ShenandoahWeakRoots<CONCURRENT>::oops_do(Closure* cl, uint worker_id) {
_jni_roots.oops_do(cl, worker_id);
_string_table_roots.oops_do(cl, worker_id);
_resolved_method_table_roots.oops_do(cl, worker_id);
_vm_roots.oops_do(cl, worker_id);
}
inline ShenandoahWeakRoots<false /* concurrent */>::ShenandoahWeakRoots() :
_jni_roots(JNIHandles::weak_global_handles(), ShenandoahPhaseTimings::JNIWeakRoots),
_string_table_roots(StringTable::weak_storage(), ShenandoahPhaseTimings::StringTableRoots),
_resolved_method_table_roots(ResolvedMethodTable::weak_storage(), ShenandoahPhaseTimings::ResolvedMethodTableRoots),
_vm_roots(SystemDictionary::vm_weak_oop_storage(), ShenandoahPhaseTimings::VMWeakRoots) {
}
template <typename IsAliveClosure, typename KeepAliveClosure>
void ShenandoahWeakRoots<false /* concurrent*/>::weak_oops_do(IsAliveClosure* is_alive, KeepAliveClosure* keep_alive, uint worker_id) {
_jni_roots.weak_oops_do(is_alive, keep_alive, worker_id);
_string_table_roots.weak_oops_do(is_alive, keep_alive, worker_id);
_resolved_method_table_roots.weak_oops_do(is_alive, keep_alive, worker_id);
_vm_roots.weak_oops_do(is_alive, keep_alive, worker_id);
}
template <typename Closure>
void ShenandoahWeakRoots<false /* concurrent */>::oops_do(Closure* cl, uint worker_id) {
AlwaysTrueClosure always_true;
weak_oops_do<AlwaysTrueClosure, Closure>(&always_true, cl, worker_id);
}
template <bool CONCURRENT>
ShenandoahJNIHandleRoots<CONCURRENT>::ShenandoahJNIHandleRoots() :
_itr(JNIHandles::global_handles()) {
@ -50,11 +119,6 @@ void ShenandoahJNIHandleRoots<CONCURRENT>::oops_do(T* cl, uint worker_id) {
}
}
template <typename IsAlive, typename KeepAlive>
void ShenandoahWeakRoots::oops_do(IsAlive* is_alive, KeepAlive* keep_alive, uint worker_id) {
_task.work<IsAlive, KeepAlive>(worker_id, is_alive, keep_alive);
}
template <bool SINGLE_THREADED>
ShenandoahClassLoaderDataRoots<SINGLE_THREADED>::ShenandoahClassLoaderDataRoots() {
if (!SINGLE_THREADED) {
@ -197,7 +261,8 @@ void ShenandoahRootUpdater::roots_do(uint worker_id, IsAlive* is_alive, KeepAliv
_code_roots.code_blobs_do(&update_blobs, worker_id);
}
_weak_roots.oops_do<IsAlive, KeepAlive>(is_alive, keep_alive, worker_id);
_serial_weak_roots.weak_oops_do(is_alive, keep_alive, worker_id);
_weak_roots.weak_oops_do(is_alive, keep_alive, worker_id);
_dedup_roots.oops_do(is_alive, keep_alive, worker_id);
}