Skip to content

Conversation

@tzezula
Copy link
Contributor

@tzezula tzezula commented Oct 1, 2024

JDK-8318694 limited the ability for JVMCI CompilerThreads to make Java upcalls. This is to mitigate against deadlock when an upcall does class loading. Class loading can easily create deadlock situations in -Xcomp or -Xbatch mode.

However, for Truffle, upcalls are unavoidable if Truffle partial evaluation occurs as part of JIT compilation inlining. This occurs when the Graal inliner sees a constant Truffle AST node which allows a Truffle-specific inlining extension to perform Truffle partial evaluation (PE) on the constant. Such PE involves upcalls to the Truffle runtime (running in Java).

This PR provides the escape hatch such that Truffle specific logic can put a compiler thread into "allow Java upcall" mode during the scope of the Truffle logic.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8340733: Add scope for relaxing constraint on JavaCalls from CompilerThread (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21285/head:pull/21285
$ git checkout pull/21285

Update a local copy of the PR:
$ git checkout pull/21285
$ git pull https://git.openjdk.org/jdk.git pull/21285/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 21285

View PR using the GUI difftool:
$ git pr show -t 21285

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21285.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 1, 2024

👋 Welcome back tzezula! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 1, 2024

@tzezula This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8340733: Add scope for relaxing constraint on JavaCalls from CompilerThread

Reviewed-by: dnsimon, kvn

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 418 new commits pushed to the master branch:

  • f77a514: 8343194: Avoid redundant Hashtable.containsKey call in CodeSource.readObject
  • 4a70c83: 8343378: Exceptions in javax/management DeadLockTest.java do not cause test failure
  • 8d4d589: 8343297: Vector unsigned min/max test are failing with -Xcomp
  • 2a4d9d9: 8343379: [BACKOUT] 8343190 GHA: Try building JTReg several times
  • 6f6cfe6: 8343380: C2: assert(iff->in(1)->is_OpaqueNotNull()) failed: must be OpaqueNotNull
  • cbda758: 8343122: RISC-V: C2: Small improvement for real runtime callouts
  • 803612e: 8343121: RISC-V: More accurate max size for C2SafepointPollStub and C2EntryBarrierStub
  • b627a41: 8343345: Use -jvmArgsPrepend when running microbenchmarks in RunTests.gmk
  • 2932144: 8343305: Remove Indify-dependent microbenchmarks
  • 34655c6: 8342544: [macos] jpackage test helper should check for both "--app-image" and "--mac-sign" for signing predefined app image case
  • ... and 408 more: https://git.openjdk.org/jdk/compare/0b467e902d591ae9feeec1669918d1588987cd1c...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@vnkozlov, @dougxc) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 1, 2024
@openjdk
Copy link

openjdk bot commented Oct 1, 2024

@tzezula The following labels will be automatically applied to this pull request:

  • graal
  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added graal graal-dev@openjdk.org hotspot-compiler hotspot-compiler-dev@openjdk.org labels Oct 1, 2024
@mlbridge
Copy link

mlbridge bot commented Oct 1, 2024

Webrevs

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`/compiler' part of changes is fine.

@openjdk
Copy link

openjdk bot commented Oct 1, 2024

⚠️ @tzezula the full name on your profile does not match the author name in this pull requests' HEAD commit. If this pull request gets integrated then the author name from this pull requests' HEAD commit will be used for the resulting commit. If you wish to push a new commit with a different author name, then please run the following commands in a local repository of your personal fork:

$ git checkout JDK-8340733
$ git commit --author='Preferred Full Name <you@example.com>' --allow-empty -m 'Update full name'
$ git push

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 1, 2024
@openjdk
Copy link

openjdk bot commented Oct 4, 2024

@tzezula Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Oct 4, 2024
@tzezula
Copy link
Contributor Author

tzezula commented Oct 4, 2024

I have simplified the _can_call_java transitions. The only feature in the libjvmci compiler that requires Java calls is Truffle compiler, which utilizes JNI to invoke the Truffle runtime methods. Given that we now have CompilerThreadCanCallJavaScope, which Truffle can use to explicitly enable Java calls, we can safely disable Java calls by default for the libjvmci compiler.

For the Java JVMCI compiler, we still need to permit Java calls to accommodate upcalls to the Graal compiler and for InterpreterRuntime while running the Java JVMCI compiler.

The simplification eliminates the need for TriBool for _can_call_java; it can remain a bool.

Copy link
Member

@dougxc dougxc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 10, 2024
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Oct 31, 2024
Copy link
Member

@dougxc dougxc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still look good to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 31, 2024
@tzezula
Copy link
Contributor Author

tzezula commented Nov 1, 2024

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Nov 1, 2024
@openjdk
Copy link

openjdk bot commented Nov 1, 2024

@tzezula
Your change (at version 7e0f1a4) is now ready to be sponsored by a Committer.

@dougxc
Copy link
Member

dougxc commented Nov 1, 2024

/sponsor

@openjdk
Copy link

openjdk bot commented Nov 1, 2024

Going to push as commit 751a914.
Since your change was applied there have been 420 commits pushed to the master branch:

  • 7e87c07: 8340116: test/jdk/sun/security/tools/jarsigner/PreserveRawManifestEntryAndDigest.java can fail due to regex
  • da0e9e3: 8343333: Parallel: Cleanup comment referring Solaris in MutableNUMASpace
  • f77a514: 8343194: Avoid redundant Hashtable.containsKey call in CodeSource.readObject
  • 4a70c83: 8343378: Exceptions in javax/management DeadLockTest.java do not cause test failure
  • 8d4d589: 8343297: Vector unsigned min/max test are failing with -Xcomp
  • 2a4d9d9: 8343379: [BACKOUT] 8343190 GHA: Try building JTReg several times
  • 6f6cfe6: 8343380: C2: assert(iff->in(1)->is_OpaqueNotNull()) failed: must be OpaqueNotNull
  • cbda758: 8343122: RISC-V: C2: Small improvement for real runtime callouts
  • 803612e: 8343121: RISC-V: More accurate max size for C2SafepointPollStub and C2EntryBarrierStub
  • b627a41: 8343345: Use -jvmArgsPrepend when running microbenchmarks in RunTests.gmk
  • ... and 410 more: https://git.openjdk.org/jdk/compare/0b467e902d591ae9feeec1669918d1588987cd1c...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 1, 2024
@openjdk openjdk bot closed this Nov 1, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Nov 1, 2024
@openjdk
Copy link

openjdk bot commented Nov 1, 2024

@dougxc @tzezula Pushed as commit 751a914.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

graal graal-dev@openjdk.org hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants