From 7a1cb64bc1b85b3ef1b0ba2d84dbc5b8b05c60ff Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Mon, 8 May 2023 07:54:08 +0000 Subject: [PATCH] 8293547: Add relaxed add_and_fetch for macos aarch64 atomics Reviewed-by: dholmes, eosterlund --- src/hotspot/os_cpu/bsd_aarch64/atomic_bsd_aarch64.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/hotspot/os_cpu/bsd_aarch64/atomic_bsd_aarch64.hpp b/src/hotspot/os_cpu/bsd_aarch64/atomic_bsd_aarch64.hpp index fba59870d7c..5a88b1a32f0 100644 --- a/src/hotspot/os_cpu/bsd_aarch64/atomic_bsd_aarch64.hpp +++ b/src/hotspot/os_cpu/bsd_aarch64/atomic_bsd_aarch64.hpp @@ -37,9 +37,13 @@ template struct Atomic::PlatformAdd { template D add_and_fetch(D volatile* dest, I add_value, atomic_memory_order order) const { - D res = __atomic_add_fetch(dest, add_value, __ATOMIC_RELEASE); - FULL_MEM_BARRIER; - return res; + if (order == memory_order_relaxed) { + return __atomic_add_fetch(dest, add_value, __ATOMIC_RELAXED); + } else { + D res = __atomic_add_fetch(dest, add_value, __ATOMIC_RELEASE); + FULL_MEM_BARRIER; + return res; + } } template