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

Jorn Vernee jvernee at openjdk.org
Mon Feb 12 13:21:13 UTC 2024


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.

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

Commit messages:
 - remove layout-inferring invoker + add MH factory for variadic funcs

Changes: https://git.openjdk.org/jextract/pull/205/files
 Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=205&range=00
  Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903660
  Stats: 84 lines in 3 files changed: 35 ins; 37 del; 12 mod
  Patch: https://git.openjdk.org/jextract/pull/205.diff
  Fetch: git fetch https://git.openjdk.org/jextract.git pull/205/head:pull/205

PR: https://git.openjdk.org/jextract/pull/205


More information about the jextract-dev mailing list