Re: RFR: 8287244: Add bound check in indexed memory access var handle [v3]

2022-05-25 Thread Jorn Vernee
On Tue, 24 May 2022 18:15:45 GMT, Maurizio Cimadamore wrote: >> Constructing indexed var handles using the `MemoryLayout` API produces >> `VarHandle` which do not check the input indices for out-of-bounds >> conditions. >> While this can never result in a VM crash (after all the memory segment

Re: RFR: 8287244: Add bound check in indexed memory access var handle [v3]

2022-05-24 Thread Paul Sandoz
On Tue, 24 May 2022 18:15:45 GMT, Maurizio Cimadamore wrote: >> Constructing indexed var handles using the `MemoryLayout` API produces >> `VarHandle` which do not check the input indices for out-of-bounds >> conditions. >> While this can never result in a VM crash (after all the memory segment

Re: RFR: 8287244: Add bound check in indexed memory access var handle [v3]

2022-05-24 Thread Maurizio Cimadamore
> Constructing indexed var handles using the `MemoryLayout` API produces > `VarHandle` which do not check the input indices for out-of-bounds conditions. > While this can never result in a VM crash (after all the memory segment will > protect against "true" OOB access), it is still possible for a

Re: RFR: 8287244: Add bound check in indexed memory access var handle [v2]

2022-05-24 Thread Maurizio Cimadamore
On Tue, 24 May 2022 18:02:50 GMT, Maurizio Cimadamore wrote: >> Sorry i misread the text, we are talking about the same thing. I think it >> would be clearer to refer `x_i` being in the range of `0` (inclusive) and >> `b_i` (exclusive), otherwise an is thrown. That way in subsequent doc

Re: RFR: 8287244: Add bound check in indexed memory access var handle [v2]

2022-05-24 Thread Maurizio Cimadamore
On Tue, 24 May 2022 18:00:46 GMT, Paul Sandoz wrote: >> The terms `x_1, x_2, ... x__n` are defined, but `x_0` is not. >> >> I think you can refer to the first index out of bounds as the exclusive >> upper bound of the range? > > Sorry i misread the text, we are talking about the same thing. I

Re: RFR: 8287244: Add bound check in indexed memory access var handle [v2]

2022-05-24 Thread Paul Sandoz
On Tue, 24 May 2022 17:55:13 GMT, Paul Sandoz wrote: >> Here's a concrete example: >> >> Consider a sequence layout with 6 elements. Then: >> >> element count = 6 >> valid indices 0, 1, 2, 3, 4, 5 >> >> Now consider a var handle that is obtained by calling the path element >> method, passing

Re: RFR: 8287244: Add bound check in indexed memory access var handle [v2]

2022-05-24 Thread Paul Sandoz
On Tue, 24 May 2022 17:53:38 GMT, Maurizio Cimadamore wrote: >> Indices start at zero. The ceilDiv operation is needed so that the operation >> returns the first index outisde the range (it's a bit subtle, sorry, but I >> don't know how else to express). > > Here's a concrete example: > > Con

Re: RFR: 8287244: Add bound check in indexed memory access var handle [v2]

2022-05-24 Thread Maurizio Cimadamore
On Tue, 24 May 2022 17:43:52 GMT, Maurizio Cimadamore wrote: >> src/java.base/share/classes/java/lang/foreign/MemoryLayout.java line 374: >> >>> 372: * >>> 373: * Additionally, the provided dynamic values must conform to some >>> bound which is derived from the layout path, that is,

Re: RFR: 8287244: Add bound check in indexed memory access var handle [v2]

2022-05-24 Thread Maurizio Cimadamore
On Tue, 24 May 2022 16:23:52 GMT, Paul Sandoz wrote: >> Maurizio Cimadamore has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Tweak javadoc for ValueLayout::arrayElementVarHandle > > src/java.base/share/classes/java/lang/foreign/MemoryLayo

Re: RFR: 8287244: Add bound check in indexed memory access var handle [v2]

2022-05-24 Thread Paul Sandoz
On Tue, 24 May 2022 15:28:27 GMT, Maurizio Cimadamore wrote: >> Constructing indexed var handles using the `MemoryLayout` API produces >> `VarHandle` which do not check the input indices for out-of-bounds >> conditions. >> While this can never result in a VM crash (after all the memory segment

Re: RFR: 8287244: Add bound check in indexed memory access var handle [v2]

2022-05-24 Thread Paul Sandoz
On Tue, 24 May 2022 15:28:27 GMT, Maurizio Cimadamore wrote: >> Constructing indexed var handles using the `MemoryLayout` API produces >> `VarHandle` which do not check the input indices for out-of-bounds >> conditions. >> While this can never result in a VM crash (after all the memory segment

Re: RFR: 8287244: Add bound check in indexed memory access var handle [v2]

2022-05-24 Thread Maurizio Cimadamore
> Constructing indexed var handles using the `MemoryLayout` API produces > `VarHandle` which do not check the input indices for out-of-bounds conditions. > While this can never result in a VM crash (after all the memory segment will > protect against "true" OOB access), it is still possible for a

Re: RFR: 8287244: Add bound check in indexed memory access var handle

2022-05-24 Thread Maurizio Cimadamore
On Tue, 24 May 2022 14:40:56 GMT, Maurizio Cimadamore wrote: > Constructing indexed var handles using the `MemoryLayout` API produces > `VarHandle` which do not check the input indices for out-of-bounds conditions. > While this can never result in a VM crash (after all the memory segment will

Re: RFR: 8287244: Add bound check in indexed memory access var handle

2022-05-24 Thread Maurizio Cimadamore
On Tue, 24 May 2022 14:51:10 GMT, Maurizio Cimadamore wrote: >> Constructing indexed var handles using the `MemoryLayout` API produces >> `VarHandle` which do not check the input indices for out-of-bounds >> conditions. >> While this can never result in a VM crash (after all the memory segment

RFR: 8287244: Add bound check in indexed memory access var handle

2022-05-24 Thread Maurizio Cimadamore
Constructing indexed var handles using the `MemoryLayout` API produces `VarHandle` which do not check the input indices for out-of-bounds conditions. While this can never result in a VM crash (after all the memory segment will protect against "true" OOB access), it is still possible for an access