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

Maurizio Cimadamore mcimadamore at openjdk.java.net
Fri Jul 3 14:28:48 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.

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

Commit messages:
 - Tweaked accessor names
 - Add more accessors

Changes: https://git.openjdk.java.net/panama-foreign/pull/232/files
 Webrev: https://webrevs.openjdk.java.net/panama-foreign/232/webrev.00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8248487
  Stats: 1354 lines in 2 files changed: 1292 ins; 0 del; 62 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