RFR: 8350607: Consolidate MethodHandles::zero into MethodHandles::constant [v2]
Claes Redestad
redestad at openjdk.org
Tue Feb 25 21:54:00 UTC 2025
On Mon, 24 Feb 2025 23:45:37 GMT, Chen Liang <liach at openjdk.org> wrote:
>> LF editor spins classes, this avoids the spinning overhead and should speed up non-capturing lambdas too.
>>
>> There may need to be additional intrinsic work for MH combinator lf bytecode generation.
>
> Chen Liang has updated the pull request incrementally with one additional commit since the last revision:
>
> We no longer load DelegateMH as we no longer rebind
Just got back home. Some comments inline, will need to run some tests and mull this over before approval.
src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java line 2241:
> 2239: var form = constantForm(basicType);
> 2240:
> 2241: if (type.isPrimitive()) {
I think you could simplify this using `Wrapper.forBasicType`; all variants should be able to use `wrapper.convert`
src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 4874:
> 4872: Objects.requireNonNull(type);
> 4873: return type.isPrimitive() ? primitiveZero(Wrapper.forPrimitiveType(type))
> 4874: : MethodHandleImpl.makeConstantReturning(type, null);
Not sure if it's important but the existing impl would cache `zero(Object.class)` while this new impl won't. Behaviorally neutral for any other reference type, though.
-------------
PR Review: https://git.openjdk.org/jdk/pull/23706#pullrequestreview-2642528847
PR Review Comment: https://git.openjdk.org/jdk/pull/23706#discussion_r1970580771
PR Review Comment: https://git.openjdk.org/jdk/pull/23706#discussion_r1970592504
More information about the core-libs-dev
mailing list