Skip to content

Conversation

@tzezula
Copy link
Contributor

@tzezula tzezula commented Aug 18, 2024

The HotSpotJVMCIRuntime#getJObjectValue method is currently invoked in two distinct scenarios:

Truffle Compiler: In this scenario, the method is called by a Truffle compiler thread. This thread is an ordinary Java thread that enters the shared library compiler (libgraal) via a Java native method call. Consequently, it always has a valid JavaFrameAnchor when invoking HotSpotJVMCIRuntime#getJObjectValue within the shared library compiler.

Host Compiler: In the second scenario, the method is called by a HotSpot CompileBroker compiler thread while inlining a Truffle call target into a host method. Here, the compiler thread is a JavaThread in the _thread_in_vm state before entering the shared library compiler (libgraal) and does not have a JavaFrameAnchor.

The HotSpotJVMCIRuntime#getJObjectValue method currently supports only the first scenario by asserting that the caller has a JavaFrameAnchor. However, this method should be adapted to also support the second scenario, where the caller thread lacks a JavaFrameAnchor but has an explicitly pushed JNI handle block. It is crucial that the HotSpotJVMCIRuntime#getJObjectValue method ensures it does not use the top-most JNIHandleBlock, which is never released. Utilizing this block for Java constants could potentially lead to memory leaks in the Java heap. To accommodate both scenarios, the method should be modified to allow execution also by threads without a JavaFrameAnchor provided they have an explicitly pushed JNI handle block.

Implementation Details: The method determines whether the caller thread has pushed a JNI handle block by using THREAD->active_handles()->pop_frame_link(). The pop_frame_link is set when JavaThread::push_jni_handle_block is called and is reset in JavaThread::pop_jni_handle_block. Each active JavaThread has a non-null _active_handles pointer, which is initialized in JavaThread::run.


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-8338538: [JVMCI] Allow HotSpotJVMCIRuntime#getJObjectValue to be called by a HotSpot CompileBroker compiler thread (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20620

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 18, 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 Aug 18, 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:

8338538: [JVMCI] Allow HotSpotJVMCIRuntime#getJObjectValue to be called by a HotSpot CompileBroker compiler thread

Reviewed-by: dnsimon

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 70 new commits pushed to the master branch:

  • 3f00da8: 8338906: Avoid passing EnumDescs and extra classes to type switch methods that don't use them
  • e63418e: 8338979: Avoid bootstrapped switches in the classfile API
  • 20d8f58: 8331671: Implement JEP 472: Prepare to Restrict the Use of JNI
  • ce83f6a: 8338844: C2: remove useless code in PhaseIdealLoop::place_outside_loop() after 8335709
  • 0c14579: 8336830: C2: assert(get_loop(lca)->_nest < n_loop->_nest || lca->in(0)->is_NeverBranch()) failed: must not be moved into inner loop
  • 5671f83: 8338785: The java.awt.datatransfer.SystemFlavorMap#FLAVOR_MAP_KEY field is not used
  • 32b3d70: 8338925: ProblemList runtime/interpreter/LastJsrTest.java on linux-all
  • 5d12ac3: 8337715: Update --release 23 symbol information for JDK 23 build 37
  • 23dc3b0: 8324048: (fc) Make FileKey fields final
  • a461369: 8338700: AttributeMapper type parameter should be bounded by Attribute
  • ... and 60 more: https://git.openjdk.org/jdk/compare/8635642dbdfb74d2ae50a51611fd2c5980fe6e74...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 (@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 changed the title JDK-8338538: [JVMCI] Allow HotSpotJVMCIRuntime#getJObjectValue to be called by host compiler threads. 8338538: [JVMCI] Allow HotSpotJVMCIRuntime#getJObjectValue to be called by host compiler threads. Aug 18, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 18, 2024
@openjdk
Copy link

openjdk bot commented Aug 18, 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 Aug 18, 2024
@mlbridge
Copy link

mlbridge bot commented Aug 18, 2024

Webrevs

@openjdk
Copy link

openjdk bot commented Aug 18, 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-8338538
$ 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 Aug 18, 2024
Co-authored-by: Douglas Simon <doug.simon@oracle.com>
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Aug 18, 2024
@tzezula tzezula changed the title 8338538: [JVMCI] Allow HotSpotJVMCIRuntime#getJObjectValue to be called by host compiler threads. 8338538: [JVMCI] Allow HotSpotJVMCIRuntime#getJObjectValue to be called by a HotSpot CompileBroker compiler thread. Aug 19, 2024
@tzezula tzezula changed the title 8338538: [JVMCI] Allow HotSpotJVMCIRuntime#getJObjectValue to be called by a HotSpot CompileBroker compiler thread. 8338538: [JVMCI] Allow HotSpotJVMCIRuntime#getJObjectValue to be called by a HotSpot CompileBroker compiler thread Aug 19, 2024
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 26, 2024
@tzezula
Copy link
Contributor Author

tzezula commented Aug 26, 2024

/integrate

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

openjdk bot commented Aug 26, 2024

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

@dougxc
Copy link
Member

dougxc commented Aug 26, 2024

/sponsor

@openjdk
Copy link

openjdk bot commented Aug 26, 2024

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

  • 3f00da8: 8338906: Avoid passing EnumDescs and extra classes to type switch methods that don't use them
  • e63418e: 8338979: Avoid bootstrapped switches in the classfile API
  • 20d8f58: 8331671: Implement JEP 472: Prepare to Restrict the Use of JNI
  • ce83f6a: 8338844: C2: remove useless code in PhaseIdealLoop::place_outside_loop() after 8335709
  • 0c14579: 8336830: C2: assert(get_loop(lca)->_nest < n_loop->_nest || lca->in(0)->is_NeverBranch()) failed: must not be moved into inner loop
  • 5671f83: 8338785: The java.awt.datatransfer.SystemFlavorMap#FLAVOR_MAP_KEY field is not used
  • 32b3d70: 8338925: ProblemList runtime/interpreter/LastJsrTest.java on linux-all
  • 5d12ac3: 8337715: Update --release 23 symbol information for JDK 23 build 37
  • 23dc3b0: 8324048: (fc) Make FileKey fields final
  • a461369: 8338700: AttributeMapper type parameter should be bounded by Attribute
  • ... and 60 more: https://git.openjdk.org/jdk/compare/8635642dbdfb74d2ae50a51611fd2c5980fe6e74...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 26, 2024
@openjdk openjdk bot closed this Aug 26, 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 Aug 26, 2024
@openjdk
Copy link

openjdk bot commented Aug 26, 2024

@dougxc @tzezula Pushed as commit a15af69.

💡 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.

2 participants