RFR: 8366671: Refactor Thread::SpinAcquire and Thread::SpinRelease [v12]

Anton Artemov aartemov at openjdk.org
Fri Dec 5 09:37:06 UTC 2025


On Thu, 4 Dec 2025 19:36:55 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> 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

Is this safety measure redundant though? I mean we move the code into a utility class, which may, potentially, end up being used in that context. It is not the case now, sure. If we do not allow that, we need document this and use a non-safe `current_or_null()`.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28264#discussion_r2592009754


More information about the hotspot-dev mailing list