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

ExE Boss duke at openjdk.org
Mon Dec 8 08:15:00 UTC 2025


On Mon, 8 Dec 2025 02:08:37 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 with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 15 additional commits since the last revision:
> 
>  - Bugs and verify loader leak
>  - Try to avoid loader leak
>  - Merge branch 'master' of https://github.com/openjdk/jdk into fix/vh-adapt-cache
>  - Revert void special case removal due to C2 shortage causing TestZGCBarrierElision::testAtomicThenAtomicAnotherField failure
>  - Test from Jorn
>  - Copyright years
>  - Fix problem identified by Jorn
>  - Rollback getAndAdd for now
>  - Redundant change
>  - Merge branch 'master' of https://github.com/openjdk/jdk into fix/vh-adapt-cache
>  - ... and 5 more: https://git.openjdk.org/jdk/compare/17ebc456...eebb8ff7

make/jdk/src/classes/build/tools/methodhandle/VarHandleGuardMethodGenerator.java line 145:

> 143:                             MethodHandle.linkToStatic(<LINK_TO_STATIC_ARGS>);
> 144:                         } else {
> 145:                             <RETURN>ad.adaptedMethodHandle(handle).invokeBasic(<LINK_TO_INVOKER_ARGS>);

The old version didn’t use `<RETURN>` in `GUARD_METHOD_TEMPLATE_V`:
Suggestion:

                            ad.adaptedMethodHandle(handle).invokeBasic(<LINK_TO_INVOKER_ARGS>);

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

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


More information about the hotspot-compiler-dev mailing list