[Nestmates] RFR (S): 8197915: [Nestmates] Implement receiver typecheck for private invokeinterface use

David Holmes david.holmes at oracle.com
Thu May 3 10:21:15 UTC 2018


bug id: https://bugs.openjdk.java.net/browse/JDK-8197915
webrev: http://cr.openjdk.java.net/~dholmes/8197915/webrev/

JDK-8174962 implemented receiver typechecks for invokeinterface within 
the interpreter (templateTable), compilers and for MethodHandles. In 
nestmates invokeinterface can now be used for private interface methods 
- which result in direct calls. So we need to extend the receiver 
subtype checks to cover the new cases.

Summary of changes:

- src/hotspot/cpu/<cpu>/templateTable_<cpu>.cpp

In the templateTable the 8174962 checks come after the private interface 
method invocation logic ("vfinal") we already had in place for the 
nestmate changes, and they rely on itable information that doesn't exist 
for private methods. So we insert a direct subtype check.

I've provided code for all CPU's but only x86 and sparc have been 
tested. I'll be soliciting aid on the other ports before nestmates goes 
to mainline later this month.

-  src/hotspot/share/oops/cpCache.cpp

We have to pass the interface klass* so it's available for the typecheck.

-  src/hotspot/share/oops/klassVtable.cpp

Updated a comment that's no longer accurate.

- src/hotspot/share/opto/doCall.cpp

This code was provided by Vladimir Ivanov (thank you!) and expands the 
existing "invokespecial" support for receiver typechecks in C2, to 
"invokeinterface" as well.

Aside: no changes were needed for C1. It's seems all the receiver 
typechecks for C1 are being handled at a higher level (through 
linkResolver and/or cpCache logic).

- src/hotspot/share/prims/methodHandles.cpp

Comment clarifying JVM_REF_invokeSpecial doesn't necessarily mean it 
relates to an actual "invokespecial" - it is used for all direct calls.

- src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java

Add clarifying comments regarding how "kind" can vary if a direct call 
is involved.

Expand the condition to switch from LF_INVSPECIAL to LF_INVSPECIAL_IFC 
(which adds the additional receiver typecheck) to account for the 
invokeinterface case.

-  test/jdk/java/lang/invoke/PrivateInterfaceCall.java

New test for invokeinterface semantics that mirrors the existing 
SpecialInterfaceCall test for invokespecial.

This is the last of the significant functional changes for nestmates.

Thanks,
David



More information about the valhalla-dev mailing list