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

8308088: Improve class check in CollectedHeap::is_oop #13982

Closed

Conversation

shipilev
Copy link
Member

@shipilev shipilev commented May 15, 2023

See the bug for more details.

Additional testing:

  • Linux x86_64 fastdebug, tier1
  • Linux x86_64 fastdebug, tier2
  • Linux x86_64 fastdebug, tier3

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-8308088: Improve class check in CollectedHeap::is_oop

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13982

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 15, 2023

👋 Welcome back shade! 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 May 15, 2023

@shipilev The following label will be automatically applied to this pull request:

  • hotspot-gc

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

@openjdk openjdk bot added the hotspot-gc hotspot-gc-dev@openjdk.org label May 15, 2023
@shipilev shipilev force-pushed the JDK-8308088-is-oop-klass-check branch from b70d1b5 to b3b4144 Compare May 15, 2023 14:22
@shipilev shipilev changed the title 8308088: Improve klass check in CollectedHeap::is_oop 8308088: Improve class check in CollectedHeap::is_oop May 15, 2023
@shipilev shipilev marked this pull request as ready for review May 15, 2023 18:31
@openjdk openjdk bot added the rfr Pull request is ready for review label May 15, 2023
@mlbridge
Copy link

mlbridge bot commented May 15, 2023

Webrevs

@openjdk
Copy link

openjdk bot commented May 15, 2023

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

8308088: Improve class check in CollectedHeap::is_oop

Reviewed-by: zgu, tschatzl, ayang, stuefe

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 28 new commits pushed to 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 May 15, 2023
Copy link
Contributor

@zhengyu123 zhengyu123 left a comment

Choose a reason for hiding this comment

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

Wait, you are calling k->is_klass() here, you do need acquire here.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label May 15, 2023
@shipilev
Copy link
Member Author

shipilev commented May 15, 2023

Wait, you are calling k->is_klass() here, you do need acquire here.

Oh. is_klass is v-call, okay. Good catch! Actually, let's just avoid checking for is_klass here, instead of making this method carry additional memory order semantics. This would make the method lighter (= more performance for debug builds), and would prevent assert(is_oop(...)) hiding memory ordering bugs in debug mode accidentally.

Copy link
Contributor

@zhengyu123 zhengyu123 left a comment

Choose a reason for hiding this comment

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

LGTM

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 16, 2023
Copy link
Member

@tstuefe tstuefe left a comment

Choose a reason for hiding this comment

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

This can be improved:

  • klass_raw() will, eventually, end up doing some asserts. We don't want that. So narrow Klass extraction needs to be done separately.
  • then, we could weed out obvious bogus Klass values (not aligned or null)
  • then, Metaspace::contains checks class space and non-class metaspace. The latter would be a false positive, and its also more expensive, since it walks the (usually short) list of metaspace regions. class space otoh is just one region. A correct check for Klass would be to check if its in CDS or in class space.

Proposal sketch:
b8868da

@tstuefe
Copy link
Member

tstuefe commented May 16, 2023

This can be improved:

* klass_raw() will, eventually, end up doing some asserts. We don't want that. So narrow Klass extraction needs to be done separately.

* then, we could weed out obvious bogus Klass values (not aligned or null)

* then, Metaspace::contains checks class space and non-class metaspace. The latter would be a false positive, and its also more expensive, since it walks the (usually short) list of metaspace regions. class space otoh is just one region. A correct check for Klass would be to check if its in CDS or in class space.

Proposal sketch: b8868da

Update: looks like I was mistaken about the first point. The rest is probably not worth optimizing. Never mind then, this looks good as it is.

Copy link
Member

@tstuefe tstuefe left a comment

Choose a reason for hiding this comment

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

include memory/metaspace.hpp is missing.

Otherwise LGTM

@shipilev
Copy link
Member Author

Thanks for reviews! I am integrating now.

/integrate

@openjdk
Copy link

openjdk bot commented May 17, 2023

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

  • e34ecc9: 8296469: Instrument VMError::report with reentrant iteration step for register and stack printing
  • 5a92aae: 8308156: VerifyCACerts.java misses blank in error output
  • 2f1c654: 8307955: Prefer to PTRACE_GETREGSET instead of PTRACE_GETREGS in method 'ps_proc.c::process_get_lwp_regs'
  • d3e5065: 8306460: Clear JVM_ACC_QUEUED flag on methods when dumping dynamic CDS archive
  • 563152f: 8308223: failure handler missed jcmd.vm.info command
  • cb8b8cd: 8307458: Add periodic heap usage JFR events
  • f9a785e: 8307547: Support variant collations
  • 4e92991: 8300794: Use @snippet in java.util:i18n
  • 64d5157: 8306467: Fix nsk/jdb/kill/kill001 to work with new JVMTI StopThread support for virtual threads.
  • 488330d: 8307533: Use atomic bitset functions for metadata flags
  • ... and 24 more: https://git.openjdk.org/jdk/compare/97b2ca3de76046c6f52d3649d8787feea7b9ac83...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented May 17, 2023

@shipilev Pushed as commit b300e73.

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

@shipilev shipilev deleted the JDK-8308088-is-oop-klass-check branch August 10, 2023 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-gc hotspot-gc-dev@openjdk.org integrated Pull request has been integrated
5 participants