RFR: 8366671: Refactor Thread::SpinAcquire and Thread::SpinRelease [v8]
Kim Barrett
kbarrett at openjdk.org
Thu Nov 20 20:09:40 UTC 2025
On Thu, 20 Nov 2025 10:37:21 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: Addressed reviewers' comments.
A couple very minor nits, but I don't object as-is.
src/hotspot/share/runtime/objectMonitor.cpp line 2040:
> 2038: bool ObjectMonitor::notify_internal(JavaThread* current) {
> 2039: bool did_notify = false;
> 2040: {
I don't think this extra level of block scope is needed. The only thing outside the end of this
extra scope is the `return did_notify`, which could just as well be inside. Your call...
src/hotspot/share/utilities/spinCriticalSection.hpp line 43:
> 41:
> 42: // Low-level leaf-lock primitives used to implement synchronization.
> 43: // Not for general synchronization use.
This comment seems like it contains info that ought to be part of the class description, rather
than on an implementation detail.
-------------
Marked as reviewed by kbarrett (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/28264#pullrequestreview-3489707063
PR Review Comment: https://git.openjdk.org/jdk/pull/28264#discussion_r2547502382
PR Review Comment: https://git.openjdk.org/jdk/pull/28264#discussion_r2547512683
More information about the hotspot-dev
mailing list