Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v7]

2023-09-05 Thread Martin Doerr
On Mon, 4 Sep 2023 21:17:06 GMT, Martin Doerr 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. Thi

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v7]

2023-09-05 Thread Maurizio Cimadamore
On Mon, 4 Sep 2023 21:17:06 GMT, Martin Doerr 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. Thi

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v3]

2023-09-05 Thread Maurizio Cimadamore
On Mon, 4 Sep 2023 14:30:06 GMT, Maurizio Cimadamore wrote: >> @TheRealMDoerr We've been discussing the shifts in order to wrap our heads >> around it, and we've ended up with this diagram in order to try and >> visualize what happens: >> >> Let's say we have a struct with 3 ints: >> >> >>

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v3]

2023-09-05 Thread Martin Doerr
On Mon, 4 Sep 2023 14:30:06 GMT, Maurizio Cimadamore wrote: >> @TheRealMDoerr We've been discussing the shifts in order to wrap our heads >> around it, and we've ended up with this diagram in order to try and >> visualize what happens: >> >> Let's say we have a struct with 3 ints: >> >> >>

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v7]

2023-09-05 Thread Jorn Vernee
On Mon, 4 Sep 2023 21:17:06 GMT, Martin Doerr 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. Thi

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v7]

2023-09-04 Thread Martin Doerr
> 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. > >

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v6]

2023-09-04 Thread Martin Doerr
On Mon, 4 Sep 2023 15:38:19 GMT, Martin Doerr 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. Thi

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v5]

2023-09-04 Thread Martin Doerr
On Mon, 4 Sep 2023 14:53:33 GMT, Jorn Vernee wrote: >> Martin Doerr has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Separate type cast from Shift bindings. > > src/java.base/share/classes/jdk/internal/foreign/abi/Binding.java line 425: >

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v6]

2023-09-04 Thread Martin Doerr
> 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. > >

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v5]

2023-09-04 Thread Jorn Vernee
On Mon, 4 Sep 2023 14:56:18 GMT, Martin Doerr 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. Thi

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v5]

2023-09-04 Thread Martin Doerr
On Mon, 4 Sep 2023 14:56:18 GMT, Martin Doerr 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. Thi

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v4]

2023-09-04 Thread Jorn Vernee
On Mon, 4 Sep 2023 14:54:05 GMT, Martin Doerr wrote: > Do you see a good place for such a comment? PPC CallArranger seems like a good place to me. We have a similar explanation comment in the AArch64 CallArranger. > Maybe it would be better to use a different size for the last chunk. Maybe >

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v5]

2023-09-04 Thread Jorn Vernee
On Mon, 4 Sep 2023 14:56:18 GMT, Martin Doerr 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. Thi

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v3]

2023-09-04 Thread Jorn Vernee
On Mon, 4 Sep 2023 14:50:37 GMT, Martin Doerr wrote: >>> as it would no longer need an input type? >> >> Yes. Then both shift ops would always operate on `long`. > > I've changed it. Note that I need many more conversions because buffer > load/store also use subtypes of `int`. Please take a loo

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v4]

2023-09-04 Thread Martin Doerr
On Mon, 4 Sep 2023 12:22:00 GMT, Martin Doerr 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. Thi

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v5]

2023-09-04 Thread Martin Doerr
> 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. > >

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v4]

2023-09-04 Thread Martin Doerr
On Mon, 4 Sep 2023 12:44:51 GMT, Jorn Vernee wrote: >> Martin Doerr has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Split Shift into ShiftLeft and ShiftRight + minor improvements. > > src/java.base/share/classes/jdk/internal/foreign/abi/

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v3]

2023-09-04 Thread Martin Doerr
On Mon, 4 Sep 2023 14:33:08 GMT, Jorn Vernee wrote: >>> I think it's worth it in order to have a cleaner contract for the shift >>> ops, should we want to use them for anything else in the future, but also >>> just to make them easier to understand for future readers. >> >> I agree that having

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v3]

2023-09-04 Thread Jorn Vernee
On Mon, 4 Sep 2023 14:27:27 GMT, Maurizio Cimadamore wrote: > as it would no longer need an input type? Yes. Then both shift ops would always operate on `long`. - PR Review Comment: https://git.openjdk.org/jdk/pull/15417#discussion_r1315016599

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v3]

2023-09-04 Thread Maurizio Cimadamore
On Mon, 4 Sep 2023 14:18:44 GMT, Jorn Vernee wrote: > If this struct is passed as an argument, then the load of the second 'half' > of the struct would look like this: It would perhaps be cleaner if in the MSB/LSB comments we said: LSBs are zzz...z LSBs are 000...0 (e.g. avoid to refer to MSB

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v3]

2023-09-04 Thread Jorn Vernee
On Mon, 4 Sep 2023 12:20:52 GMT, Martin Doerr wrote: >> Sorry for the delay, I've been on vacation. > >> Sorry for the delay, I've been on vacation. > > No problem. Hope you had a good time! Thanks for your feedback. @TheRealMDoerr We've been discussing the shifts in order to wrap our heads ar

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v4]

2023-09-04 Thread Jorn Vernee
On Mon, 4 Sep 2023 12:22:00 GMT, Martin Doerr 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. Thi

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v3]

2023-09-04 Thread Jorn Vernee
On Mon, 4 Sep 2023 12:19:42 GMT, Martin Doerr wrote: >> src/java.base/share/classes/jdk/internal/foreign/abi/Binding.java line 398: >> >>> 396: bindings.add(Binding.cast(type, int.class)); >>> 397: type = int.class; >>> 398: } >> >> Part of the casts

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v3]

2023-09-04 Thread Martin Doerr
On Mon, 4 Sep 2023 07:26:36 GMT, Jorn Vernee wrote: > Sorry for the delay, I've been on vacation. No problem. Hope you had a good time! Thanks for your feedback. > src/java.base/share/classes/jdk/internal/foreign/abi/Binding.java line 398: > >> 396: bindings.add(Binding.cast(ty

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v3]

2023-09-04 Thread Martin Doerr
On Mon, 4 Sep 2023 07:06:39 GMT, Jorn Vernee wrote: >> Martin Doerr has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Remove unnecessary imports. > > src/java.base/share/classes/jdk/internal/foreign/abi/Binding.java line 695: > >> 693:

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v4]

2023-09-04 Thread Martin Doerr
> 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. > >

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v3]

2023-09-04 Thread Jorn Vernee
On Fri, 25 Aug 2023 09:24:15 GMT, Maurizio Cimadamore wrote: >> The ABI says: "An aggregate or union smaller than one doubleword in size is >> padded so that it appears in the least significant bits of the doubleword. >> All others are padded, if necessary, at their tail." >> [https://refspec

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v3]

2023-09-04 Thread Jorn Vernee
On Fri, 25 Aug 2023 10:59:45 GMT, Martin Doerr 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. Th

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v3]

2023-08-25 Thread Martin Doerr
> 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. > >

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v2]

2023-08-25 Thread Martin Doerr
On Fri, 25 Aug 2023 09:01:43 GMT, Maurizio Cimadamore wrote: >> I had something like that, but another reviewer didn't like it, either. >> Originally, I had thought that the v1 and v2 CallArrangers would get more >> content, but they're still empty. Would it be better to remove these special

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API [v2]

2023-08-25 Thread Martin Doerr
> 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. > >

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API

2023-08-25 Thread Maurizio Cimadamore
On Fri, 25 Aug 2023 07:54:51 GMT, Martin Doerr wrote: >> src/java.base/share/classes/jdk/internal/foreign/abi/Binding.java line 717: >> >>> 715: public void interpret(Deque stack, StoreFunc storeFunc, >>> 716: LoadFunc loadFunc, SegmentAllocator >>> allocat

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API

2023-08-25 Thread Maurizio Cimadamore
On Fri, 25 Aug 2023 07:48:19 GMT, Martin Doerr wrote: >> If my assumption above is correct, then maybe another way to solve the >> problem, would be to, instead of adding a new shift binding, to generalize >> the VM store binding we have to allow writing a smaller value into a bigger >> storag

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API

2023-08-25 Thread Maurizio Cimadamore
On Fri, 25 Aug 2023 07:36:47 GMT, Martin Doerr wrote: >> src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/ABIv1CallArranger.java >> line 33: >> >>> 31: * PPC64 CallArranger specialized for ABI v1. >>> 32: */ >>> 33: public class ABIv1CallArranger extends CallArranger { >> >> Wouldn

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API

2023-08-25 Thread Martin Doerr
On Thu, 24 Aug 2023 23:38:42 GMT, Maurizio Cimadamore 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

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API

2023-08-25 Thread Martin Doerr
On Fri, 25 Aug 2023 00:10:11 GMT, Maurizio Cimadamore 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

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API

2023-08-25 Thread Martin Doerr
On Thu, 24 Aug 2023 23:58:35 GMT, Maurizio Cimadamore wrote: >> 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

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API

2023-08-25 Thread Martin Doerr
On Thu, 24 Aug 2023 23:33:23 GMT, Maurizio Cimadamore 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

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API

2023-08-24 Thread Maurizio Cimadamore
On Thu, 24 Aug 2023 13:56:12 GMT, Martin Doerr 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 P

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API

2023-08-24 Thread Maurizio Cimadamore
On Thu, 24 Aug 2023 23:55:28 GMT, Maurizio Cimadamore wrote: >> 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

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API

2023-08-24 Thread Maurizio Cimadamore
On Thu, 24 Aug 2023 23:36:22 GMT, Maurizio Cimadamore 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

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API

2023-08-24 Thread Maurizio Cimadamore
On Thu, 24 Aug 2023 13:56:12 GMT, Martin Doerr 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 P

Re: RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API

2023-08-24 Thread Maurizio Cimadamore
On Thu, 24 Aug 2023 13:56:12 GMT, Martin Doerr 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 P

RFR: 8314949: linux PPC64 Big Endian: Implementation of Foreign Function & Memory API

2023-08-24 Thread Martin Doerr
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 revi