[foreign-abi] RFR: 8245988: Add a special VaList carrier

Jorn Vernee jvernee at openjdk.java.net
Fri May 29 15:07:52 UTC 2020


On Wed, 27 May 2020 18:13:01 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Hi,
>> 
>> This patch adds a special VaList carrier to CSupport that can be used by C linker implementations to pass `va_list`
>> arguments to upcalls and downcalls.
>> Currently Windows VaList and SysV VaLists are implemented, but AArach64 not yet.
>> 
>> The API for the Reader and Builder might be a bit strange; the limitation to int, long, and double comes from the
>> standard argument promotions that are done in C when calling a variadic function. Since we do not know how to promote
>> any arbitrary value, at least for now the API restricts itself to accepting only types that would not be promoted in C,
>> leaving any needed conversion up to the user.  For reviewers; I moved CallArranger.TypeClass + classification code to
>> the top level, since it is now shared with the VaList implementations, so that's where the CallArranger diff comes
>> from.  Thanks, Jorn
>
> Great work.
> 
> Didn't read through all the changes - but I have a question on the API - why did you opted for a separate Reader
> abstraction? Seems like VaList is already stateful anyway (since it can be closed), why not dropping all the reader
> methods directly into VaList?  Also (but can be done later) - we need va_copy too.

Reader is an attempt to allow users to re-read the same VaList. It also gives an oppertunity to declare how many
arguments the VaList is expected to hold (something we don't know when constructing the VaList instance). I think
moving the reader methods to VaList makes sense as well.

I'll look into implementing a `copy()` method as well.

As discussed offline, I'll also look into adding methods to convert back and forth between a MemoryAddress from a
VaList. As well as adding a benchmark that compares VaList with a manually specialized varargs down call (using `...`).

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

PR: https://git.openjdk.java.net/panama-foreign/pull/184


More information about the panama-dev mailing list