RFR(S): 8142329: [JVMCI] pass Handle by value
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
> 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.
> On Mon, Nov 9, 2015 at 11:36 AM, Roland Schatz
> <roland.schatz at oracle.com <mailto:roland.schatz at oracle.com>> wrote:
> In JVMCI we have a few methods using `Handle&` as argument,
> according to the comment in handle.hpp this should be `Handle`
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
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.
> Please review.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the hotspot-compiler-dev