8261501: Shenandoah: reconsider heap statistics memory ordering

Reviewed-by: rkennke
This commit is contained in:
Aleksey Shipilev 2021-02-16 10:31:40 +00:00
parent 3cbd16de3d
commit 3f8819c666

@ -620,12 +620,11 @@ void ShenandoahHeap::post_initialize() {
} }
size_t ShenandoahHeap::used() const { size_t ShenandoahHeap::used() const {
return Atomic::load_acquire(&_used); return Atomic::load(&_used);
} }
size_t ShenandoahHeap::committed() const { size_t ShenandoahHeap::committed() const {
OrderAccess::acquire(); return Atomic::load(&_committed);
return _committed;
} }
void ShenandoahHeap::increase_committed(size_t bytes) { void ShenandoahHeap::increase_committed(size_t bytes) {
@ -639,20 +638,20 @@ void ShenandoahHeap::decrease_committed(size_t bytes) {
} }
void ShenandoahHeap::increase_used(size_t bytes) { void ShenandoahHeap::increase_used(size_t bytes) {
Atomic::add(&_used, bytes); Atomic::add(&_used, bytes, memory_order_relaxed);
} }
void ShenandoahHeap::set_used(size_t bytes) { void ShenandoahHeap::set_used(size_t bytes) {
Atomic::release_store_fence(&_used, bytes); Atomic::store(&_used, bytes);
} }
void ShenandoahHeap::decrease_used(size_t bytes) { void ShenandoahHeap::decrease_used(size_t bytes) {
assert(used() >= bytes, "never decrease heap size by more than we've left"); assert(used() >= bytes, "never decrease heap size by more than we've left");
Atomic::sub(&_used, bytes); Atomic::sub(&_used, bytes, memory_order_relaxed);
} }
void ShenandoahHeap::increase_allocated(size_t bytes) { void ShenandoahHeap::increase_allocated(size_t bytes) {
Atomic::add(&_bytes_allocated_since_gc_start, bytes); Atomic::add(&_bytes_allocated_since_gc_start, bytes, memory_order_relaxed);
} }
void ShenandoahHeap::notify_mutator_alloc_words(size_t words, bool waste) { void ShenandoahHeap::notify_mutator_alloc_words(size_t words, bool waste) {
@ -1883,11 +1882,11 @@ address ShenandoahHeap::gc_state_addr() {
} }
size_t ShenandoahHeap::bytes_allocated_since_gc_start() { size_t ShenandoahHeap::bytes_allocated_since_gc_start() {
return Atomic::load_acquire(&_bytes_allocated_since_gc_start); return Atomic::load(&_bytes_allocated_since_gc_start);
} }
void ShenandoahHeap::reset_bytes_allocated_since_gc_start() { void ShenandoahHeap::reset_bytes_allocated_since_gc_start() {
Atomic::release_store_fence(&_bytes_allocated_since_gc_start, (size_t)0); Atomic::store(&_bytes_allocated_since_gc_start, (size_t)0);
} }
void ShenandoahHeap::set_degenerated_gc_in_progress(bool in_progress) { void ShenandoahHeap::set_degenerated_gc_in_progress(bool in_progress) {