[foreign-memaccess+abi] RFR: 8275332: Variadic functions don't work on Linux/AArch64

Nick Gasson ngasson at openjdk.java.net
Wed Oct 20 02:24:23 UTC 2021


On Tue, 19 Oct 2021 11:16:11 GMT, Andrew Haley <aph at openjdk.org> wrote:

>> src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/aarch64/CallArranger.java line 213:
>> 
>>> 211:         }
>>> 212: 
>>> 213:         void adjustForVarArgs(boolean varArgsOnStack) {
>> 
>> If I'm right this is the only place where something different needs to happen for the two ABIs? If so - perhaps we could consider a different restacking where we use inheritance from a common abstract class - but that would change the shape of the code a bit.
>
> Please.

Well I did think about that, but at the moment CallArranger is just a bag of static methods: we'd need to refactor it quite a bit to fit it into that pattern. 

Perhaps (an AArch64 extension of) AbiDescriptor is the right place to store this? That already stores information like stack alignment, shadow space, etc. We'd then have a `MACOS_C` and `LINUX_C` instead of the single `C` we have now, and then pass that into `getBindings()`, etc.

> If I'm right this is the only place where something different needs to happen for the two ABIs?

Actually I think there's one more case we don't handle correctly at the moment but isn't covered by the existing tests:


void f(int, int, int, int, int, int, int, int, char x, short y);


In the standard ABI `x` and `y` get spilled to the stack as eight byte quantities (as if they were assigned to a register and then spilled) but in the Mac ABI they are spilled to the stack with their original size and natural alignment. So we need another flag somewhere to handle that difference. I'll make a JBS ticket for it.

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

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


More information about the panama-dev mailing list