8374680: ZGC: Convert zGeneration to use Atomic<T>

Reviewed-by: stefank, tschatzl
This commit is contained in:
Axel Boldt-Christmas 2026-01-26 14:28:39 +00:00
parent fef85ff932
commit b59f49a1c3
2 changed files with 15 additions and 15 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 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
@ -56,7 +56,6 @@
#include "logging/log.hpp" #include "logging/log.hpp"
#include "memory/universe.hpp" #include "memory/universe.hpp"
#include "prims/jvmtiTagMap.hpp" #include "prims/jvmtiTagMap.hpp"
#include "runtime/atomicAccess.hpp"
#include "runtime/continuation.hpp" #include "runtime/continuation.hpp"
#include "runtime/handshake.hpp" #include "runtime/handshake.hpp"
#include "runtime/safepoint.hpp" #include "runtime/safepoint.hpp"
@ -298,33 +297,33 @@ bool ZGeneration::is_relocate_queue_active() const {
void ZGeneration::reset_statistics() { void ZGeneration::reset_statistics() {
assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
_freed = 0; _freed.store_relaxed(0u);
_promoted = 0; _promoted.store_relaxed(0u);
_compacted = 0; _compacted.store_relaxed(0u);
} }
size_t ZGeneration::freed() const { size_t ZGeneration::freed() const {
return _freed; return _freed.load_relaxed();
} }
void ZGeneration::increase_freed(size_t size) { void ZGeneration::increase_freed(size_t size) {
AtomicAccess::add(&_freed, size, memory_order_relaxed); _freed.add_then_fetch(size, memory_order_relaxed);
} }
size_t ZGeneration::promoted() const { size_t ZGeneration::promoted() const {
return _promoted; return _promoted.load_relaxed();;
} }
void ZGeneration::increase_promoted(size_t size) { void ZGeneration::increase_promoted(size_t size) {
AtomicAccess::add(&_promoted, size, memory_order_relaxed); _promoted.add_then_fetch(size, memory_order_relaxed);
} }
size_t ZGeneration::compacted() const { size_t ZGeneration::compacted() const {
return _compacted; return _compacted.load_relaxed();;
} }
void ZGeneration::increase_compacted(size_t size) { void ZGeneration::increase_compacted(size_t size) {
AtomicAccess::add(&_compacted, size, memory_order_relaxed); _compacted.add_then_fetch(size, memory_order_relaxed);
} }
ConcurrentGCTimer* ZGeneration::gc_timer() const { ConcurrentGCTimer* ZGeneration::gc_timer() const {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 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
@ -37,6 +37,7 @@
#include "gc/z/zWeakRootsProcessor.hpp" #include "gc/z/zWeakRootsProcessor.hpp"
#include "gc/z/zWorkers.hpp" #include "gc/z/zWorkers.hpp"
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "runtime/atomic.hpp"
class ThreadClosure; class ThreadClosure;
class ZForwardingTable; class ZForwardingTable;
@ -70,9 +71,9 @@ protected:
ZRelocate _relocate; ZRelocate _relocate;
ZRelocationSet _relocation_set; ZRelocationSet _relocation_set;
volatile size_t _freed; Atomic<size_t> _freed;
volatile size_t _promoted; Atomic<size_t> _promoted;
volatile size_t _compacted; Atomic<size_t> _compacted;
Phase _phase; Phase _phase;
uint32_t _seqnum; uint32_t _seqnum;