From 5f4965d422cf1d2b4bb372202e6cae96be863d30 Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Tue, 25 Apr 2023 17:55:57 +0000 Subject: [PATCH] 8306687: Relax memory ordering constraints on metaspace atomic counters Reviewed-by: shade, minqi --- src/hotspot/share/memory/metaspace/counters.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hotspot/share/memory/metaspace/counters.hpp b/src/hotspot/share/memory/metaspace/counters.hpp index 33c19d1186a..c7c841df423 100644 --- a/src/hotspot/share/memory/metaspace/counters.hpp +++ b/src/hotspot/share/memory/metaspace/counters.hpp @@ -93,22 +93,22 @@ public: AbstractAtomicCounter() : _c(0) {} - T get() const { return _c; } + T get() const { return Atomic::load(&_c); } void increment() { - Atomic::inc(&_c); + Atomic::inc(&_c, memory_order_relaxed); } void decrement() { - Atomic::dec(&_c); + Atomic::dec(&_c, memory_order_relaxed); } void increment_by(T v) { - Atomic::add(&_c, v); + Atomic::add(&_c, v, memory_order_relaxed); } void decrement_by(T v) { - Atomic::sub(&_c, v); + Atomic::sub(&_c, v, memory_order_relaxed); } #ifdef ASSERT