On Sat, 14 Oct 2023 18:07:45 GMT, Alan Bateman <al...@openjdk.org> wrote:

> JVMTI is notified after a virtual thread unmounts. Right not, this 
> notification is done after the virtual thread has finished parking or 
> yielding so it's possible for the virtual to continue, and be mounted on a 
> different carrier, before the unmount notification has completed on the 
> original carrier. If this happens it means the the JVMTI mount and unmount 
> notifications will race and it's possible they could be unbalanced. The 
> unmount notification needs to move to after the unmount and before the 
> virtual thread state is changed.
> 
> While in the area, I've removed @ChangesCurrentThread from VirtualThread.run. 
> This annotation was in place to workaround an issue with the notifyJvmtiXXX 
> instrinsics, fixed recently by JDK-8316130.
> 
> Testing: tier1-6.

Looks good. It is more elegant now.
I was thinking if it'd make sense to move:
 - `notifyJvmtiMount(/*hide*/true);` at start of `mount()`
 -  `notifyJvmtiUnmount(/*hide*/false);` at end of unmount()
but I guess you wanted to have them at the `runContinuation()` level.

Thanks,
Serguei

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

Marked as reviewed by sspitsyn (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/16194#pullrequestreview-1686379670

Reply via email to