[Integrated] [foreign-abi] RFR: JDK-8244601: Cleanup support for upcall handles

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu May 7 14:32:22 UTC 2020

On Thu, 7 May 2020 11:21:15 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This patch removes the SystemABI::freeUpcallStub routine and, in its place, allows SystemABI::upcallHandle to return
> a *stub segment* which can be explicitly closed by the user.
> I think having one less method in SystemABI is cleaner - but I'm not 100% sure that using a segment as the return type
> is the way to go; I found myself split between returning MemoryAddress and MemorySegment while writing this patch. I
> ultimately went for MemorySegment because I think it makes idiomatic code a tad cleaner (look at StdLibTest).  When
> writing this I also wondered if we couldn't benefit from a separate abstraction for callbacks - something like:
> interface UpcallHandle extends AutoCloseable {
>    MethodHandle handle();
>    MemoryAddress address();
>    void close();
> }
> And then teach SystemABI about this carrier (the translation into a raw address should be relatively painless). But
> then we'd still need to support cases where the function pointer is obtained through another native call (in which case
> the carrier will just be MemoryAddress). So I'm not sure in the end having this additional abstraction will change
> things significantly compared to just having a segment and have the user calling `baseAddress`.  That said, I'm open to
> suggestions if people feel strongly one way or another.

This pull request has now been integrated.

Changeset: d8f37ce8
Author:    Maurizio Cimadamore <mcimadamore at openjdk.org>
URL:       https://git.openjdk.java.net/panama-foreign/commit/d8f37ce8
Stats:     93 lines in 10 files changed: 34 ins; 27 del; 32 mod

JDK-8244601: Cleanup support for upcall handles

Reviewed-by: sundar, jvernee


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

More information about the panama-dev mailing list