mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
ZGC: Convert zRootsIterator to use Atomic<T>
This commit is contained in:
parent
c1c0ac8770
commit
c21b49dc30
@ -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) {
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user