Skip to content

Conversation

@fisk
Copy link
Contributor

@fisk fisk commented Jan 10, 2023

When raw char* String contents are exposed to JNI code, we

  1. Load the string.value and pin it
  2. Run native code
  3. Load the string.value and unpin it

Given this sequence we would be in trouble if between 1 and 3, string deduplication changed the value object. Then the pinning and unpinning wouldn't be balanced.

The current approach for dealing with this is to have a bunch of code to guard against deduplication. An alternative simpler solution is to just change step 3 to pass in the same value. We already have enough information available to do that. Then the pinning and unpinning is also balanced, and we don't need to have any special interactions with string deduplication and can decouple these orthogonal concerns.

It's worth noting though that the contract of pin_object now makes it explicit that pinned objects must not be recycled, even if not otherwise reachable. That seems to come naturally for region based pinning, but is worth keeping in mind. The exposed char* might be the only thing referencing the string value when string dedup happens concurrently.


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-8299673: Simplify object pinning interactions with string deduplication

Reviewers

Contributors

  • Stefan Karlsson <stefank@openjdk.org>
  • Axel Boldt-Christmas <aboldtch@openjdk.org>

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11923

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 10, 2023

👋 Welcome back eosterlund! 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 openjdk bot added the rfr Pull request is ready for review label Jan 10, 2023
@openjdk
Copy link

openjdk bot commented Jan 10, 2023

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

  • hotspot
  • shenandoah

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 hotspot hotspot-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Jan 10, 2023
@mlbridge
Copy link

mlbridge bot commented Jan 10, 2023

Webrevs

@fisk
Copy link
Contributor Author

fisk commented Jan 10, 2023

/contributor add @stefank

@openjdk
Copy link

openjdk bot commented Jan 10, 2023

@fisk
Contributor Stefan Karlsson <stefank@openjdk.org> successfully added.

@fisk
Copy link
Contributor Author

fisk commented Jan 10, 2023

/contributor add @xmas92

@openjdk
Copy link

openjdk bot commented Jan 10, 2023

@fisk
Contributor Axel Boldt-Christmas <aboldtch@openjdk.org> successfully added.

Copy link

@kimbarrett kimbarrett 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.

@openjdk
Copy link

openjdk bot commented Jan 11, 2023

@fisk 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:

8299673: Simplify object pinning interactions with string deduplication

Co-authored-by: Stefan Karlsson <stefank@openjdk.org>
Co-authored-by: Axel Boldt-Christmas <aboldtch@openjdk.org>
Reviewed-by: kbarrett, stefank, dholmes

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

  • f52f6e6: 8299972: Remove metaprogramming/removeReference.hpp
  • 4c1e66e: 8299971: Remove metaprogramming/conditional.hpp
  • 4073b68: 8298047: Remove all non-significant trailing whitespace from properties files
  • 506c818: 8296401: ConcurrentHashTable::bulk_delete might miss to delete some objects
  • 319de6a: 8300124: Remove unnecessary assert in GenCollectedHeap::initialize
  • 289aed4: 8298128: runtime/ErrorHandling/TestSigInfoInHsErrFile.java fails to find pattern with slowdebug
  • a2f6766: 8288415: java/awt/PopupMenu/PopupMenuLocation.java is unstable in MacOS machines

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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.

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

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 11, 2023
Comment on lines 26 to 27
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcHeapSummary.hpp"
Copy link
Member

Choose a reason for hiding this comment

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

Sort order

@fisk
Copy link
Contributor Author

fisk commented Jan 13, 2023

Thank you for the reviews, @kimbarrett and @stefank!

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Initially I was a bit unsure about the conceptual model here, as I was thinking that pinning is a very general concept, where in fact it only relates to these JNI "critical" functions. So in that sense every GC must support pinning as required by those functions, so this simplification looks very neat. Thanks.

@fisk
Copy link
Contributor Author

fisk commented Jan 17, 2023

Thanks for the review, @dholmes-ora!

@fisk
Copy link
Contributor Author

fisk commented Jan 17, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Jan 17, 2023

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

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 17, 2023
@openjdk openjdk bot closed this Jan 17, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 17, 2023
@openjdk
Copy link

openjdk bot commented Jan 17, 2023

@fisk Pushed as commit 9a36f8a.

💡 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

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

Development

Successfully merging this pull request may close these issues.

4 participants