[master] RFR: Add some inlining and avoid CAS for quick_enter for lightweight locking.
Coleen Phillimore
coleenp at openjdk.org
Tue Jul 2 14:24:34 UTC 2024
On Tue, 2 Jul 2024 06:59:21 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:
>> This is sort of a simple change to inline the code that decides to go to LightweightSynchronizer in case the call has some negative effects for performance sensitive code. Avoiding the CAS in try_enter was the most helpful. With perf, I found that the CAS had a longer stall than with the code without the OM world refactoring. The OM world table is off for this comparison.
>> Tested with tier1-4, including some local changes to run tier1 tests with -XX:+UseObjectMonitorTable.
>
> src/hotspot/share/runtime/lightweightSynchronizer.cpp line 578:
>
>> 576: };
>> 577:
>> 578: inline bool LightweightSynchronizer::check_unlocked(oop obj, LockStack& lock_stack, JavaThread* current) {
>
> This could be called something like `fast_lock_try_enter` or `fast_lock_enter`. Or even `enter_fast_lock` (similar name to what is in synchronizer.cpp).
>
> I think I like `fast_lock_try_enter` or `fast_lock_enter` the best.
I like fast_lock_try_enter - that looks good in the code and describes the situation.
> src/hotspot/share/runtime/objectMonitor.cpp line 385:
>
>> 383:
>> 384: bool ObjectMonitor::try_enter(JavaThread* current) {
>> 385: if (LockingMode == LM_LIGHTWEIGHT) {
>
> Could probably just do this for all LockingModes.
Yes, you convinced me that reading the owner for legacy mode doesn't need to be done as the return from the CAS because it can change anyway. If the owner is the stack lock, which the code is testing for, it will never change here so it's ok to read it again.
-------------
PR Review Comment: https://git.openjdk.org/lilliput/pull/187#discussion_r1662628264
PR Review Comment: https://git.openjdk.org/lilliput/pull/187#discussion_r1662629707
More information about the lilliput-dev
mailing list