[foreign-memaccess] RFR 8230449: Simplify creation of handles for memory slices

Jorn Vernee jorn.vernee at oracle.com
Tue Sep 3 14:25:03 UTC 2019


Hi,

Some comments:
- MemoryLayout.java; The javadoc should be updated from "if the step 
factor is < 0" -> "is 0", since it can also be negative.
- LayoutPathImpl.java; Could use a helper method to do the sequence 
index check (code is duplicated between 2 `sequenceElement` methods). 
Also, the `step == 0` check is done in the PathElement::sequenceElement 
already. Lastly, I'm not so sure about the last check for invalid step 
factor. It would still be valid to access a single element when the 
coordinate passed to the VH is 0, but this check blocks that.

Rest looks good.

Cheers,
Jorn

On 02/09/2019 17:27, Maurizio Cimadamore wrote:
> Hi,
> the foreign memory API is pretty good at expressing access to 
> multi-dimensional data, e.g. by allowing to define custom strides and 
> offsets. There are however some limitations that limit the 
> expressiveness of the API when it comes to denote complex 
> VarHandle-based views of contiguous chunks of memory:
>
> 1) It is not possible to use negative strides (which makes it 
> impossible e.g. to create a VarHandle which returns the contents of 
> the memory region "in reverse order")
> 2) there's no way in the PathElement API to select a 'slice' of a 
> sequence layout (e.g. from start given start index, with given step)
>
> The following webrev aims at closing this gap:
>
> http://cr.openjdk.java.net/~mcimadamore/panama/8230449/
>
> P.S.
> To allow negative strides I had to remove a validation of the stride 
> in the combinator API which ensured that the stride was greater than 
> the offset + carrierSize. I believe this restriction to be a tad 
> obscure and not a fundamental one (this was also pointed out by Jorn 
> when I added the restriction in the first place), so I'm ok to drop it 
> in name for more expressiveness.
>
> Maurizio
>


More information about the panama-dev mailing list