ZGC: Convert zRootsIterator to use Atomic<T>

This commit is contained in:
Axel Boldt-Christmas 2026-01-07 06:56:59 +00:00
parent c1c0ac8770
commit c21b49dc30
2 changed files with 9 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
@ -29,7 +29,6 @@
#include "gc/z/zStat.hpp"
#include "memory/resourceArea.hpp"
#include "prims/jvmtiTagMap.hpp"
#include "runtime/atomicAccess.hpp"
#include "runtime/globals.hpp"
#include "runtime/safepoint.hpp"
#include "utilities/debug.hpp"
@ -91,10 +90,10 @@ public:
template <typename Iterator>
template <typename ClosureType>
void ZParallelApply<Iterator>::apply(ClosureType* cl) {
if (!AtomicAccess::load(&_completed)) {
if (!_completed.load_relaxed()) {
_iter.apply(cl);
if (!AtomicAccess::load(&_completed)) {
AtomicAccess::store(&_completed, true);
if (!_completed.load_relaxed()) {
_completed.store_relaxed(true);
}
}
}
@ -120,7 +119,7 @@ void ZCLDsIteratorAll::apply(CLDClosure* cl) {
}
uint ZJavaThreadsIterator::claim() {
return AtomicAccess::fetch_then_add(&_claimed, 1u);
return _claimed.fetch_then_add(1u);
}
void ZJavaThreadsIterator::apply(ThreadClosure* cl) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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,13 +28,14 @@
#include "gc/z/zGenerationId.hpp"
#include "logging/log.hpp"
#include "memory/iterator.hpp"
#include "runtime/atomic.hpp"
#include "runtime/threadSMR.hpp"
template <typename Iterator>
class ZParallelApply {
private:
Iterator _iter;
volatile bool _completed;
Atomic<bool> _completed;
public:
ZParallelApply(ZGenerationIdOptional generation)
@ -113,7 +114,7 @@ public:
class ZJavaThreadsIterator {
private:
ThreadsListHandle _threads;
volatile uint _claimed;
Atomic<uint> _claimed;
const ZGenerationIdOptional _generation;
uint claim();