8385901: G1: G1FullGCPrepareTask::_has_free_compaction_targets should be Atomic

Reviewed-by: ayang, iwalulya
This commit is contained in:
Thomas Schatzl 2026-06-12 08:53:57 +00:00
parent 55a53f945f
commit baf0f45fc7
2 changed files with 5 additions and 4 deletions

View File

@ -60,13 +60,13 @@ G1FullGCPrepareTask::G1FullGCPrepareTask(G1FullCollector* collector) :
}
void G1FullGCPrepareTask::set_has_free_compaction_targets() {
if (!_has_free_compaction_targets) {
_has_free_compaction_targets = true;
if (!has_free_compaction_targets()) {
_has_free_compaction_targets.store_relaxed(true);
}
}
bool G1FullGCPrepareTask::has_free_compaction_targets() {
return _has_free_compaction_targets;
return _has_free_compaction_targets.load_relaxed();
}
void G1FullGCPrepareTask::work(uint worker_id) {

View File

@ -28,6 +28,7 @@
#include "gc/g1/g1FullGCTask.hpp"
#include "gc/g1/g1HeapRegion.hpp"
#include "memory/allocation.hpp"
#include "runtime/atomic.hpp"
class G1CollectedHeap;
class G1CMBitMap;
@ -61,7 +62,7 @@ public:
};
class G1FullGCPrepareTask : public G1FullGCTask {
volatile bool _has_free_compaction_targets;
Atomic<bool> _has_free_compaction_targets;
G1HeapRegionClaimer _hrclaimer;
void set_has_free_compaction_targets();