diff --git a/src/hotspot/share/gc/z/zMark.cpp b/src/hotspot/share/gc/z/zMark.cpp index 3b247fdd35e..03701ae9998 100644 --- a/src/hotspot/share/gc/z/zMark.cpp +++ b/src/hotspot/share/gc/z/zMark.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -57,7 +57,6 @@ #include "memory/iterator.inline.hpp" #include "oops/objArrayOop.inline.hpp" #include "oops/oop.inline.hpp" -#include "runtime/atomicAccess.hpp" #include "runtime/continuation.hpp" #include "runtime/handshake.hpp" #include "runtime/javaThread.hpp" @@ -152,13 +151,14 @@ void ZMark::prepare_work() { _terminate.reset(_nworkers); // Reset flush counters - _work_nproactiveflush = _work_nterminateflush = 0; + _work_nproactiveflush.store_relaxed(0u); + _work_nterminateflush.store_relaxed(0u); } void ZMark::finish_work() { // Accumulate proactive/terminate flush counters - _nproactiveflush += _work_nproactiveflush; - _nterminateflush += _work_nterminateflush; + _nproactiveflush += _work_nproactiveflush.load_relaxed(); + _nterminateflush += _work_nterminateflush.load_relaxed(); } void ZMark::follow_work_complete() { @@ -594,7 +594,7 @@ bool ZMark::flush() { } bool ZMark::try_terminate_flush() { - AtomicAccess::inc(&_work_nterminateflush); + _work_nterminateflush.add_then_fetch(1u); _terminate.set_resurrected(false); if (ZVerifyMarking) { @@ -610,12 +610,12 @@ bool ZMark::try_proactive_flush() { return false; } - if (AtomicAccess::load(&_work_nproactiveflush) == ZMarkProactiveFlushMax) { + if (_work_nproactiveflush.load_relaxed() == ZMarkProactiveFlushMax) { // Limit reached or we're trying to terminate return false; } - AtomicAccess::inc(&_work_nproactiveflush); + _work_nproactiveflush.add_then_fetch(1u); SuspendibleThreadSetLeaver sts_leaver; return flush(); diff --git a/src/hotspot/share/gc/z/zMark.hpp b/src/hotspot/share/gc/z/zMark.hpp index cc398addeb8..72a527b957d 100644 --- a/src/hotspot/share/gc/z/zMark.hpp +++ b/src/hotspot/share/gc/z/zMark.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -30,6 +30,7 @@ #include "gc/z/zMarkStackEntry.hpp" #include "gc/z/zMarkTerminate.hpp" #include "oops/oopsHierarchy.hpp" +#include "runtime/atomic.hpp" #include "utilities/globalDefinitions.hpp" class Thread; @@ -60,8 +61,8 @@ private: ZMarkingSMR _marking_smr; ZMarkStripeSet _stripes; ZMarkTerminate _terminate; - volatile size_t _work_nproactiveflush; - volatile size_t _work_nterminateflush; + Atomic _work_nproactiveflush; + Atomic _work_nterminateflush; size_t _nproactiveflush; size_t _nterminateflush; size_t _ntrycomplete;