No segment method for MemoryAddress?
Ty Young
youngty1997 at gmail.com
Fri Aug 21 00:40:31 UTC 2020
On 8/20/20 4:43 PM, Maurizio Cimadamore wrote:
>
> On 20/08/2020 21:32, Ty Young wrote:
>> So, apparently the <MemoryAddress>.segment() method was removed and
>> now provides a seemingly redundant address() method:
>
> This was all described here:
>
> https://mail.openjdk.java.net/pipermail/panama-dev/2020-July/009928.html
>
> Basically, a MemoryAddress no longer has a link to a segment. An
> address is just a thin wrapper around an Object/long unsafe addressing
> pair.
>
> Addressable is mostly there so that _everything_ that can be converted
> to an address can be passed to a function. We use this in jextract, so
> that clients can avoid a lot of calls to ".baseAddress()". If you
> don't need it, you can ignore it.
I read that and came to that very conclusion as you give for the reason.
I thought it was a minor, optional API change and not something that
breaks the API's flow though which is why I never bothered making a new
JDK build.
I don't personally understand the logic here - It makes more sense(to
me, anyway) to talk in MemoryAddress(s) rather than MemorySegment(s),
MemoryAddress takes up heap representing what could be represented using
primitive longs(unless I'm missing something?), and you have this
address() method on MemoryAddress that presumably just returns
itself(?). The way it was before really wasn't bad, it just needed some
method name changes(baseAddress() -> address()).
I guess I'll be creating yet another abstraction interface
"NativeAddress" or something. I hope it doesn't get to the point where I
need to abstract everything about FMA.
>
> Maurizio
>
>
>>
>>
>> private final MemoryAddress address;
>>
>>
>> ...
>>
>>
>> this.address.address();
>>
>>
>> which has the Javadoc:
>>
>>
>> "Map this object into a MemoryAddress instance."
>>
>>
>> ...but it is already a MemoryAddress? What is going on here? How are
>> you supposed to get a segment from an address? Why is there a
>> seemingly redundant address() method?
>>
>>
>> Reading the Javadoc of Addressable:
>>
>>
>> "Represents a type which is addressable. An addressable type is one
>> which can be projected down to a memory address instance (see
>> address()). Examples of addressable types are MemorySegment,
>> MemoryAddress, LibraryLookup.Symbol and CSupport.VaList."
>>
>>
>> provides context on why the address() method exists but not why
>> segment() has been removed.
>>
>>
>> Personally, I think the address() method should be removed and the
>> components that make up a MemoryAddress be exposed instead if
>> possible, but that's my 2 cents.
>>
>>
>>
>>
>>
More information about the panama-dev
mailing list