8387322: G1: G1CSetCandidateGroupList::_num_regions should be Atomic

Reviewed-by: stefank
This commit is contained in:
Thomas Schatzl 2026-06-29 08:45:26 +00:00
parent 007c7e38be
commit 5f1355b085
2 changed files with 8 additions and 7 deletions

View File

@ -134,7 +134,7 @@ void G1CSetCandidateGroupList::append(G1CSetCandidateGroup* group) {
assert(group->length() > 0, "Do not add empty groups");
assert(!_groups.contains(group), "Already added to list");
_groups.append(group);
_num_regions += group->length();
_num_regions.store_relaxed(num_regions() + group->length());
}
G1CSetCandidateGroup* G1CSetCandidateGroupList::at(uint index) {
@ -147,7 +147,7 @@ void G1CSetCandidateGroupList::clear(bool uninstall_group_cardset) {
delete gr;
}
_groups.clear();
_num_regions = 0;
_num_regions.store_relaxed(0);
}
void G1CSetCandidateGroupList::prepare_for_scan() {
@ -156,9 +156,9 @@ void G1CSetCandidateGroupList::prepare_for_scan() {
}
}
void G1CSetCandidateGroupList::remove_selected(uint count, uint num_regions) {
void G1CSetCandidateGroupList::remove_selected(uint count, uint num_regions_to_remove) {
_groups.remove_till(count);
_num_regions -= num_regions;
_num_regions.store_relaxed(num_regions() - num_regions_to_remove);
}
void G1CSetCandidateGroupList::remove(G1CSetCandidateGroupList* other) {
@ -172,7 +172,7 @@ void G1CSetCandidateGroupList::remove(G1CSetCandidateGroupList* other) {
// Create a list from scratch, copying over the elements from the candidate
// list not in the other list. Finally deallocate and overwrite the old list.
int new_length = _groups.length() - other->length();
_num_regions = num_regions() - other->num_regions();
_num_regions.store_relaxed(num_regions() - other->num_regions());
GrowableArray<G1CSetCandidateGroup*> new_list(new_length, mtGC);
uint other_idx = 0;

View File

@ -29,6 +29,7 @@
#include "gc/g1/g1CollectionSetCandidates.hpp"
#include "gc/shared/gc_globals.hpp"
#include "memory/allocation.hpp"
#include "runtime/atomic.hpp"
#include "runtime/globals.hpp"
#include "utilities/growableArray.hpp"
@ -147,7 +148,7 @@ using G1CSetCandidateGroupListIterator = GrowableArrayIterator<G1CSetCandidateGr
class G1CSetCandidateGroupList {
GrowableArray<G1CSetCandidateGroup*> _groups;
volatile uint _num_regions;
Atomic<uint> _num_regions;
public:
G1CSetCandidateGroupList();
@ -163,7 +164,7 @@ public:
uint length() const { return (uint)_groups.length(); }
uint num_regions() const { return _num_regions; }
uint num_regions() const { return _num_regions.load_relaxed(); }
void remove_selected(uint count, uint num_regions);