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

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Jan 19 12:12:30 UTC 2023


On Thu, 19 Jan 2023 11:24:55 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/foreign/Utils.java line 219:
>> 
>>> 217:     }
>>> 218: 
>>> 219:     public static StructLayout computeStructLayout(MemoryLayout... elements) {
>> 
>> Not too sure about this - at least this being here. The general spirit of Linker classification is that padding bits are inserted as required by the client. Now, it seems you need this inside the fallback FFI, so that you can create the precise layout of a struct where some of the fields might be platform-dependent - in that case I'd say it would be better to move this function over there?
>
> Note that we don't use this on any of the user supplied layouts. This is only used to compute the layout of `ffi_type` in `FFIType`. On 64bit platforms this needs padding, on 32bit platforms it does not.
> 
> I can move it into `FFIType` as well, but it seemed like a more general piece of functionality (i.e. maybe we could change the CallGeneratorHelper test class to use this instead)

Yep - I've seen that. I guess perhaps what I find confusing is the name - e.g. one might thing that MemoryLayout.structLayout should call this, but it doesn't. But I don't have any great suggestions. Perhaps I'd stress the alignment, so maybe "computePaddedStructLayout" would be clearer?

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

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


More information about the panama-dev mailing list