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

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Sep 2 15:27:11 UTC 2019


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