RFR: 8160821: VarHandle accesses are penalized when argument conversion is required [v6]

Vladimir Ivanov vlivanov at openjdk.org
Wed Dec 3 19:39:56 UTC 2025


On Wed, 3 Dec 2025 16:43:24 GMT, Chen Liang <liach at openjdk.org> wrote:

>> Since access descriptor is created for each VH operation site, we can optimistically cache the adapted method handle in a site if the site operates on a constant VH.  Used a C2 IR test to verify such a setup through an inexact VarHandle invocation can be constant folded through (previously, it was blocked by `asType`)
>
> Chen Liang has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Test from Jorn
>  - Copyright years

src/java.base/share/classes/java/lang/invoke/VarHandle.java line 2036:

> 2034:         // from two writes (they must not be tearable)
> 2035:         private record Adaption(VarHandle vh, MethodHandle mh) {}
> 2036:         private @Stable Adaption adaption;

Is a soft reference needed here? The situation looks similar to `MH.asTypeSoftCache`. It can keep some classes referred by `vh` alive for unnecessarily long.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28585#discussion_r2586374014


More information about the hotspot-compiler-dev mailing list