RFR: 8187221 [Nestmates] Virtual invocation for private interface methods

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Sep 5 13:20:09 UTC 2017


Langtools change looks good, VM changes also make sense. One question - 
I wonder why the old code assumed that link_info.current_klass() could 
be null? I see that your new code expects that not to be the case 
(otherwise the code would crash), and that's probably a consequence of 
the fact that you're using InstanceKlass::cast which I see asserts that 
value passed in is not NULL. So does it mean that this value cannot ever 
be NULL and that the old code was 'bogus' ?

Maurizio


On 05/09/17 13:34, David Holmes wrote:
> webrev: http://cr.openjdk.java.net/~dholmes/8187221/
>
> Following up from JDK-8186763 this issue handles item #2:
>
> 2. Use invokeinterface for private interface method invocations, 
> instead of invokespecial
>
> This involves three basic pieces:
>
> 1. javac issues invokeinterface instead of invokespecial
> 2. Verifier rules requiring invokespecial are relaxed for latest class 
> file version (exact version TBD based on release timing)
> 3. Method resolution locates the expected method.
>
> As part of this change I'm also isolating the changes that allowed 
> invokespecial to be used for nestmate method invocations. In the near 
> future that code will be removed so that we are near final-form.
>
> Actual file changes are very simple in the end:
>
> src/share/vm/classfile/verifier.cpp
>
> Restore original (pre-nestmate) logic for invokespecial and add in the 
> nestmate-enabling logic under the UseNewCode guard.
>
> ---
>
> src/share/vm/interpreter/linkResolver.cpp
>
> LinkResolver::resolve_interface_method: Only prohibit invokeinterface 
> for private interface methods if : 
> InstanceKlass::cast(current_klass)->major_version() < 
> VIRTUAL_PRIVATE_ACCESS_VERSION
>
> LinkResolver::runtime_resolve_interface_method: Don't resolve in the 
> receiver class if dealing with a private interface method
>
> ---
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java
>
> Removed the check for interface methods when generating virtual calls.
>
> ---
>
> With these changes in place the following test options will test the 
> use of invokevirtual and invokeinterface for private method invocations:
>
> -javacoption:-XDdisablePrivateAccessors 
> -javacoption:-XDvirtualizePrivateAccess
>
> If you still want to experiment with the invokespecial changes use:
>
> -javacoption:-XDdisablePrivateAccessors -javaoption:-XX:+UseNewCode
>
> (note the second one is a java option not javac)
>
> Next iteration I plan on removing the invokespecial related changes.
>
> ---
>
> Testing so far:
>  - all runtime jtreg tests
>  - langtools jtreg tests
>
> Cheers,
> David
> -----



More information about the valhalla-dev mailing list