8261503: Shenandoah: reconsider verifier memory ordering

Reviewed-by: zgu
This commit is contained in:
Aleksey Shipilev 2021-02-15 08:41:28 +00:00
parent d9744f6536
commit 7c93159169

View File

@ -160,7 +160,7 @@ private:
// skip // skip
break; break;
case ShenandoahVerifier::_verify_liveness_complete: case ShenandoahVerifier::_verify_liveness_complete:
Atomic::add(&_ld[obj_reg->index()], (uint) obj->size()); Atomic::add(&_ld[obj_reg->index()], (uint) obj->size(), memory_order_relaxed);
// fallthrough for fast failure for un-live regions: // fallthrough for fast failure for un-live regions:
case ShenandoahVerifier::_verify_liveness_conservative: case ShenandoahVerifier::_verify_liveness_conservative:
check(ShenandoahAsserts::_safe_oop, obj, obj_reg->has_live(), check(ShenandoahAsserts::_safe_oop, obj, obj_reg->has_live(),
@ -483,7 +483,7 @@ public:
} }
} }
Atomic::add(&_processed, processed); Atomic::add(&_processed, processed, memory_order_relaxed);
} }
}; };
@ -512,7 +512,7 @@ public:
_processed(0) {}; _processed(0) {};
size_t processed() { size_t processed() {
return _processed; return Atomic::load(&_processed);
} }
virtual void work(uint worker_id) { virtual void work(uint worker_id) {
@ -522,7 +522,7 @@ public:
_options); _options);
while (true) { while (true) {
size_t v = Atomic::fetch_and_add(&_claimed, 1u); size_t v = Atomic::fetch_and_add(&_claimed, 1u, memory_order_relaxed);
if (v < _heap->num_regions()) { if (v < _heap->num_regions()) {
ShenandoahHeapRegion* r = _heap->get_region(v); ShenandoahHeapRegion* r = _heap->get_region(v);
if (!r->is_humongous() && !r->is_trash()) { if (!r->is_humongous() && !r->is_trash()) {
@ -542,7 +542,7 @@ public:
if (_heap->complete_marking_context()->is_marked((oop)obj)) { if (_heap->complete_marking_context()->is_marked((oop)obj)) {
verify_and_follow(obj, stack, cl, &processed); verify_and_follow(obj, stack, cl, &processed);
} }
Atomic::add(&_processed, processed); Atomic::add(&_processed, processed, memory_order_relaxed);
} }
virtual void work_regular(ShenandoahHeapRegion *r, ShenandoahVerifierStack &stack, ShenandoahVerifyOopClosure &cl) { virtual void work_regular(ShenandoahHeapRegion *r, ShenandoahVerifierStack &stack, ShenandoahVerifyOopClosure &cl) {
@ -575,7 +575,7 @@ public:
} }
} }
Atomic::add(&_processed, processed); Atomic::add(&_processed, processed, memory_order_relaxed);
} }
void verify_and_follow(HeapWord *addr, ShenandoahVerifierStack &stack, ShenandoahVerifyOopClosure &cl, size_t *processed) { void verify_and_follow(HeapWord *addr, ShenandoahVerifierStack &stack, ShenandoahVerifyOopClosure &cl, size_t *processed) {
@ -747,12 +747,12 @@ void ShenandoahVerifier::verify_at_safepoint(const char *label,
if (r->is_humongous()) { if (r->is_humongous()) {
// For humongous objects, test if start region is marked live, and if so, // For humongous objects, test if start region is marked live, and if so,
// all humongous regions in that chain have live data equal to their "used". // all humongous regions in that chain have live data equal to their "used".
juint start_live = Atomic::load_acquire(&ld[r->humongous_start_region()->index()]); juint start_live = Atomic::load(&ld[r->humongous_start_region()->index()]);
if (start_live > 0) { if (start_live > 0) {
verf_live = (juint)(r->used() / HeapWordSize); verf_live = (juint)(r->used() / HeapWordSize);
} }
} else { } else {
verf_live = Atomic::load_acquire(&ld[r->index()]); verf_live = Atomic::load(&ld[r->index()]);
} }
size_t reg_live = r->get_live_data_words(); size_t reg_live = r->get_live_data_words();