[foreign-memaccess+abi] RFR: 8287516: Implement fallback Linker [v5]

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Jan 20 13:11:57 UTC 2023


On Fri, 20 Jan 2023 13:04:07 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> 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.
>
> More specifically, if a struct has extra padding, then I wonder if libFFI could expect a struct size that is smaller than the size of the memory segment passed in by a Panama client (because that segment also has the extra padding). In our usual JDK-driven classification, we would take the struct, extract its field components and place them on registers and/or stack slots. But with libFFI, we just have to provide the struct segment in a buffer, which then libFFI will act upon - if there is a size mismatch there, I think it might have dire consequences?

Anyway - I appreciate that the code verifies for mismatches. Good job. I was worried about the analysis being too "field-oriented", but you also look at offsets, so any extra padding should result in issues. Well, except maybe a trailing padding field?

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

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


More information about the panama-dev mailing list