RFR: 8244550: Unsafe::allocateInstance does redundant transitions

Claes Redestad claes.redestad at oracle.com
Wed May 6 23:09:19 UTC 2020


Hi,

Unsafe::allocateInstance transitions from VM to native only to call
jni_AllocObject, transitioning back into VM.

This contributes measurably to overhead when run in interpreter and C1,
so improving this helps startup/warmup. (C2 replaces with an intrinsic.)

Patch moves code to allocate instance into InstanceKlass, so that it
can be shared between jni.cpp and unsafe.cpp, and changes to the unsafe
call doesn't go via jni_AllocObject.

Patch: http://cr.openjdk.java.net/~redestad/8244550/open.00/
Bug:   https://bugs.openjdk.java.net/browse/JDK-8244550

Testing: tier1-3, reduces U::allocateInstance overhead per call from
~100ns to ~60ns

Thanks!

/Claes


More information about the hotspot-runtime-dev mailing list