[foreign-memaccess+abi] RFR: 8275584: Incorrect stack spilling in CallArranger on MacOS/AArch64 [v2]

Nick Gasson ngasson at openjdk.org
Tue Oct 25 09:04:18 UTC 2022


On Mon, 24 Oct 2022 14:12:38 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/CallArranger.java line 290:
>> 
>>> 288:                 long copy = Math.min(layout.byteSize() - offset, STACK_SLOT_SIZE);
>>> 289:                 VMStorage storage =
>>> 290:                     storageCalculator.stackAlloc(copy, layout.byteAlignment(), false);
>> 
>> Ok. So it looks like only HFAs are 'packed', and other structs follow the classic approach of passing everything in stack slot sized chunks :/
>
> I think maybe passing `layout.byteAlignment` here is a little misleading, as it is unconditionally overwritten to `STACK_SLOT_SIZE` in `stackAlloc` any ways.
> 
> I know that's a change I made, but I think it might be better to just use `STACK_SLOT_SIZE` as alignment here, and then I don't think the extra `subSlotPacking` parameter is needed either.

> Ok. So it looks like only HFAs are 'packed', and other structs follow the classic approach of passing everything in stack slot sized chunks :/

Yes but I only figured that out by looking at what Clang does. Apple's page at [1] isn't very clear on this.

[1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms

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

PR: https://git.openjdk.org/panama-foreign/pull/746


More information about the panama-dev mailing list