From 4f87fb53ee5c6071fa57dfe9452eca9fe7b460ee Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Wed, 21 Jan 2026 09:01:00 +0000 Subject: [PATCH] 8375622: G1: Convert G1CodeRootSet to use Atomic Reviewed-by: shade, sjohanss --- src/hotspot/share/gc/g1/g1CodeRootSet.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1CodeRootSet.cpp b/src/hotspot/share/gc/g1/g1CodeRootSet.cpp index 60ad3a2af32..ca4487876b9 100644 --- a/src/hotspot/share/gc/g1/g1CodeRootSet.cpp +++ b/src/hotspot/share/gc/g1/g1CodeRootSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -28,7 +28,7 @@ #include "gc/g1/g1HeapRegion.hpp" #include "memory/allocation.hpp" #include "oops/oop.inline.hpp" -#include "runtime/atomicAccess.hpp" +#include "runtime/atomic.hpp" #include "utilities/concurrentHashTable.inline.hpp" #include "utilities/concurrentHashTableTasks.inline.hpp" @@ -60,7 +60,7 @@ class G1CodeRootSetHashTable : public CHeapObj { HashTable _table; HashTableScanTask _table_scanner; - size_t volatile _num_entries; + Atomic _num_entries; bool is_empty() const { return number_of_entries() == 0; } @@ -120,7 +120,7 @@ public: bool grow_hint = false; bool inserted = _table.insert(Thread::current(), lookup, method, &grow_hint); if (inserted) { - AtomicAccess::inc(&_num_entries); + _num_entries.add_then_fetch(1u); } if (grow_hint) { _table.grow(Thread::current()); @@ -131,7 +131,7 @@ public: HashTableLookUp lookup(method); bool removed = _table.remove(Thread::current(), lookup); if (removed) { - AtomicAccess::dec(&_num_entries); + _num_entries.sub_then_fetch(1u); } return removed; } @@ -182,7 +182,7 @@ public: guarantee(succeeded, "unable to clean table"); if (num_deleted != 0) { - size_t current_size = AtomicAccess::sub(&_num_entries, num_deleted); + size_t current_size = _num_entries.sub_then_fetch(num_deleted); shrink_to_match(current_size); } } @@ -226,7 +226,7 @@ public: size_t mem_size() { return sizeof(*this) + _table.get_mem_size(Thread::current()); } - size_t number_of_entries() const { return AtomicAccess::load(&_num_entries); } + size_t number_of_entries() const { return _num_entries.load_relaxed(); } }; uintx G1CodeRootSetHashTable::HashTableLookUp::get_hash() const {