RFR: 8366671: Refactor Thread::SpinAcquire and Thread::SpinRelease [v12]
David Holmes
dholmes at openjdk.org
Thu Dec 4 19:40:02 UTC 2025
On Wed, 3 Dec 2025 14:04:28 GMT, Anton Artemov <aartemov at openjdk.org> wrote:
>> Hi,
>>
>> please consider the following changes:
>>
>> In this PR `Thread::SpinAcquire()` and `Thread::SpinRelease()` methods are refactored into a utility class `SpinCriticalSection`. The motivation is to make it easier for developers to use this lightweight synchronization mechanism in the codebase. The two aforementioned methods were used in JFR to create short critical sections with a helper class, but that was not the case for the object monitor code.
>>
>> Tested in tiers 1 - 5.
>
> Anton Artemov has updated the pull request incrementally with one additional commit since the last revision:
>
> 8366671: Added NoSafepointVerifier
src/hotspot/share/utilities/spinCriticalSection.hpp line 54:
> 52: SpinCriticalSection(volatile int* lock)
> 53: : _lock(lock)
> 54: DEBUG_ONLY(COMMA _nsv(Thread::current_or_null_safe() != nullptr)) {
So we need to allow for null because this can be called early in VM init whilst the main thread is still attaching, but why do we need the "safe" variant? That is only for code that can be executed in a signal handling context
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28264#discussion_r2590332917
More information about the hotspot-dev
mailing list