RFR: 8200238: Reduce number of exceptions created when calling MemberName$Factory::resolveOrNull

Claes Redestad claes.redestad at oracle.com
Mon Mar 26 12:08:06 UTC 2018


MethodHandleNatives::resolve are used by both 
MemberName$Factory::resolveOrFail and ::resolveOrNull, the latter 
allowing speculative lookup of methods.

While the linkResolver code this calls into in the VM will create and 
throw exceptions for all cases where a method or field is missing, these 
are caught by MethodHandles::resolve_MemberName and an empty handle is 
returned instead. However, the outer method, MHN_resolve_Mem will always 
create a new exception and throw it.

In case of resolveOrNull, we'll then ignore whatever exception is thrown 
in the java code, so in effect we're creating and ignoring two 
exceptions on a failed lookup.

We can cut this in half by passing a boolean to 
MethodHandleNatives::resolve to indicate whether we're doing a 
speculative lookup (resolveOrNull) or not (resolveOrFail):

Bug: https://bugs.openjdk.java.net/browse/JDK-8200238

Webrev: http://cr.openjdk.java.net/~redestad/8200238/open.00/

This is a small startup optimization for applications that have a high 
miss rate (looks up a lot of methods that doesn't exist in the 
pre-generated Holders).



More information about the core-libs-dev mailing list