From a316c06e03e06b86ceca376cf20dcb9c526905f5 Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Wed, 3 Nov 2021 12:08:37 +0000 Subject: [PATCH] 8275730: Relax memory constraint on MultiThreadedRefCounter Reviewed-by: mgronlun, minqi --- src/hotspot/share/jfr/utilities/jfrRefCountPointer.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/jfr/utilities/jfrRefCountPointer.hpp b/src/hotspot/share/jfr/utilities/jfrRefCountPointer.hpp index d24da8fdd82b0..149047837b7ef 100644 --- a/src/hotspot/share/jfr/utilities/jfrRefCountPointer.hpp +++ b/src/hotspot/share/jfr/utilities/jfrRefCountPointer.hpp @@ -112,15 +112,15 @@ class MultiThreadedRefCounter { MultiThreadedRefCounter() : _refs(0) {} void inc() const { - Atomic::add(&_refs, 1); + Atomic::inc(&_refs, memory_order_relaxed); } bool dec() const { - return 0 == Atomic::add(&_refs, (-1)); + return 0 == Atomic::sub(&_refs, 1, memory_order_relaxed); } intptr_t current() const { - return _refs; + return Atomic::load(&_refs); } };