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

Daniel D. Daugherty dcubed at openjdk.org
Thu Mar 9 18:54:49 UTC 2023


On Mon, 30 Jan 2023 14:30:41 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

>> 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.

Okay, I get it. `is_lock_owned()` only return `true` when called by a
JavaThread and if that JavaThread owns the monitor.

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

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


More information about the serviceability-dev mailing list