RFR (S): 8033666: Make sure @ForceInline is everywhere it needs to be in sun.misc and java.lang.invoke

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Wed Feb 26 00:16:04 UTC 2014


ValueConversions::castReference was introduced to workaround a problem 
with unreliable inlining of Class::cast method. Unfortunately, since 
ValueConversions class is located in sun.invoke.util, 
@java.lang.invoke.ForceInline annotation isn't visible to it.

A proper fix would be to teach Hotspot to treat Class::cast specifically 
and always inline it, but it requires extensive exploration of 
performance implications. Filed 8035809 [1] to track that.

As an interim fix, I moved castReference method into 
java.lang.invoke.MethodHandleImpl class and added new entry point 
ValueConversions::cast which accepts a method handle to a method which 
should be used for casting.

Testing: manual (looked through -XX:+PrintInlining output to ensure 
MHI::castReference is inlined), jdk/java/lang/invoke, octane.


Best regards,
Vladimir Ivanov

[1] 8035809: Improve inlining of Class::cast method

More information about the core-libs-dev mailing list