[foreign-memaccess+abi] RFR: 8287516: Implement fallback Linker [v5]
Jorn Vernee
jvernee at openjdk.org
Fri Jan 20 13:07:10 UTC 2023
On Fri, 20 Jan 2023 12:57:51 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Jorn Vernee has updated the pull request incrementally with one additional commit since the last revision:
>>
>> add note about dependencies
>
> src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FFIType.java line 129:
>
>> 127: try (Arena verifyArena = Arena.openConfined()) {
>> 128: MemorySegment offsetsOut = verifyArena.allocate(SIZE_T.byteSize() * filteredLayouts.size());
>> 129: LibFallback.getStructOffsets(structType, offsetsOut, abi);
>
> Maybe I'm being paranoid, but libFFI has its own way to determine a struct layout given the struct fields, based on what the ABI types are. But the Panama layout API is more expressive than that, and it allows, theoretically, to pass arguments that have stricter or larger alignment constraints - which can end up in more or less padding being inserted (from clients), and in different struct layout sizes.
>
> So, my question is: should we double check that what we get back from libFFI is actually compatible with what we have in the group layout before proceeding?
Yes, that is exactly what this code (`verifyStructType`) is trying to do.
Note that we also already reject layouts that do not have natural alignment [1](https://github.com/openjdk/panama-foreign/blob/foreign-memaccess%2Babi/src/java.base/share/classes/jdk/internal/foreign/abi/AbstractLinker.java#L111) Though, we might want to relax that constraint in the future.
-------------
PR: https://git.openjdk.org/panama-foreign/pull/770
More information about the panama-dev
mailing list