[foreign-memaccess+abi] RFR: 8258516: Allow passing a target address as an argument to a native MethodHandle

Jorn Vernee jvernee at openjdk.java.net
Mon Jan 11 20:39:42 UTC 2021


Hi,

This patch adds the ability to CLinker to link a method handle that takes the address to the target function separately as a leading argument, instead of having to supply it during linking.

This will avoid the need to re-link method handles for 'virtual' call sites, where the type of the call is always the same, but the address of the target function can differ.

I've updated the C2 code to intrinsify the current case when the address argument is a constant, but there is still more work to be done to add intrinsification of virtual calls. Though, not having to re-link a method handle on every call should already speed things up significantly.

There are other possible enhancements imaginable as well, such as caching linked method handles inside the linker, and re-using them with different addresses (but that is for a later patch).

I added a benchmark similar to CallOverhead that measures the virtual variants. Some refactoring has been done there to put shared code in a helper class, and the old benchmark has been renamed to CallOverheadConstant so it's possible to select either class to run independently of the other with JMH. I've also added several more variants that test different numbers of arguments.

I added a TestVirtualCalls test as a smoke test for simple virtual calls, and updated (as well as simplified a little) TestIntrinsics to make sure nothing crashes in the C2 code when encountering a virtual call.

Thanks,
Jorn

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

Commit messages:
 - Remove unneeded imports
 - Update copyright header part 2
 - Fix assert crash
 - Add tests
 - Fix copyrights
 - Cleanups + javadoc
 - Add virtual call benchmarks
 - Allow passing address of target separately to downcall handles

Changes: https://git.openjdk.java.net/panama-foreign/pull/433/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=433&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8258516
  Stats: 960 lines in 29 files changed: 623 ins; 234 del; 103 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/433.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/433/head:pull/433

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


More information about the panama-dev mailing list