[foreign-preview] RFR: 8286306: Upcall wrapper class sharing
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Fri May 6 16:29:21 UTC 2022
On Fri, 6 May 2022 14:50:53 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
> This patch adds upcall wrapper class sharing.
>
> I recently realized that these classes can be shared if they have the same input FunctionDescriptor, but a different target method handle.
>
> This is implemented by generating a wrapper class that takes the target method handles as a leading argument. The target method handle is then inserted into the parameter list using `MethodHandles::insertArguments` to create the final method handle that is returned by the specializer. After MH customization kicks in, the target will be a constant again (so shouldn't affect peak performance).
>
> Doing this doesn't effect peak performance, as verified through the Upcalls benchmark, but does significantly improve linking performance.
>
> Before:
>
> Benchmark Mode Cnt Score Error Units
> LinkUpcall.link_blank avgt 30 69.323 � 2.522 us/op
>
> After:
>
> Benchmark Mode Cnt Score Error Units
> LinkUpcall.link_blank avgt 30 11.787 � 0.744 us/op
Looks solid!
-------------
Marked as reviewed by mcimadamore (Committer).
PR: https://git.openjdk.java.net/panama-foreign/pull/679
More information about the panama-dev
mailing list