RFR: 8366671: Refactor Thread::SpinAcquire and Thread::SpinRelease [v4]
Anton Artemov
aartemov at openjdk.org
Mon Nov 17 09:45:17 UTC 2025
On Fri, 14 Nov 2025 18:53:06 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:
>> Anton Artemov has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8366671: Fixed build problem.
>
> src/hotspot/share/runtime/objectMonitor.cpp line 320:
>
>> 318: check_object_context();
>> 319: if (_object_strong.is_empty()) {
>> 320: auto setObjectStrongLambda = [&](OopHandle& object_strong, const WeakHandle& object) {
>
> Doesn't the lambda capture the _object and _object_strong values from the [&] ?
> And maybe instead of a class SpinSingleSection it should be a template function that passes in the lambda?
According to the C++ standard, evaluation of a lambda expression creates a closure object, invoking the closure object executes the lambda expression. The closure object behaves as a functional object, and its call operator, constructor and data members are defined by the lambda expression. The capture type tells how variables are passed into the closure object, and nothing more. Variables are passed when the lambda is executed.
We can of course have a template function instead of a class, but then it somewhat breaks the idea of having the an object representing the critical/single section, where the length of the section is defined by the lifetime of the object.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28264#discussion_r2533384738
More information about the hotspot-dev
mailing list