8245124: Shenandoah: optimize code root evacuation/update during concurrent class unloading

Reviewed-by: shade
This commit is contained in:
Zhengyu Gu 2020-05-18 14:47:09 -04:00
parent 3eaf944203
commit b26516309a
4 changed files with 29 additions and 22 deletions

View File

@ -26,6 +26,7 @@
#include "code/codeCache.hpp"
#include "code/icBuffer.hpp"
#include "code/nmethod.hpp"
#include "gc/shenandoah/shenandoahClosures.inline.hpp"
#include "gc/shenandoah/shenandoahCodeRoots.hpp"
#include "gc/shenandoah/shenandoahEvacOOMHandler.hpp"
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
@ -272,7 +273,8 @@ public:
// Heal oops and disarm
if (_bs->is_armed(nm)) {
ShenandoahNMethod::heal_nmethod(nm);
ShenandoahEvacOOMScope oom_evac_scope;
ShenandoahNMethod::heal_nmethod_metadata(nm_data);
_bs->disarm(nm);
}

View File

@ -110,24 +110,6 @@ void ShenandoahNMethod::update() {
assert_same_oops();
}
void ShenandoahNMethod::oops_do(OopClosure* oops, bool fix_relocations) {
for (int c = 0; c < _oops_count; c ++) {
oops->do_oop(_oops[c]);
}
oop* const begin = _nm->oops_begin();
oop* const end = _nm->oops_end();
for (oop* p = begin; p < end; p++) {
if (*p != Universe::non_oop_word()) {
oops->do_oop(p);
}
}
if (fix_relocations && _has_non_immed_oops) {
_nm->fix_oop_relocations();
}
}
void ShenandoahNMethod::detect_reloc_oops(nmethod* nm, GrowableArray<oop*>& oops, bool& has_non_immed_oops) {
has_non_immed_oops = false;
// Find all oops relocations
@ -215,8 +197,7 @@ void ShenandoahNMethod::heal_nmethod(nmethod* nm) {
}
} else if (heap->is_concurrent_weak_root_in_progress()) {
ShenandoahEvacOOMScope evac_scope;
ShenandoahEvacuateUpdateRootsClosure<> cl;
data->oops_do(&cl, true /*fix relocation*/);
heal_nmethod_metadata(data);
} else {
// There is possibility that GC is cancelled when it arrives final mark.
// In this case, concurrent root phase is skipped and degenerated GC should be

View File

@ -51,7 +51,7 @@ public:
inline nmethod* nm() const;
inline ShenandoahReentrantLock* lock();
void oops_do(OopClosure* oops, bool fix_relocations = false);
inline void oops_do(OopClosure* oops, bool fix_relocations = false);
// Update oops when the nmethod is re-registered
void update();
@ -67,6 +67,7 @@ public:
static inline ShenandoahReentrantLock* lock_for_nmethod(nmethod* nm);
static void heal_nmethod(nmethod* nm);
static inline void heal_nmethod_metadata(ShenandoahNMethod* nmethod_data);
static inline void disarm_nmethod(nmethod* nm);
static inline ShenandoahNMethod* gc_data(nmethod* nm);

View File

@ -54,6 +54,29 @@ bool ShenandoahNMethod::is_unregistered() const {
return _unregistered;
}
void ShenandoahNMethod::oops_do(OopClosure* oops, bool fix_relocations) {
for (int c = 0; c < _oops_count; c ++) {
oops->do_oop(_oops[c]);
}
oop* const begin = _nm->oops_begin();
oop* const end = _nm->oops_end();
for (oop* p = begin; p < end; p++) {
if (*p != Universe::non_oop_word()) {
oops->do_oop(p);
}
}
if (fix_relocations && _has_non_immed_oops) {
_nm->fix_oop_relocations();
}
}
void ShenandoahNMethod::heal_nmethod_metadata(ShenandoahNMethod* nmethod_data) {
ShenandoahEvacuateUpdateRootsClosure<> cl;
nmethod_data->oops_do(&cl, true /*fix relocation*/);
}
void ShenandoahNMethod::disarm_nmethod(nmethod* nm) {
if (!ShenandoahConcurrentRoots::can_do_concurrent_class_unloading()) {
return;