[foreign-abi] RFR: 8248331: Intrinsify downcall handles in C2 [v3]

Jorn Vernee jvernee at openjdk.java.net
Wed Jul 1 13:30:49 UTC 2020


> 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

Jorn Vernee has updated the pull request incrementally with three additional commits since the last revision:

 - Remove leftover comment
 - Conservatively spill the largest supported vector register size.
 - Move spill_register/fill_register to NativeInvokerGenerator

-------------

Changes:
  - all: https://git.openjdk.java.net/panama-foreign/pull/219/files
  - new: https://git.openjdk.java.net/panama-foreign/pull/219/files/62a26b2e..3daf69c2

Webrevs:
 - full: https://webrevs.openjdk.java.net/panama-foreign/219/webrev.02
 - incr: https://webrevs.openjdk.java.net/panama-foreign/219/webrev.01-02

  Stats: 75 lines in 4 files changed: 42 ins; 29 del; 4 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/219.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/219/head:pull/219

PR: https://git.openjdk.java.net/panama-foreign/pull/219


More information about the panama-dev mailing list