RFR: 7903660: Drop layout-inferring varargs invoker + add method handle factory [v3]
Jorn Vernee
jvernee at openjdk.org
Mon Feb 12 16:21:04 UTC 2024
On Mon, 12 Feb 2024 16:17:32 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> This PR removes the layout-inferring variadic invokers that we generate. Instead, users will have to create an instance of the invoker interface first, by specifying the layouts of the variadic args explicitly. This leads to a more WYSIWYG approach, where we don't have to guess what the correct variadic layouts are.
>>
>> Additionally, a `handle` and `descriptor` factory are added to the invoker interface, which can be used to create specialized method handles and function descriptors for the variadic function. The base descriptor and function address are also exposed as fields.
>>
>> Open questions:
>> 1. Should we try and hide these fields (with another private nested class)? And if not, should we expose the function address for regular functions as well?
>> 2. Some layouts are illegal as variadic layouts (e.g. C_FLOAT). The `descriptor` factory currently doesn't reject these. Are we happy with that? On the other hand. Making this factory reject those layouts would be quite some work, and would need to be kept in sync with the linker implementation. This didn't seem worth it, so I've left this.
>>
>> Finally, I've removed the now unused runtime helper code related to inferring variadic layouts.
>
> Jorn Vernee has updated the pull request incrementally with one additional commit since the last revision:
>
> use invoker class
See the latest version. Invoker interface is replaced with an invoker class which caches the spread invoker. Performance is really good with that. A client can grab the specialized method handle from the invoker instance and stash that in a `static final` to get full performance.
Two nits:
1. Maybe we should drop the top-level invoker factory, and just have the factory method in the invoker class itself. This signals that this is really a special case, and a client can't just directly call a variadic function, but needs to specialize first. Auto-complete will still find the invoker class when the name of the symbol is typed.
2. Maybe we should rename `apply` to `invoke`, to match what we do for function pointer classes.
-------------
PR Comment: https://git.openjdk.org/jextract/pull/205#issuecomment-1939058339
More information about the jextract-dev
mailing list