RFR: 7903660: Drop layout-inferring varargs invoker + add method handle factory [v3]
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Feb 12 16:49:06 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
src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java line 221:
> 219:
> 220: /**
> 221: * {@return specialized method handle}
Should we use an article here? E.g."the specialized" - not sure how it would look in the javadoc
test/jtreg/generator/testPrintf/TestPrintf.java line 54:
> 52:
> 53: @Test(dataProvider = "cases")
> 54: public void testsPrintfHandle(String fmt, Object[] args, String expected, MemoryLayout[] layouts) throws Throwable {
Shouldn't we also have a test for the invoker interface?
-------------
PR Review Comment: https://git.openjdk.org/jextract/pull/205#discussion_r1486475640
PR Review Comment: https://git.openjdk.org/jextract/pull/205#discussion_r1486478239
More information about the jextract-dev
mailing list