diff --git a/src/hotspot/share/gc/g1/g1FullCollector.cpp b/src/hotspot/share/gc/g1/g1FullCollector.cpp index 7395df01760..6c8cc7028cc 100644 --- a/src/hotspot/share/gc/g1/g1FullCollector.cpp +++ b/src/hotspot/share/gc/g1/g1FullCollector.cpp @@ -134,10 +134,10 @@ G1FullCollector::G1FullCollector(G1CollectedHeap* heap, _compaction_points = NEW_C_HEAP_ARRAY(G1FullGCCompactionPoint*, _num_workers, 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, _heap->max_num_regions(), mtGC); for (uint j = 0; j < heap->max_num_regions(); j++) { _live_stats[j].clear(); - _compaction_tops[j] = nullptr; + ::new (&_compaction_tops[j]) Atomic{}; } _partial_array_state_manager = new PartialArrayStateManager(_num_workers); @@ -167,7 +167,7 @@ G1FullCollector::~G1FullCollector() { FREE_C_HEAP_ARRAY(G1FullGCMarker*, _markers); FREE_C_HEAP_ARRAY(G1FullGCCompactionPoint*, _compaction_points); - FREE_C_HEAP_ARRAY(HeapWord*, _compaction_tops); + FREE_C_HEAP_ARRAY(Atomic, _compaction_tops); FREE_C_HEAP_ARRAY(G1RegionMarkStats, _live_stats); } diff --git a/src/hotspot/share/gc/g1/g1FullCollector.hpp b/src/hotspot/share/gc/g1/g1FullCollector.hpp index 28ecffad944..7e455b07013 100644 --- a/src/hotspot/share/gc/g1/g1FullCollector.hpp +++ b/src/hotspot/share/gc/g1/g1FullCollector.hpp @@ -96,7 +96,7 @@ class G1FullCollector : StackObj { G1FullGCHeapRegionAttr _region_attr_table; - HeapWord* volatile* _compaction_tops; + Atomic* _compaction_tops; public: G1FullCollector(G1CollectedHeap* heap, diff --git a/src/hotspot/share/gc/g1/g1FullCollector.inline.hpp b/src/hotspot/share/gc/g1/g1FullCollector.inline.hpp index b52f3d79604..0c201f0e43f 100644 --- a/src/hotspot/share/gc/g1/g1FullCollector.inline.hpp +++ b/src/hotspot/share/gc/g1/g1FullCollector.inline.hpp @@ -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. * * 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) { - AtomicAccess::store(&_compaction_tops[r->hrm_index()], value); + _compaction_tops[r->hrm_index()].store_relaxed(value); } 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() {