Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK-8244601: Cleanup support for upcall handles #154

Closed
wants to merge 1 commit into from

Conversation

@mcimadamore
Copy link
Collaborator

@mcimadamore mcimadamore commented May 7, 2020

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.


Progress

  • Change must not contain extraneous whitespace
  • Change must be properly reviewed

Issue

Reviewers

  • Athijegannathan Sundararajan (sundar - Committer)
  • Jorn Vernee (jvernee - Committer)

Download

$ git fetch https://git.openjdk.java.net/panama-foreign pull/154/head:pull/154
$ git checkout pull/154

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented May 7, 2020

👋 Welcome back mcimadamore! A progress list of the required criteria for merging this PR into foreign-abi will be added to the body of your pull request.

@openjdk openjdk bot added the rfr label May 7, 2020
@mlbridge
Copy link

@mlbridge mlbridge bot commented May 7, 2020

Webrevs

@openjdk
Copy link

@openjdk openjdk bot commented May 7, 2020

@mcimadamore This change now passes all automated pre-integration checks, type /integrate in a new comment to proceed. After integration, the commit message will be:

JDK-8244601: Cleanup support for upcall handles

Reviewed-by: sundar, jvernee
  • If you would like to add a summary, use the /summary command.
  • To credit additional contributors, use the /contributor command.
  • To add additional solved issues, use the /solves command.

There are currently no new commits on the foreign-abi branch since the last update of the source branch of this PR. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you would like to avoid potential automatic rebasing, specify the current head hash when integrating, like this: /integrate 023cac3726c9a5a4f8c83d59e912271ed649abb9.

➡️ To integrate this PR with the above commit message to the foreign-abi branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label May 7, 2020
Copy link
Member

@JornVernee JornVernee left a comment

Looks good!

@mcimadamore
Copy link
Collaborator Author

@mcimadamore mcimadamore commented May 7, 2020

/integrate

@openjdk openjdk bot closed this May 7, 2020
@openjdk openjdk bot added integrated and removed ready rfr labels May 7, 2020
@openjdk
Copy link

@openjdk openjdk bot commented May 7, 2020

@mcimadamore
Pushed as commit d8f37ce.

@mcimadamore mcimadamore deleted the callbackSegment branch May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants