8225572: Shenandoah: Move JNIHandles root out of serial roots

Reviewed-by: rkennke
This commit is contained in:
Zhengyu Gu 2019-06-11 19:15:31 -04:00
parent 4f171abe26
commit 9597144fb2
5 changed files with 27 additions and 7 deletions

View File

@ -60,8 +60,7 @@ ShenandoahSerialRoots::ShenandoahSerialRoots() :
_object_synchronizer_root(&ObjectSynchronizer::oops_do, ShenandoahPhaseTimings::ObjectSynchronizerRoots), _object_synchronizer_root(&ObjectSynchronizer::oops_do, ShenandoahPhaseTimings::ObjectSynchronizerRoots),
_management_root(&Management::oops_do, ShenandoahPhaseTimings::ManagementRoots), _management_root(&Management::oops_do, ShenandoahPhaseTimings::ManagementRoots),
_system_dictionary_root(&SystemDictionary::oops_do, ShenandoahPhaseTimings::SystemDictionaryRoots), _system_dictionary_root(&SystemDictionary::oops_do, ShenandoahPhaseTimings::SystemDictionaryRoots),
_jvmti_root(&JvmtiExport::oops_do, ShenandoahPhaseTimings::JVMTIRoots), _jvmti_root(&JvmtiExport::oops_do, ShenandoahPhaseTimings::JVMTIRoots) {
_jni_handle_root(&JNIHandles::oops_do, ShenandoahPhaseTimings::JNIRoots) {
} }
void ShenandoahSerialRoots::oops_do(OopClosure* cl, uint worker_id) { void ShenandoahSerialRoots::oops_do(OopClosure* cl, uint worker_id) {
@ -70,7 +69,10 @@ void ShenandoahSerialRoots::oops_do(OopClosure* cl, uint worker_id) {
_management_root.oops_do(cl, worker_id); _management_root.oops_do(cl, worker_id);
_system_dictionary_root.oops_do(cl, worker_id); _system_dictionary_root.oops_do(cl, worker_id);
_jvmti_root.oops_do(cl, worker_id); _jvmti_root.oops_do(cl, worker_id);
_jni_handle_root.oops_do(cl, worker_id); }
ShenandoahJNIHandleRoots::ShenandoahJNIHandleRoots() :
ShenandoahSerialRoot(&JNIHandles::oops_do, ShenandoahPhaseTimings::JNIRoots) {
} }
ShenandoahThreadRoots::ShenandoahThreadRoots(bool is_par) : _is_par(is_par) { ShenandoahThreadRoots::ShenandoahThreadRoots(bool is_par) : _is_par(is_par) {
@ -160,6 +162,7 @@ void ShenandoahRootEvacuator::roots_do(uint worker_id, OopClosure* oops) {
AlwaysTrueClosure always_true; AlwaysTrueClosure always_true;
_serial_roots.oops_do(oops, worker_id); _serial_roots.oops_do(oops, worker_id);
_jni_roots.oops_do(oops, worker_id);
_thread_roots.oops_do(oops, NULL, worker_id); _thread_roots.oops_do(oops, NULL, worker_id);
_cld_roots.clds_do(&clds, &clds, worker_id); _cld_roots.clds_do(&clds, &clds, worker_id);
@ -189,6 +192,7 @@ void ShenandoahRootAdjuster::roots_do(uint worker_id, OopClosure* oops) {
AlwaysTrueClosure always_true; AlwaysTrueClosure always_true;
_serial_roots.oops_do(oops, worker_id); _serial_roots.oops_do(oops, worker_id);
_jni_roots.oops_do(oops, worker_id);
_thread_roots.oops_do(oops, NULL, worker_id); _thread_roots.oops_do(oops, NULL, worker_id);
_cld_roots.clds_do(&adjust_cld_closure, NULL, worker_id); _cld_roots.clds_do(&adjust_cld_closure, NULL, worker_id);

View File

@ -56,12 +56,16 @@ private:
ShenandoahSerialRoot _management_root; ShenandoahSerialRoot _management_root;
ShenandoahSerialRoot _system_dictionary_root; ShenandoahSerialRoot _system_dictionary_root;
ShenandoahSerialRoot _jvmti_root; ShenandoahSerialRoot _jvmti_root;
ShenandoahSerialRoot _jni_handle_root;
public: public:
ShenandoahSerialRoots(); ShenandoahSerialRoots();
void oops_do(OopClosure* cl, uint worker_id); void oops_do(OopClosure* cl, uint worker_id);
}; };
class ShenandoahJNIHandleRoots : public ShenandoahSerialRoot {
public:
ShenandoahJNIHandleRoots();
};
class ShenandoahThreadRoots { class ShenandoahThreadRoots {
private: private:
const bool _is_par; const bool _is_par;
@ -126,6 +130,7 @@ template <typename ITR>
class ShenandoahRootScanner : public ShenandoahRootProcessor { class ShenandoahRootScanner : public ShenandoahRootProcessor {
private: private:
ShenandoahSerialRoots _serial_roots; ShenandoahSerialRoots _serial_roots;
ShenandoahJNIHandleRoots _jni_roots;
ShenandoahClassLoaderDataRoots _cld_roots; ShenandoahClassLoaderDataRoots _cld_roots;
ShenandoahThreadRoots _thread_roots; ShenandoahThreadRoots _thread_roots;
ShenandoahCodeCacheRoots<ITR> _code_roots; ShenandoahCodeCacheRoots<ITR> _code_roots;
@ -152,6 +157,7 @@ typedef ShenandoahRootScanner<ShenandoahCsetCodeRootsIterator> ShenandoahCSetRoo
class ShenandoahRootEvacuator : public ShenandoahRootProcessor { class ShenandoahRootEvacuator : public ShenandoahRootProcessor {
private: private:
ShenandoahSerialRoots _serial_roots; ShenandoahSerialRoots _serial_roots;
ShenandoahJNIHandleRoots _jni_roots;
ShenandoahClassLoaderDataRoots _cld_roots; ShenandoahClassLoaderDataRoots _cld_roots;
ShenandoahThreadRoots _thread_roots; ShenandoahThreadRoots _thread_roots;
ShenandoahWeakRoots _weak_roots; ShenandoahWeakRoots _weak_roots;
@ -168,6 +174,7 @@ public:
class ShenandoahRootUpdater : public ShenandoahRootProcessor { class ShenandoahRootUpdater : public ShenandoahRootProcessor {
private: private:
ShenandoahSerialRoots _serial_roots; ShenandoahSerialRoots _serial_roots;
ShenandoahJNIHandleRoots _jni_roots;
ShenandoahClassLoaderDataRoots _cld_roots; ShenandoahClassLoaderDataRoots _cld_roots;
ShenandoahThreadRoots _thread_roots; ShenandoahThreadRoots _thread_roots;
ShenandoahWeakRoots _weak_roots; ShenandoahWeakRoots _weak_roots;
@ -186,6 +193,7 @@ public:
class ShenandoahRootAdjuster : public ShenandoahRootProcessor { class ShenandoahRootAdjuster : public ShenandoahRootProcessor {
private: private:
ShenandoahSerialRoots _serial_roots; ShenandoahSerialRoots _serial_roots;
ShenandoahJNIHandleRoots _jni_roots;
ShenandoahClassLoaderDataRoots _cld_roots; ShenandoahClassLoaderDataRoots _cld_roots;
ShenandoahThreadRoots _thread_roots; ShenandoahThreadRoots _thread_roots;
ShenandoahWeakRoots _weak_roots; ShenandoahWeakRoots _weak_roots;

View File

@ -99,6 +99,7 @@ void ShenandoahRootScanner<ITR>::roots_do(uint worker_id, OopClosure* oops, CLDC
ResourceMark rm; ResourceMark rm;
_serial_roots.oops_do(oops, worker_id); _serial_roots.oops_do(oops, worker_id);
_jni_roots.oops_do(oops, worker_id);
_cld_roots.clds_do(clds, clds, worker_id); _cld_roots.clds_do(clds, clds, worker_id);
_thread_roots.threads_do(&tc_cl, worker_id); _thread_roots.threads_do(&tc_cl, worker_id);
@ -118,6 +119,7 @@ void ShenandoahRootScanner<ITR>::roots_do_unchecked(OopClosure* oops) {
ResourceMark rm; ResourceMark rm;
_serial_roots.oops_do(oops, 0); _serial_roots.oops_do(oops, 0);
_jni_roots.oops_do(oops, 0);
_cld_roots.clds_do(&clds, &clds, 0); _cld_roots.clds_do(&clds, &clds, 0);
_thread_roots.threads_do(&tc_cl, 0); _thread_roots.threads_do(&tc_cl, 0);
_code_roots.code_blobs_do(&code, 0); _code_roots.code_blobs_do(&code, 0);
@ -130,6 +132,7 @@ void ShenandoahRootScanner<ITR>::strong_roots_do(uint worker_id, OopClosure* oop
ResourceMark rm; ResourceMark rm;
_serial_roots.oops_do(oops, worker_id); _serial_roots.oops_do(oops, worker_id);
_jni_roots.oops_do(oops, worker_id);
_cld_roots.clds_do(clds, NULL, worker_id); _cld_roots.clds_do(clds, NULL, worker_id);
_thread_roots.threads_do(&tc_cl, worker_id); _thread_roots.threads_do(&tc_cl, worker_id);
} }
@ -141,6 +144,7 @@ void ShenandoahRootUpdater::roots_do(uint worker_id, IsAlive* is_alive, KeepAliv
CLDToOopClosure* weak_clds = ShenandoahHeap::heap()->unload_classes() ? NULL : &clds; CLDToOopClosure* weak_clds = ShenandoahHeap::heap()->unload_classes() ? NULL : &clds;
_serial_roots.oops_do(keep_alive, worker_id); _serial_roots.oops_do(keep_alive, worker_id);
_jni_roots.oops_do(keep_alive, worker_id);
_thread_roots.oops_do(keep_alive, NULL, worker_id); _thread_roots.oops_do(keep_alive, NULL, worker_id);
_cld_roots.clds_do(&clds, weak_clds, worker_id); _cld_roots.clds_do(&clds, weak_clds, worker_id);

View File

@ -69,15 +69,18 @@ void ShenandoahRootVerifier::oops_do(OopClosure* oops) {
if (verify(SerialRoots)) { if (verify(SerialRoots)) {
shenandoah_assert_safepoint(); shenandoah_assert_safepoint();
Universe::oops_do(oops); Universe::oops_do(oops);
Management::oops_do(oops); Management::oops_do(oops);
JvmtiExport::oops_do(oops); JvmtiExport::oops_do(oops);
JNIHandles::oops_do(oops);
ObjectSynchronizer::oops_do(oops); ObjectSynchronizer::oops_do(oops);
SystemDictionary::oops_do(oops); SystemDictionary::oops_do(oops);
} }
if (verify(JNIHandleRoots)) {
shenandoah_assert_safepoint();
JNIHandles::oops_do(oops);
}
if (verify(WeakRoots)) { if (verify(WeakRoots)) {
shenandoah_assert_safepoint(); shenandoah_assert_safepoint();
AlwaysTrueClosure always_true; AlwaysTrueClosure always_true;

View File

@ -36,7 +36,8 @@ public:
CLDGRoots = 1 << 3, CLDGRoots = 1 << 3,
WeakRoots = 1 << 4, WeakRoots = 1 << 4,
StringDedupRoots = 1 << 5, StringDedupRoots = 1 << 5,
AllRoots = (SerialRoots | ThreadRoots | CodeRoots | CLDGRoots | WeakRoots | StringDedupRoots) JNIHandleRoots = 1 << 6,
AllRoots = (SerialRoots | ThreadRoots | CodeRoots | CLDGRoots | WeakRoots | StringDedupRoots | JNIHandleRoots)
}; };
private: private: