11/*
2- * Copyright (c) 2015, 2025 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2015, 2026 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -64,31 +64,31 @@ ZRelocateQueue::ZRelocateQueue()
6464 _needs_attention(0 ) {}
6565
6666bool ZRelocateQueue::needs_attention () const {
67- return AtomicAccess::load (& _needs_attention) != 0 ;
67+ return _needs_attention. load_relaxed ( ) != 0 ;
6868}
6969
7070void ZRelocateQueue::inc_needs_attention () {
71- const int needs_attention = AtomicAccess::add (& _needs_attention, 1 );
71+ const int needs_attention = _needs_attention. add_then_fetch ( 1 );
7272 assert (needs_attention == 1 || needs_attention == 2 , " Invalid state" );
7373}
7474
7575void ZRelocateQueue::dec_needs_attention () {
76- const int needs_attention = AtomicAccess::sub (& _needs_attention, 1 );
76+ const int needs_attention = _needs_attention. sub_then_fetch ( 1 );
7777 assert (needs_attention == 0 || needs_attention == 1 , " Invalid state" );
7878}
7979
8080void ZRelocateQueue::activate (uint nworkers) {
81- _is_active = true ;
81+ _is_active. store_relaxed ( true ) ;
8282 join (nworkers);
8383}
8484
8585void ZRelocateQueue::deactivate () {
86- AtomicAccess::store (& _is_active, false );
86+ _is_active. store_relaxed ( false );
8787 clear ();
8888}
8989
9090bool ZRelocateQueue::is_active () const {
91- return AtomicAccess::load (& _is_active);
91+ return _is_active. load_relaxed ( );
9292}
9393
9494void ZRelocateQueue::join (uint nworkers) {
@@ -453,7 +453,7 @@ static void retire_target_page(ZGeneration* generation, ZPage* page) {
453453class ZRelocateSmallAllocator {
454454private:
455455 ZGeneration* const _generation;
456- volatile size_t _in_place_count;
456+ Atomic< size_t > _in_place_count;
457457
458458public:
459459 ZRelocateSmallAllocator (ZGeneration* generation)
@@ -463,7 +463,7 @@ class ZRelocateSmallAllocator {
463463 ZPage* alloc_and_retire_target_page (ZForwarding* forwarding, ZPage* target) {
464464 ZPage* const page = alloc_page (forwarding);
465465 if (page == nullptr ) {
466- AtomicAccess::inc (& _in_place_count);
466+ _in_place_count. add_then_fetch ( 1u );
467467 }
468468
469469 if (target != nullptr ) {
@@ -493,7 +493,7 @@ class ZRelocateSmallAllocator {
493493 }
494494
495495 size_t in_place_count () const {
496- return _in_place_count;
496+ return _in_place_count. load_relaxed () ;
497497 }
498498};
499499
@@ -503,7 +503,7 @@ class ZRelocateMediumAllocator {
503503 ZConditionLock _lock;
504504 ZRelocationTargets* _shared_targets;
505505 bool _in_place;
506- volatile size_t _in_place_count;
506+ Atomic< size_t > _in_place_count;
507507
508508public:
509509 ZRelocateMediumAllocator (ZGeneration* generation, ZRelocationTargets* shared_targets)
@@ -539,7 +539,7 @@ class ZRelocateMediumAllocator {
539539 ZPage* const to_page = alloc_page (forwarding);
540540 _shared_targets->set (partition_id, to_age, to_page);
541541 if (to_page == nullptr ) {
542- AtomicAccess::inc (& _in_place_count);
542+ _in_place_count. add_then_fetch ( 1u );
543543 _in_place = true ;
544544 }
545545
@@ -579,7 +579,7 @@ class ZRelocateMediumAllocator {
579579 }
580580
581581 size_t in_place_count () const {
582- return _in_place_count;
582+ return _in_place_count. load_relaxed () ;
583583 }
584584};
585585
0 commit comments