Obsoleting JavaCritical

Jorn Vernee jorn.vernee at oracle.com
Thu Jul 7 18:22:25 UTC 2022


The Java->native transition is required to let the rest of the VM know 
it doesn't have to wait for this particular thread when waiting for all 
threads to get to a safepoint (global safepoint).

Not doing the state transition means that, when a global safepoint is 
requested, the rest of the VM (including other threads running Java 
code) will block at their respective safepoints until the native call 
returns to Java and reaches a subsequent safepoint of it's own later in 
the code.

If the native call takes a long time to complete, this would be 
detrimental to performance.

The thing that's important to allow for upcalls is setting the "frame 
anchor" which describes the last Java frame, in a thread local. This 
frame anchor is saved as part of the "entry" frame when an upcall 
happens, and is used by stack walking code to "jump" over all the native 
frames in between an upcall and downcall , to continue walking Java 
frames on the other (downcall) side.

Jorn

On 06/07/2022 20:19, Ioannis Tsakpinis wrote:
> Afaik, the Java->native transition is required because an upcall back
> to Java during the JNI downcall would otherwise crash the JVM. Are
> transitions required for any other reason?


More information about the panama-dev mailing list