From 6cf8b2ea2fb34b2e63a44d74ffe0495669ea5690 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Tue, 3 Mar 2026 13:26:20 +0000 Subject: [PATCH] 8378845: Add NoSafepointVerifier to CriticalSection classes Reviewed-by: dholmes, iwalulya --- src/hotspot/share/utilities/globalCounter.inline.hpp | 7 +++++-- src/hotspot/share/utilities/singleWriterSynchronizer.hpp | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/utilities/globalCounter.inline.hpp b/src/hotspot/share/utilities/globalCounter.inline.hpp index ed37b8a878d..0d05096716a 100644 --- a/src/hotspot/share/utilities/globalCounter.inline.hpp +++ b/src/hotspot/share/utilities/globalCounter.inline.hpp @@ -29,6 +29,7 @@ #include "runtime/atomic.hpp" #include "runtime/javaThread.hpp" +#include "runtime/safepointVerifiers.hpp" inline GlobalCounter::CSContext GlobalCounter::critical_section_begin(Thread *thread) { @@ -53,11 +54,13 @@ GlobalCounter::critical_section_end(Thread *thread, CSContext context) { } class GlobalCounter::CriticalSection { - private: + NoSafepointVerifier _nsv; Thread* _thread; CSContext _context; - public: + +public: inline CriticalSection(Thread* thread) : + _nsv(), _thread(thread), _context(GlobalCounter::critical_section_begin(_thread)) {} diff --git a/src/hotspot/share/utilities/singleWriterSynchronizer.hpp b/src/hotspot/share/utilities/singleWriterSynchronizer.hpp index 450c7e89233..c21c9d4ee5e 100644 --- a/src/hotspot/share/utilities/singleWriterSynchronizer.hpp +++ b/src/hotspot/share/utilities/singleWriterSynchronizer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -27,6 +27,7 @@ #include "memory/allocation.hpp" #include "runtime/atomic.hpp" +#include "runtime/safepointVerifiers.hpp" #include "runtime/semaphore.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" @@ -101,12 +102,14 @@ inline void SingleWriterSynchronizer::exit(uint enter_value) { } class SingleWriterSynchronizer::CriticalSection : public StackObj { + NoSafepointVerifier _nsv; SingleWriterSynchronizer* _synchronizer; uint _enter_value; public: // Enter synchronizer's critical section. explicit CriticalSection(SingleWriterSynchronizer* synchronizer) : + _nsv(), _synchronizer(synchronizer), _enter_value(synchronizer->enter()) {}