[foreign-memaccess] RFR: 8248487: Add static helpers to access segments (continued) [v2]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Fri Jul 3 16:01:27 UTC 2020


> Following some feedback from jextract experiments, we have noted that, while the set of primitive accessors is the
> right one to expose, as it is the most primitive (and others can be derived from that), usability-wise we lose a bit
> when it comes to perform dereference at offset 0 (in which case an extra offset 0 has to be specified), or a
> dereference with a logical index (e.g. `p[i] = ...`).  To overcome these issues, I've added two additional variants of
> static accessors - now:
> * `getByte_LE(MemoryAddress addr)` -> dereference at given address
> * `getByteAtOffset(MemoryAddress, byte offset)` -> dereference at given address + offset (in bytes)
> * `getByteAtIndex(MemoryAddress, long index)` -> dereference at given logical index (where offset = index * stride)
> 
> Looking at TestByteBuffer, this immediately seem to make things better.

Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:

  Update src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryAccess.java
  
  Co-authored-by: Jorn Vernee <JornVernee at users.noreply.github.com>

-------------

Changes:
  - all: https://git.openjdk.java.net/panama-foreign/pull/232/files
  - new: https://git.openjdk.java.net/panama-foreign/pull/232/files/5e09a135..ef8b8890

Webrevs:
 - full: https://webrevs.openjdk.java.net/panama-foreign/232/webrev.01
 - incr: https://webrevs.openjdk.java.net/panama-foreign/232/webrev.00-01

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/232.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/232/head:pull/232

PR: https://git.openjdk.java.net/panama-foreign/pull/232


More information about the panama-dev mailing list