[foreign-memaccess] RFR: Backport misc changes from foreign-abi

Maurizio Cimadamore mcimadamore at openjdk.java.net
Tue Mar 31 14:33:55 UTC 2020


On Tue, 31 Mar 2020 13:57:31 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

> Hi,
> 
> This patch backports several changes that went into the foreign-abi branch, but which are in retrospect useful to have
> on the memaccess branch, and as part of the memory access API as well.
> These changes include:
> - Replacing ForeignUnsafe with Foreign
> - Adding the `ofNativeUnchecked` method to create unchecked MemorySegments, MemoryAddress::ofLong to forge
>   MemoryAddresses from longs, as well as the Nothing segment and rebase support. Mainly to support going from a `long` to
>   `MemoryAddress`, and also to `MemorySegment` (MA -> long is already covered) The memory layout attributes exposed in
>   the public API (could be interesting to investigate attaching carrier types directly to layouts).
> 
> The MemoryAddress carrier support for VarHandles is left out for now, since the current thinking is that it will be
> dropped and replaced with VarHandle combinators to convert between long and MA instead.
> Thanks,
> Jorn

Looks good - few minor nits noted

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryAddress.java line 133:

> 132:      */
> 133:     MemoryAddress NULL = MemorySegmentImpl.NOTHING.baseAddress();
> 134:

I'd leave this out for now? This seems very C oriented.

src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/MemoryAddressImpl.java line 142:

> 141:
> 142:     public static MemoryAddress ofLongUnchecked(long value) {
> 143:         return ofLongUnchecked(value, Long.MAX_VALUE);

I believe these two are probably unused?

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

Marked as reviewed by mcimadamore (Committer).

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


More information about the panama-dev mailing list