RFR(S): 8142329: [JVMCI] pass Handle by value

Coleen Phillimore coleen.phillimore at oracle.com
Mon Nov 9 22:21:17 UTC 2015

On 11/9/15 12:07 PM, Carsten Varming wrote:
> Dear Roland,
> Coleen recently changes a bunch of handle values to references (see 
> http://hg.openjdk.java.net/jdk9/hs-rt/hotspot/rev/6ab7e19c9220, 
> https://bugs.openjdk.java.net/browse/JDK-8140274). Perhaps the comment 
> in handles.hpp should be updated to reflect the efficiency goal of 
> Coleen's recent change. Your change has both constantPoolHandles and 
> methodHandles, so it would be nice to not go backwards.


Thank you for alerting me about this change.
> Carsten
> On Mon, Nov 9, 2015 at 11:36 AM, Roland Schatz 
> <roland.schatz at oracle.com <mailto:roland.schatz at oracle.com>> wrote:
>     Hi,
>     In JVMCI we have a few methods using `Handle&` as argument,
>     according to the comment in handle.hpp this should be `Handle`
>     directly.

We have three things with unfortunately similar names:

1. Handle  including instanceHandle, arrayHandle, objArrayHandle and 
typeArrayHandle.   These hold oops.  They don't have anything but a 
trivial constructor and since the only field in these handles is the 
oopDesc pointer, there is no penalty for passing them by value.   By 
convention in the JVM sources, they are passed by value:  ie:   void 
foo(Handle h).

2. metadata Handles including methodHandle and constantPoolHandle. These 
hold metadata.  Their purpose is to keep the metadata from being 
deallocated due to disuse after redefinition.  These handles have copy 
constructors and destructors and are have to call these to pass by 
value.   These values shouldn't be written either.   So you should pass 
these as *const* references.  ie   void foo(const methodHandle& m);

3. instanceKlassHandle and KlassHandle.  These are vestigial but were 
left in the code because they might have been needed for enhanced class 
redefinition.  They have no semantics so can be passed however you want.

In my opinion, none of these things should be passed as *non-const* 
references since they should never be output parameters.

So part of this change is correct to remove the non-const references but 
the Handles should be passed by value and the methodHandles and 
constantPoolHandles should be passed as const references.


>     JIRA:
>     https://bugs.openjdk.java.net/browse/JDK-8142329
>     Webrev:
>     http://cr.openjdk.java.net/~rschatz/JDK-8142329/webrev.00/
>     <http://cr.openjdk.java.net/%7Erschatz/JDK-8142329/webrev.00/>
>     Please review.
>     Thanks,
>     Roland

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20151109/19c66185/attachment.html>

More information about the hotspot-compiler-dev mailing list