RFR: 8291555: Implement alternative fast-locking scheme [v5]

Roman Kennke rkennke at openjdk.org
Mon Jan 30 14:33:35 UTC 2023


On Fri, 27 Jan 2023 20:50:32 GMT, Daniel D. Daugherty <dcubed at openjdk.org> wrote:

>> Roman Kennke has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 86 commits:
>> 
>>  - Merge branch 'master' into JDK-8291556-v2
>>  - Revert UseFastLocking to default to off
>>  - Change log message inflate(locked) -> inflate(has_locker)
>>  - Properly set ZF on anon-check path; avoid some conditional branches
>>  - Use testb when testing for anon owner in fast-path
>>  - Merge branch 'master' into JDK-8291555-v2
>>  - In x86_32 C2 fast_lock(), CAS thread directly, instead of CASing stack-pointer and then storing thread
>>  - x86 part of optimization to check for anon owner
>>  - Optimize the check-for-anon-owner fast-path
>>  - Merge remote-tracking branch 'origin/JDK-8291555-v2' into JDK-8291555-v2
>>  - ... and 76 more: https://git.openjdk.org/jdk/compare/da80e7a4...784b361c
>
> src/hotspot/share/runtime/synchronizer.cpp line 1336:
> 
>> 1334:         // Success! Return inflated monitor.
>> 1335:         if (own) {
>> 1336:           assert(current->is_Java_thread(), "must be: checked in is_lock_owned()");
> 
> `is_lock_owned()` currently does this:
> 
> 
> static bool is_lock_owned(Thread* thread, oop obj) {
>   assert(UseFastLocking, "only call this with fast-locking enabled");
>   return thread->is_Java_thread() ? reinterpret_cast<JavaThread*>(thread)->lock_stack().contains(obj) : false;
> }
> 
> 
> so I would not say "checked in is_locked_owned()" since `is_locked_owned()` does
> not enforce that the caller is a JavaThread.

If it's not a Java thread, `is_lock_owned()` returns `false`, and we wouldn't end up in the `if (own)` branch.

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

PR: https://git.openjdk.org/jdk/pull/10907


More information about the serviceability-dev mailing list