8378845: Add NoSafepointVerifier to CriticalSection classes

Reviewed-by: dholmes, iwalulya
This commit is contained in:
Thomas Schatzl 2026-03-03 13:26:20 +00:00
parent 7dc97af89f
commit 6cf8b2ea2f
2 changed files with 9 additions and 3 deletions

View File

@ -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))
{}

View File

@ -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())
{}