[foreign-preview] Integrated: 8278414: Replace binding recipe customization using MH combinators with bytecode spinning
Jorn Vernee
jvernee at openjdk.java.net
Wed Feb 2 12:42:38 UTC 2022
On Mon, 31 Jan 2022 17:55:29 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
> Hi,
>
> This patch removes the binding recipe specialization using MethodHandle combinators in the linker implementation, and replaces it with specialization by spinning a class using the ASM bytecode API.
>
> The main reason for doing this is simplicity of the implementation, as well as finer-grained control over the classes that are generated.
>
> The meat of this PR is in `jdk.internal.foreign.abi.Specializer`, but there are some spin-off changes in this PR as well:
> - MethodHandles are really good at sharing classes, so to get comparable performance, this PR also adds a cache behind CLinker::downcallHandle. Due to this, I've also created an AbstractLinker base class for all linker implementations, which contains the cache as well as other shared code.
> - CallingSequence is used to steer the class generation. I've added some predicates to this class to check whether the CS is for downcall or upcall. As well as splitting the methodType() accessor into callerMethodType() and calleeMethodType(), reflecting the 2 method types in play during generation (one of the 2 was being computed ad-hoc during specialization previously). This is also responsible for most of the test changes. I've added some javadoc to CS which hopefully adequately explains these accessors.
> - I've slightly changed the toString output of ValueLayout to include carrier types as well, in order to be able to use FunctionDescriptor.toString() as a file name in case we want to dump the generated classes to disc. This avoids conflicts between e.g. long and double, which previously were both stringified as b64.
>
> Thanks,
> Jorn
This pull request has now been integrated.
Changeset: 55a7e6c4
Author: Jorn Vernee <jvernee at openjdk.org>
URL: https://git.openjdk.java.net/panama-foreign/commit/55a7e6c4cd65048efb1f6de4a3fed7a1348a73ad
Stats: 1629 lines in 19 files changed: 1110 ins; 410 del; 109 mod
8278414: Replace binding recipe customization using MH combinators with bytecode spinning
Reviewed-by: mcimadamore
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/635
More information about the panama-dev
mailing list