RFR: 8244550: Unsafe::allocateInstance does redundant transitions

Claes Redestad claes.redestad at oracle.com
Wed May 6 23:48:30 UTC 2020


On 2020-05-07 01:40, Mandy Chung wrote:
> 
> 
> On 5/6/20 4:09 PM, Claes Redestad wrote:
>> 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/
> 
> Looks good.

Thanks, Mandy!

> 
> Nit: variable `ih` typically means handle.  This could simply be `i`.

This followed over from existing code in jni.cpp. I can change it.

/Claes

> 
> 358 instanceOop ih = 
> InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(cls), 
> CHECK_NULL); Mandy
> 
> 


More information about the hotspot-runtime-dev mailing list