8224875: Shenandoah: ParallelCleaning code unloading should take lock to protect shared code roots array
Reviewed-by: shade
This commit is contained in:
parent
71825293eb
commit
951e0b22d7
@ -26,6 +26,7 @@
|
||||
#include "code/nmethod.hpp"
|
||||
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
|
||||
#include "gc/shenandoah/shenandoahCodeRoots.hpp"
|
||||
#include "gc/shenandoah/shenandoahUtils.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
|
||||
@ -121,18 +122,21 @@ public:
|
||||
};
|
||||
|
||||
GrowableArray<ShenandoahNMethod*>* ShenandoahCodeRoots::_recorded_nms;
|
||||
ShenandoahLock ShenandoahCodeRoots::_recorded_nms_lock;
|
||||
|
||||
void ShenandoahCodeRoots::initialize() {
|
||||
_recorded_nms = new (ResourceObj::C_HEAP, mtGC) GrowableArray<ShenandoahNMethod*>(100, true, mtGC);
|
||||
}
|
||||
|
||||
void ShenandoahCodeRoots::add_nmethod(nmethod* nm) {
|
||||
assert(CodeCache_lock->owned_by_self(), "Must own CodeCache_lock");
|
||||
switch (ShenandoahCodeRootsStyle) {
|
||||
case 0:
|
||||
case 1:
|
||||
break;
|
||||
case 2: {
|
||||
assert_locked_or_safepoint(CodeCache_lock);
|
||||
ShenandoahLocker locker(CodeCache_lock->owned_by_self() ? NULL : &_recorded_nms_lock);
|
||||
|
||||
ShenandoahNMethodOopDetector detector;
|
||||
nm->oops_do(&detector);
|
||||
|
||||
@ -156,13 +160,15 @@ void ShenandoahCodeRoots::add_nmethod(nmethod* nm) {
|
||||
};
|
||||
|
||||
void ShenandoahCodeRoots::remove_nmethod(nmethod* nm) {
|
||||
assert(CodeCache_lock->owned_by_self(), "Must own CodeCache_lock");
|
||||
switch (ShenandoahCodeRootsStyle) {
|
||||
case 0:
|
||||
case 1: {
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
assert_locked_or_safepoint(CodeCache_lock);
|
||||
ShenandoahLocker locker(CodeCache_lock->owned_by_self() ? NULL : &_recorded_nms_lock);
|
||||
|
||||
ShenandoahNMethodOopDetector detector;
|
||||
nm->oops_do(&detector, /* allow_zombie = */ true);
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "code/codeCache.hpp"
|
||||
#include "gc/shenandoah/shenandoahSharedVariables.hpp"
|
||||
#include "gc/shenandoah/shenandoahLock.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/iterator.hpp"
|
||||
|
||||
@ -132,6 +133,7 @@ public:
|
||||
|
||||
private:
|
||||
static GrowableArray<ShenandoahNMethod*>* _recorded_nms;
|
||||
static ShenandoahLock _recorded_nms_lock;
|
||||
};
|
||||
|
||||
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHCODEROOTS_HPP
|
||||
|
Loading…
x
Reference in New Issue
Block a user