From 63be87d7f38a83c5fcdf59b54c6d63e0f0ca34d6 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Thu, 22 Jan 2026 08:35:03 +0000 Subject: [PATCH] 8375977: G1: Convert JVMCICleaningTask to use Atomic Reviewed-by: kbarrett --- src/hotspot/share/gc/g1/g1ParallelCleaning.cpp | 7 +++---- src/hotspot/share/gc/g1/g1ParallelCleaning.hpp | 7 +++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1ParallelCleaning.cpp b/src/hotspot/share/gc/g1/g1ParallelCleaning.cpp index 8d5e2a3239c..e3eabff5a50 100644 --- a/src/hotspot/share/gc/g1/g1ParallelCleaning.cpp +++ b/src/hotspot/share/gc/g1/g1ParallelCleaning.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -24,7 +24,6 @@ #include "gc/g1/g1ParallelCleaning.hpp" -#include "runtime/atomicAccess.hpp" #if INCLUDE_JVMCI #include "jvmci/jvmci.hpp" #endif @@ -35,11 +34,11 @@ JVMCICleaningTask::JVMCICleaningTask() : } bool JVMCICleaningTask::claim_cleaning_task() { - if (AtomicAccess::load(&_cleaning_claimed)) { + if (_cleaning_claimed.load_relaxed()) { return false; } - return !AtomicAccess::cmpxchg(&_cleaning_claimed, false, true); + return _cleaning_claimed.compare_set(false, true); } void JVMCICleaningTask::work(bool unloading_occurred) { diff --git a/src/hotspot/share/gc/g1/g1ParallelCleaning.hpp b/src/hotspot/share/gc/g1/g1ParallelCleaning.hpp index d8725cb110d..815b0883e16 100644 --- a/src/hotspot/share/gc/g1/g1ParallelCleaning.hpp +++ b/src/hotspot/share/gc/g1/g1ParallelCleaning.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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,13 @@ #define SHARE_GC_G1_G1PARALLELCLEANING_HPP #include "gc/shared/parallelCleaning.hpp" +#if INCLUDE_JVMCI +#include "runtime/atomic.hpp" +#endif #if INCLUDE_JVMCI class JVMCICleaningTask : public StackObj { - volatile bool _cleaning_claimed; + Atomic _cleaning_claimed; public: JVMCICleaningTask();