RFR: 8307149: MethodHandles.arrayConstructor can be cached
Chen Liang
liach at openjdk.org
Fri Jun 30 05:16:10 UTC 2023
On Thu, 4 May 2023 23:29:17 GMT, Chen Liang <liach at openjdk.org> wrote:
> This patch migrates `MethodHandles::arrayConstructor`, added in Java 9 as a hotfix to the incorrect constructor found on arrays via Lookup, to share the array access caching features. The result is that calling `MethodHandles.arrayConstructor` to create method handles is much faster.
>
> Oracle JDK 20:
>
> Benchmark Mode Cnt Score Error Units
> MethodHandlesArrayConstructor.createWithAnewarray avgt 15 2.739 ± 0.058 ns/op
> MethodHandlesArrayConstructor.createWithMethodHandle avgt 15 3.313 ± 0.041 ns/op
> MethodHandlesArrayConstructor.methodHandleCreation avgt 15 61.874 ± 0.397 ns/op
>
>
> This patch:
>
> Benchmark Mode Cnt Score Error Units
> MethodHandlesArrayConstructor.createWithAnewarray avgt 15 3.067 ± 0.026 ns/op
> MethodHandlesArrayConstructor.createWithMethodHandle avgt 15 3.699 ± 0.042 ns/op
> MethodHandlesArrayConstructor.methodHandleCreation avgt 15 1.447 ± 0.004 ns/op
keep-alive.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13819#issuecomment-1614138348
More information about the core-libs-dev
mailing list