On Thu, 24 Aug 2023 23:36:22 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> wrote:
>> I've found a way to solve the remaining FFI problem on linux PPC64 Big >> Endian. Large structs (>8 Bytes) which are passed in registers or on stack >> require shifting the Bytes in the last slot if the size is not a multiple of >> 8. This PR adds the required functionality to the Java code. >> >> Please review and provide feedback. There may be better ways to implement >> it. I just found one which works and makes the tests pass: >> >> Test summary >> ============================== >> TEST TOTAL PASS FAIL ERROR >> >> jtreg:test/jdk/java/foreign 88 88 0 0 >> >> >> >> Note: This PR should be considered as preparation work for AIX which also >> uses ABIv1. > > src/java.base/share/classes/jdk/internal/foreign/abi/Binding.java line 695: > >> 693: * Negative [shiftAmount] shifts right and converts to int if >> needed. >> 694: */ >> 695: record ShiftLeft(int shiftAmount, Class<?> type) implements Binding >> { > > Given the situation you are facing, perhaps adding the new binding here is > unavoidable. Let's wait to hear from @JornVernee. In the meantime, can you > point me to a document which explains this behavior? I'm curious and I'd like > to know more :-) Maybe I'm starting to see it - it's not a special rule, as much as it is a consequence of the endianness. E.g. if you have a struct that is 64 + 32 bytes, you can store the first 64 bytes as a long. Then, there's an issue as we have to fill another long, but we have only 32 bits of value. Is it the problem that if we just copy the value into the long word "as is" it will be stored in the "wrong" 32 bits? So the shift takes care of that, I guess? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15417#discussion_r1304981242