On Fri, 25 Oct 2024 18:46:52 GMT, Patricio Chilano Mateo 
<pchilanom...@openjdk.org> wrote:

>> src/hotspot/share/runtime/objectMonitor.cpp line 2028:
>> 
>>> 2026:   // First time we run after being preempted on Object.wait().
>>> 2027:   // Check if we were interrupted or the wait timed-out, and in
>>> 2028:   // that case remove ourselves from the _WaitSet queue.
>> 
>> I'm not sure how to interpret this comment block - is this really two 
>> sentences because the first is not actually a sentence. Also unclear what 
>> "run" and "First time" relate to.
>
> This vthread was unmounted on the call to `Object.wait`. Now it is mounted 
> and "running" again, and we need to check which case it is in: notified, 
> interrupted or timed-out. "First time" means it is the first time it's 
> running after the original unmount on `Object.wait`. This is because once we 
> are on the monitor reentry phase, the virtual thread can be potentially 
> unmounted and mounted many times until it successfully acquires the monitor. 
> Not sure how to rewrite the comment to make it clearer.

The first sentence is not a sentence. Is it supposed to be saying:

// The first time we run after being preempted on Object.wait()
// we check if we were interrupted or the wait timed-out ...

?

>> src/hotspot/share/runtime/synchronizer.cpp line 670:
>> 
>>> 668:   // Top native frames in the stack will not be seen if we attempt
>>> 669:   // preemption, since we start walking from the last Java anchor.
>>> 670:   NoPreemptMark npm(current);
>> 
>> Don't we still pin for JNI monitor usage?
>
> Only when facing contention on this call. But once we have the monitor we 
> don't.

But if this is from JNI then we have at least one native frame on the stack 
making the JNI call, so we have to be pinned if we were to block on the 
monitor. ???

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21565#discussion_r1818239594
PR Review Comment: https://git.openjdk.org/jdk/pull/21565#discussion_r1818240013

Reply via email to