RFR: 8282883: Use JVM_LEAF to avoid ThreadStateTransition for some simple JVM entries

Yi Yang yyang at openjdk.java.net
Thu Mar 10 09:59:42 UTC 2022


On Thu, 10 Mar 2022 04:37:11 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Some existing JVM_ENTRY routines are behavioral simple, they do not lock, GC or throw exceptions, we could use JVM_LEAF instead of JVM_ENTRY, to avoid ThreadStateTransition and safepoint checks.
>
> Hi Yi,
> 
> I agree these all look like they are completely safe to be LEAF functions.
> 
> Thanks,
> David

> I am a bit concerned about `JVM_Yield`, though. AFAICS, `JVM_LEAF` should not run for too long, because that would interfere with safepointing, and yielding the thread does look like an invitation to de-schedule the thread for unknown amount of time. @dholmes-ora -- you looked at it, have you figured this is okay?

As I understand, JVM_LEAF could run long time, for operations that simply enought/taking long time but safe enough, we don't need to check safepoint(and further block itself), we could use JVM_LEAF, these entries work as if they are part of native code, no matter how long they take time to execute. Otherwise, we need JVM_ENTRY to check safepoint and block itself if sfpt requested.
https://github.com/openjdk/jdk/blob/6a3a7b94a4c342ce12ad553f1ba2818ca3a77f36/src/hotspot/share/prims/unsafe.cpp#L393-L411

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

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


More information about the hotspot-runtime-dev mailing list