8375974: G1: Convert G1FullCollector to use Atomic<T>

Reviewed-by: kbarrett, iwalulya
This commit is contained in:
Thomas Schatzl 2026-01-26 09:16:11 +00:00
parent e7cadd90b2
commit 4597046984
3 changed files with 7 additions and 7 deletions

View File

@ -134,10 +134,10 @@ G1FullCollector::G1FullCollector(G1CollectedHeap* heap,
_compaction_points = NEW_C_HEAP_ARRAY(G1FullGCCompactionPoint*, _num_workers, mtGC); _compaction_points = NEW_C_HEAP_ARRAY(G1FullGCCompactionPoint*, _num_workers, mtGC);
_live_stats = NEW_C_HEAP_ARRAY(G1RegionMarkStats, _heap->max_num_regions(), mtGC); _live_stats = NEW_C_HEAP_ARRAY(G1RegionMarkStats, _heap->max_num_regions(), mtGC);
_compaction_tops = NEW_C_HEAP_ARRAY(HeapWord*, _heap->max_num_regions(), mtGC); _compaction_tops = NEW_C_HEAP_ARRAY(Atomic<HeapWord*>, _heap->max_num_regions(), mtGC);
for (uint j = 0; j < heap->max_num_regions(); j++) { for (uint j = 0; j < heap->max_num_regions(); j++) {
_live_stats[j].clear(); _live_stats[j].clear();
_compaction_tops[j] = nullptr; ::new (&_compaction_tops[j]) Atomic<HeapWord*>{};
} }
_partial_array_state_manager = new PartialArrayStateManager(_num_workers); _partial_array_state_manager = new PartialArrayStateManager(_num_workers);
@ -167,7 +167,7 @@ G1FullCollector::~G1FullCollector() {
FREE_C_HEAP_ARRAY(G1FullGCMarker*, _markers); FREE_C_HEAP_ARRAY(G1FullGCMarker*, _markers);
FREE_C_HEAP_ARRAY(G1FullGCCompactionPoint*, _compaction_points); FREE_C_HEAP_ARRAY(G1FullGCCompactionPoint*, _compaction_points);
FREE_C_HEAP_ARRAY(HeapWord*, _compaction_tops); FREE_C_HEAP_ARRAY(Atomic<HeapWord*>, _compaction_tops);
FREE_C_HEAP_ARRAY(G1RegionMarkStats, _live_stats); FREE_C_HEAP_ARRAY(G1RegionMarkStats, _live_stats);
} }

View File

@ -96,7 +96,7 @@ class G1FullCollector : StackObj {
G1FullGCHeapRegionAttr _region_attr_table; G1FullGCHeapRegionAttr _region_attr_table;
HeapWord* volatile* _compaction_tops; Atomic<HeapWord*>* _compaction_tops;
public: public:
G1FullCollector(G1CollectedHeap* heap, G1FullCollector(G1CollectedHeap* heap,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -63,11 +63,11 @@ void G1FullCollector::update_from_skip_compacting_to_compacting(uint region_idx)
} }
void G1FullCollector::set_compaction_top(G1HeapRegion* r, HeapWord* value) { void G1FullCollector::set_compaction_top(G1HeapRegion* r, HeapWord* value) {
AtomicAccess::store(&_compaction_tops[r->hrm_index()], value); _compaction_tops[r->hrm_index()].store_relaxed(value);
} }
HeapWord* G1FullCollector::compaction_top(G1HeapRegion* r) const { HeapWord* G1FullCollector::compaction_top(G1HeapRegion* r) const {
return AtomicAccess::load(&_compaction_tops[r->hrm_index()]); return _compaction_tops[r->hrm_index()].load_relaxed();
} }
void G1FullCollector::set_has_compaction_targets() { void G1FullCollector::set_has_compaction_targets() {