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

Coleen Phillimore coleenp at openjdk.org
Tue Nov 18 13:46:08 UTC 2025


On Mon, 17 Nov 2025 11:59:29 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. 
>> 
>> Additionally, `SpinSingleSection` class is added, which allows to execute a payload code inside of a lambda function by only one thread. 
>> 
>> Tested in tiers 1 - 5.
>
> Anton Artemov has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8366671: Removed redundant include.

I'd rather this be a general purpose synchronization utility that's used with care rather than something buried in thread code that nobody finds and creates one of their own.  That there's only three uses of this is a good thing.  It's preferable to use Mutex.  The commentary that Kim suggested would be very good.

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

PR Comment: https://git.openjdk.org/jdk/pull/28264#issuecomment-3547701344


More information about the hotspot-dev mailing list