8374676: ZGC: Convert zAbort to use Atomic<T>

Reviewed-by: stefank, tschatzl
This commit is contained in:
Axel Boldt-Christmas 2026-01-26 12:16:05 +00:00
parent 0f1b96a50a
commit de5c7a9e86
3 changed files with 8 additions and 10 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -22,10 +22,9 @@
*/
#include "gc/z/zAbort.hpp"
#include "runtime/atomicAccess.hpp"
volatile bool ZAbort::_should_abort = false;
Atomic<bool> ZAbort::_should_abort{};
void ZAbort::abort() {
AtomicAccess::store(&_should_abort, true);
_should_abort.store_relaxed(true);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2023, 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,10 +25,11 @@
#define SHARE_GC_Z_ZABORT_HPP
#include "memory/allStatic.hpp"
#include "runtime/atomic.hpp"
class ZAbort : public AllStatic {
private:
static volatile bool _should_abort;
static Atomic<bool> _should_abort;
public:
static bool should_abort();

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.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,10 +26,8 @@
#include "gc/z/zAbort.hpp"
#include "runtime/atomicAccess.hpp"
inline bool ZAbort::should_abort() {
return AtomicAccess::load(&_should_abort);
return _should_abort.load_relaxed();
}
#endif // SHARE_GC_Z_ZABORT_INLINE_HPP