[foreign-abi] RFR: 8254682: Close MemorySegments passed to upcalls after the upcall is done

Jorn Vernee jvernee at openjdk.java.net
Tue Oct 13 17:14:29 UTC 2020


On Tue, 13 Oct 2020 17:08:09 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/AbstractNativeScope.java line 140:
>> 
>>> 138:
>>> 139:     // only for registering
>>> 140:     private static class EmptyScope extends AbstractNativeScope {
>> 
>> could this be your Throwing Allocator?
>
> No, the throwing allocator has no machinery to do handoffs. The code of EmptyScope looks deceptively simple, but that's
> because all the logic we want is actually in the base class.

I tried to replace this with a singleton as well, but realized that doesn't work because then the list of registered
segments would be shared. There's also other things like recreating the segment with less access modes that would be
nice to re-use the NativeScope implementation for. (though, if needed, it can be re-written specifically for Allocator.
But, NativeScope just seems like (almost) the right hammer here).

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

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


More information about the panama-dev mailing list