[foreign-abi] Integrated: 8248331: Intrinsify downcall handles in C2
Jorn Vernee
jvernee at openjdk.java.net
Wed Jul 1 15:59:04 UTC 2020
On Mon, 29 Jun 2020 11:20:22 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
> Hi,
>
> This patch adds intrinsification of down call handles.
>
> This is done through a new method handle intrinsic called linkToNative. We create a NativeMethodHandle that calls this
> intrinsic, which then replaces the leaf method handle in ProgrammableInvoker::getBoundMethodHandle, basically replacing
> the call to invokeMoves. Before C2 kicks in, this intrinsic will call a fallback method handle that we pass to it. The
> handle that is passed is a handle that points to ProgrammableInvoker::invokeMoves, thus simulating the current
> behaviour. However, when a call to linkToNative is inlined, C2 will instead generate either a direct call to the
> target function, or a call to a wrapper stub (which is generated on demand) that also does the thread state transitions
> needed for long running native functions. Information about ABI, and which registers to use are captured in a so-called
> 'appendix argument' of the type NativeEntryPoint, which is passed as the last argument. This captures all the
> information needed to generate the call in C2 (note that previously in the patch shared in the discussion thread this
> information was split over several classes, but I've condensed the info into just NativeEntryPoint in order to reduce
> the amount of code needed in the vm to be able to access the information). With this, the overhead for downcalls is on
> par or slightly lower than with JNI for calls that need to do thread state transitions, and it is even lower when the
> thread state transitions are omitted (see that *_trivial runs). Benchmark
> Mode Cnt Score Error Units CallOverhead.jni_blank avgt 30 8.461 □ 0.892
> ns/op CallOverhead.jni_identity avgt 30 12.585 □ 0.066 ns/op
> CallOverhead.panama_blank avgt 30 8.562 □ 0.029 ns/op
> CallOverhead.panama_blank_trivial avgt 30 1.372 □ 0.008 ns/op
> CallOverhead.panama_identity avgt 30 11.813 □ 0.073 ns/op
> CallOverhead.panama_identity_trivial avgt 30 6.042 □ 0.024 ns/op Finished running test
> 'micro:CallOverhead' Thanks, Jorn
This pull request has now been integrated.
Changeset: 69e9a61e
Author: Jorn Vernee <jvernee at openjdk.org>
URL: https://git.openjdk.java.net/panama-foreign/commit/69e9a61e
Stats: 1860 lines in 73 files changed: 29 ins; 1752 del; 79 mod
8248331: Intrinsify downcall handles in C2
Reviewed-by: vlivanov
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/219
More information about the panama-dev
mailing list