On Mon, 17 May 2021 01:36:05 GMT, David Holmes <dhol...@openjdk.org> wrote:

>> src/hotspot/share/prims/jvmtiRawMonitor.cpp line 386:
>> 
>>> 384:     _waiters++;
>>> 385:     ret = simple_wait(self, millis);
>>> 386:     _waiters--;
>> 
>> We don't own the monitor yet so you cannot modify `_waiters` here.
>> Any reason you moved and duplicated this block?
>
> Good catch! Even if the block wasn't moved we still no longer own the monitor 
> after simple_wait.
> 
> This is going to be tricky to fix in a clear/clean way as the waiters count 
> has to be maintained properly.

Actually the field is unused.
The _entry_list is the list of waiters, which is the only thing we really care 
about.
If there was a reader of _waiter reading it without lock can only be used as 
some kind of hint.
If you have lock you can just check _entry_list.

I duplicated it because otherwise I would need two branchse on if 
(self->is_Java_thread()) which creates more complicated code.

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

PR: https://git.openjdk.java.net/jdk/pull/3875

Reply via email to