RFR: 8319797: Recursive lightweight locking: Runtime implementation [v3]
Axel Boldt-Christmas
aboldtch at openjdk.org
Mon Nov 13 09:28:58 UTC 2023
On Mon, 13 Nov 2023 01:26:00 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> Axel Boldt-Christmas has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Fix nit
>
> src/hotspot/share/runtime/synchronizer.cpp line 395:
>
>> 393: // Always go into runtime if the lock stack is full.
>> 394: return false;
>> 395: }
>
> It isn't obvious that it is beneficial to check what should be a rare occurrence. Why do this?
All lightweight enters must check if the lock stack is full. Both push and try_recursive_enter have that as a pre condition. All code paths emitted C2, emitted shared code and the runtime does the is full check first.
The reason that quick_enter does this without checking the mark word (for monitor) is that we go into the runtime from the emitted code if the lock stack is full. So we want to enter the runtime to inflate and make room, to not get into scenario where we have to go into the runtime on every monitor enter because we are locking on new objects in a loop with a full lock stack.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16606#discussion_r1390826245
More information about the hotspot-dev
mailing list