RFR: 7903660: Drop layout-inferring varargs invoker + add method handle factory [v4]

Jorn Vernee jvernee at openjdk.org
Mon Feb 12 17:50:23 UTC 2024


On Mon, 12 Feb 2024 17:09:27 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:
> 
>   add missing 'the' in javadoc

I think there's value in trying to signal that creating the invoker is a somewhat expensive operation (so, I also think `makeInvoker` is a better name, since `invoker` sounds like an accessor). Auto-complete with IntelliJ looks pretty nice too. It just suggest `makeInvoker` when typing the name of the symbol (`foo`):

![image](https://github.com/openjdk/jextract/assets/5962029/df4eff38-2178-4a06-9f41-b7b53fdd160b)

P.S. see needed changes here: https://github.com/openjdk/jextract/pull/205/commits/28d8ba684674cb3d3e33f4b5378ef5a3894d883e

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

PR Comment: https://git.openjdk.org/jextract/pull/205#issuecomment-1939227395


More information about the jextract-dev mailing list