[foreign-memaccess+abi] RFR: 8301801: Implement arena-centric API

Jorn Vernee jvernee at openjdk.org
Thu Feb 9 18:49:25 UTC 2023


On Thu, 9 Feb 2023 16:42:27 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java line 157:
>> 
>>> 155: 
>>> 156:     private static MemorySegment bufferCopy(MemorySegment dest, MemorySegment buffer) {
>>> 157:         return dest.asUnbounded().copyFrom(buffer);
>> 
>> Why is this change needed? The destination segment should already have the right size.
>> 
>> Looking at the current code, this is used for upcall IMR, where we get a pointer from native code to copy the return value into. When that pointer is boxed up, we should be attaching the right size to it (since we know the layout of the return value).
>
> Okay, it looks like for in memory return on e.g. SysV, we are using just a plain `C_POINTER` layout without a pointee layout attached, so the boxed address should already have unbounded size.

I guess we could also potentially attach the right size to the address layout, to make this buffer copy just a bit more safe. But, we can do that later.

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

PR: https://git.openjdk.org/panama-foreign/pull/781


More information about the panama-dev mailing list