RFR: 8160821: VarHandle accesses are penalized when argument conversion is required [v3]
Chen Liang
liach at openjdk.org
Tue Dec 2 22:06:49 UTC 2025
On Tue, 2 Dec 2025 20:18:19 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:
>> Chen Liang has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Tweak VH usage in some classes
>
> src/java.base/share/classes/java/lang/invoke/VarHandle.java line 2042:
>
>> 2040: // This is still a hot path if vh is not constant - in this case,
>> 2041: // asType is the bottleneck for constant folding, unfortunately
>> 2042: var result = vh.getMethodHandle(mode).asType(symbolicMethodTypeInvoker);
>
> `mode` and `symbolicMethodTypeInvoker` are part of `AccessDescriptor` while `vh` comes as an argument. What guarantees that a cached adapter is compatible with `vh` observed during subsequent calls? It means that `vh` shape stays exactly the same shape. Is it correct? Would be good to have it validated with asserts.
I am assuming that the previous `vh` observed is compatible with future ones if compiler can fold the `vh` into a constant. If it is not, we can drop the updates to the cache field in the C2 compiled slow code.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28585#discussion_r2582922472
More information about the hotspot-dev
mailing list