11/*
2- * Copyright (c) 1997, 2025 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 1997, 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
2828#include " logging/log.hpp"
2929#include " memory/resourceArea.hpp"
3030#include " memory/universe.hpp"
31- #include " runtime/atomicAccess .hpp"
31+ #include " runtime/atomic .hpp"
3232#include " runtime/interfaceSupport.inline.hpp"
3333#include " runtime/javaThread.inline.hpp"
3434#include " runtime/safepoint.hpp"
@@ -60,16 +60,13 @@ class GCLockerTimingDebugLogger : public StackObj {
6060};
6161
6262Monitor* GCLocker::_lock;
63- volatile bool GCLocker::_is_gc_request_pending;
63+ Atomic< bool > GCLocker::_is_gc_request_pending{ false } ;
6464
65- DEBUG_ONLY (uint64_t GCLocker::_verify_in_cr_count;)
65+ DEBUG_ONLY (Atomic< uint64_t > GCLocker::_verify_in_cr_count{ 0 } ;)
6666
6767void GCLocker::initialize() {
6868 assert (JNICritical_lock != nullptr , " inv" );
6969 _lock = JNICritical_lock;
70- _is_gc_request_pending = false ;
71-
72- DEBUG_ONLY (_verify_in_cr_count = 0 ;)
7370}
7471
7572bool GCLocker::is_active () {
@@ -84,11 +81,11 @@ bool GCLocker::is_active() {
8481void GCLocker::block () {
8582 // _lock is held from the beginning of block() to the end of of unblock().
8683 _lock->lock ();
87- assert (AtomicAccess::load (& _is_gc_request_pending) == false , " precondition" );
84+ assert (_is_gc_request_pending. load_relaxed ( ) == false , " precondition" );
8885
8986 GCLockerTimingDebugLogger logger (" Thread blocked to start GC." );
9087
91- AtomicAccess::store (& _is_gc_request_pending, true );
88+ _is_gc_request_pending. store_relaxed ( true );
9289
9390 // The _is_gc_request_pending and _jni_active_critical (inside
9491 // in_critical_atomic()) variables form a Dekker duality. On the GC side, the
@@ -112,14 +109,14 @@ void GCLocker::block() {
112109#ifdef ASSERT
113110 // Matching the storestore in GCLocker::exit.
114111 OrderAccess::loadload ();
115- assert (AtomicAccess::load (& _verify_in_cr_count) == 0 , " inv" );
112+ assert (_verify_in_cr_count. load_relaxed ( ) == 0 , " inv" );
116113#endif
117114}
118115
119116void GCLocker::unblock () {
120- assert (AtomicAccess::load (& _is_gc_request_pending) == true , " precondition" );
117+ assert (_is_gc_request_pending. load_relaxed ( ) == true , " precondition" );
121118
122- AtomicAccess::store (& _is_gc_request_pending, false );
119+ _is_gc_request_pending. store_relaxed ( false );
123120 _lock->unlock ();
124121}
125122
@@ -139,7 +136,7 @@ void GCLocker::enter_slow(JavaThread* current_thread) {
139136 // Same as fast path.
140137 OrderAccess::fence ();
141138
142- if (!AtomicAccess::load (& _is_gc_request_pending)) {
139+ if (!_is_gc_request_pending. load_relaxed ( )) {
143140 return ;
144141 }
145142
0 commit comments