[foreign-memaccess+abi] RFR: 8274912: Eagerly generate native invokers
Jorn Vernee
jvernee at openjdk.java.net
Thu Oct 7 14:43:47 UTC 2021
On Thu, 7 Oct 2021 14:29:47 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
> Hi,
>
> This patch is a refactoring of VM code pertaining to downcalls. As outlined in the JBS issue, this patch makes 'native invoker' generation currently done by C2 eager.
>
> Most of the changes in this patch are moving around existing code:
> - The native invoker generation code is moved from sharedRuntime*.cpp to universalNativeInvoker*.cpp, to match what is done for upcalls.
> - C2 & nmethod scaffolding for registering native invokers has been removed (lifetime is now managed in Java code).
> - Now, C2 will only intrinsify trivial downcalls, which means some of the code was simplified there.
> - To reduce code duplication, several utilities have been added:
> - ArgumentShuffle (and impls of CallConvClosure): a utility class for computing argument shuffles and generating shuffling code. The shuffling code is heavily based on what is done today for optimized upcalls on x64.
> - To support the above, I've made a copy of the ComputeMoveOrder utility from SharedRuntime code (which was only implemented on x64), and adapted it to our use case.
> - RegSpillFill: similarly, a utility for computing and generating register spill and fill code (given a list of registers).
> - oop_cast: this was a pre-existing utility that was renamed (from 'cast') and moved into a separate file.
> - The linkToNative method handle intrinsic now just loads the invoker address from the appendix argument and jumps to it, instead of jumping to the fallback method handle.
>
> The implementation passes all the jdk_foreign tests on Windows/x64, Linux/x64 (WSL), and Linux/AArch64. Though, there were some pre-exsiting test failures on AArch64 wrt variadic functions.
>
> Thanks,
> Jorn
src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp line 5349:
> 5347: ShouldNotReachHere();
> 5348: }
> 5349: }
Similar to what was done for x64, I've moved the aarch64 shuffling helpers to macroassembler
src/hotspot/cpu/x86/macroAssembler_x86.cpp line 947:
> 945: } else if (dst.is_single_phys_reg()) {
> 946: assert(src.is_single_reg(), "not a stack pair");
> 947: movq(dst.first()->as_Register(), Address(rbp, reg2offset_in(src.first())));
A pre-existing bug found when testing (same below). Loads from `rbp` should always be paired with `reg2offset_in`
test/jdk/java/foreign/TestUpcall.java line 48:
> 46: * TestUpcall
> 47: */
> 48:
It seems that not all the upcall test configurations were being run, so I've added them back here. (these are separate jtreg tests, so shouldn't run into any problems with timeouts).
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/593
More information about the panama-dev
mailing list