[foreign-memaccess+abi] RFR: 8284300: Explicitly reject layouts that don't have the correct alignment during linking

Jorn Vernee jvernee at openjdk.org
Tue Sep 20 19:00:32 UTC 2022


On Tue, 20 Sep 2022 18:57:29 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/CallArranger.java line 279:
>> 
>>> 277:                 long copy = Math.min(layout.byteSize() - offset, COPY_CHUNK_SIZE);
>>> 278:                 VMStorage storage = storageCalculator.stackAlloc(copy, align);
>>> 279:                 align = 1; // only first copy needs aligning
>> 
>> so, this was an issue in the old code? (seems like in old code we always align to STACK_SLOT_SIZE)
>
> Sorry, forgot to explain this.
> 
> In the old code we always passed STACK_SLOT_SIZE. This works out in the current implementation since we only allow values to be copied to the stack at stack slot aligned offset. Though, technically, we might need a more precise alignment in the case of Mac/AArch64. For instance, if a struct has 4 byte alignment, we might need to spill it at a 4-byte aligned stack offset.
> 
> I noticed this when looking through the code and decided to fix this. But, I'm think now that it kinda doesn't belong in this patch. I can remove it. All we need is the change to drop `SharedUtils.alignment` for `layout.byteAlignment` above.

I think this might have slipped over from when I was working on the Mac/AArch64 stack spill issue, and I didn't think to remove it :/

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

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


More information about the panama-dev mailing list