RFR: 8352565: Add native method implementation of Reference.get()
Chen Liang
liach at openjdk.org
Tue Apr 1 01:59:21 UTC 2025
On Sat, 29 Mar 2025 21:47:18 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
> Please review this change which adds a native method providing the
> implementation of Reference::get. Referece::get is an intrinsic candidate, so
> this native method implementation is only used when the intrinsic is not.
>
> Currently there is intrinsic support by the interpreter, C1, C2, and graal,
> which are always used. With this change we can later remove all the
> per-platform interpreter intrinsic implementations, and might also remove the
> C1 intrinsic implementation.
>
> Testing:
> (1) mach5 tier1-6 normal (so using all the existing intrinsics).
> (2) mach5 tier1-6 with interpreter and C1 Reference::get intrinsics disabled.
src/java.base/share/classes/java/lang/ref/Reference.java line 365:
> 363: * C2 to sometimes prefer the native implementation over the intrinsic.
> 364: */
> 365: private native Object get0();
I think you can declare this as `private native T get0();` without changes to native method signatures, so you can avoid the unchecked cast above. (See Class::getPrimitiveClass declaration)
Also, can C2 choose to use native over intrinsic? That is concerning from a performance POV, as I think there are a few such performance sensitive methods in core libraries.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24315#discussion_r2022010819
More information about the hotspot-dev
mailing list