[foreign-memaccess+abi] RFR: 8258516: Allow passing a target address as an argument to a native MethodHandle
Vladimir Ivanov
vlivanov at openjdk.java.net
Fri Jan 29 16:25:51 UTC 2021
On Mon, 11 Jan 2021 20:35:09 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
> 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
Looks good.
-------------
Marked as reviewed by vlivanov (Committer).
PR: https://git.openjdk.java.net/panama-foreign/pull/433
More information about the panama-dev
mailing list