From de5c7a9e8607b2a6219d98f9b81ddce4ca92baef Mon Sep 17 00:00:00 2001 From: Axel Boldt-Christmas Date: Mon, 26 Jan 2026 12:16:05 +0000 Subject: [PATCH] 8374676: ZGC: Convert zAbort to use Atomic Reviewed-by: stefank, tschatzl --- src/hotspot/share/gc/z/zAbort.cpp | 7 +++---- src/hotspot/share/gc/z/zAbort.hpp | 5 +++-- src/hotspot/share/gc/z/zAbort.inline.hpp | 6 ++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/hotspot/share/gc/z/zAbort.cpp b/src/hotspot/share/gc/z/zAbort.cpp index 3310793f730..82523ddebe8 100644 --- a/src/hotspot/share/gc/z/zAbort.cpp +++ b/src/hotspot/share/gc/z/zAbort.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,10 +22,9 @@ */ #include "gc/z/zAbort.hpp" -#include "runtime/atomicAccess.hpp" -volatile bool ZAbort::_should_abort = false; +Atomic ZAbort::_should_abort{}; void ZAbort::abort() { - AtomicAccess::store(&_should_abort, true); + _should_abort.store_relaxed(true); } diff --git a/src/hotspot/share/gc/z/zAbort.hpp b/src/hotspot/share/gc/z/zAbort.hpp index 925b0a79ac3..64633752d5d 100644 --- a/src/hotspot/share/gc/z/zAbort.hpp +++ b/src/hotspot/share/gc/z/zAbort.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,10 +25,11 @@ #define SHARE_GC_Z_ZABORT_HPP #include "memory/allStatic.hpp" +#include "runtime/atomic.hpp" class ZAbort : public AllStatic { private: - static volatile bool _should_abort; + static Atomic _should_abort; public: static bool should_abort(); diff --git a/src/hotspot/share/gc/z/zAbort.inline.hpp b/src/hotspot/share/gc/z/zAbort.inline.hpp index 37503e25f70..856179e9d2a 100644 --- a/src/hotspot/share/gc/z/zAbort.inline.hpp +++ b/src/hotspot/share/gc/z/zAbort.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,10 +26,8 @@ #include "gc/z/zAbort.hpp" -#include "runtime/atomicAccess.hpp" - inline bool ZAbort::should_abort() { - return AtomicAccess::load(&_should_abort); + return _should_abort.load_relaxed(); } #endif // SHARE_GC_Z_ZABORT_INLINE_HPP