[foreign-memaccess+abi] RFR: 8291473: Unify MemorySegment and MemoryAddress [v2]
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu Jul 28 16:45:25 UTC 2022
> This patch implements the changes described in [1].
>
> The main things to notice are the removal of `MemoryAddress` and `Addressable`. Everything else falls from that.
>
> There are some changes to the `MemorySegment` API as well, as some methods such as `segmentOffset` and `asOverlappingSlice` have been removed, and instead `MemorySegment::address` now works on heap segments too (and, clients can obtain the array of an heap segment using its `array` method). So, these methods can, if needed, be implemented outside the core API.
>
> `MemorySegment::equals` now compares the segments address, which is the most useful comparison when working with native interop (again, client can implement deeper comparison using `mismatch`).
>
> Finally, restricted factories accepting raw addresses (in `MemorySegment` and `VaList`) have been tweaked to accept a long value instead.
>
> `VaList` also needed some adjustments, since it builds on top of segments. The API is similar to before - but instead of having an address accessor, it has a zero-length segment accessor.
>
> `ValueLayout.OfAddress` has a new method to create *unsafe* address layouts which return segment with maximal size (`Long.MAX_VALUE`). I've used these layouts in a lot of places in the implementation internal, which simplifies things quite a bit (e.g. removing the need to create a new segment from an address).
>
> There are several test and microbenchmark updates, but relatively minor, and all caused by removal of `MemoryAddress`/`Addressable`. Changes here should be relatively simple to follow.
>
> While the javadoc is ok, I didn't put too much effort in trying to provide a complete and cohesive story on how zero-length segments are used to model raw addresses. I'm working on some more extensive doc changes on the side, but I wanted to split the javadoc changes from the impl changes, so as to simplify the review work. I hope that makes sense.
>
> [1] - https://mail.openjdk.org/pipermail/panama-dev/2022-July/017181.html
Maurizio Cimadamore has updated the pull request incrementally with four additional commits since the last revision:
- Update src/java.base/share/classes/jdk/internal/foreign/abi/AbstractLinker.java
Co-authored-by: Jorn Vernee <JornVernee at users.noreply.github.com>
- Update src/java.base/share/classes/java/lang/foreign/VaList.java
Co-authored-by: Jorn Vernee <JornVernee at users.noreply.github.com>
- Update src/java.base/share/classes/java/lang/foreign/ValueLayout.java
Co-authored-by: Jorn Vernee <JornVernee at users.noreply.github.com>
- Update src/java.base/share/classes/java/lang/foreign/package-info.java
Co-authored-by: Jorn Vernee <JornVernee at users.noreply.github.com>
-------------
Changes:
- all: https://git.openjdk.org/panama-foreign/pull/694/files
- new: https://git.openjdk.org/panama-foreign/pull/694/files/31fa30b5..118cf04b
Webrevs:
- full: https://webrevs.openjdk.org/?repo=panama-foreign&pr=694&range=01
- incr: https://webrevs.openjdk.org/?repo=panama-foreign&pr=694&range=00-01
Stats: 6 lines in 4 files changed: 0 ins; 0 del; 6 mod
Patch: https://git.openjdk.org/panama-foreign/pull/694.diff
Fetch: git fetch https://git.openjdk.org/panama-foreign pull/694/head:pull/694
PR: https://git.openjdk.org/panama-foreign/pull/694
More information about the panama-dev
mailing list