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

8256306: ObjectMonitor::_contentions field should not be 'jint' #3980

Closed
wants to merge 2 commits into from

Conversation

@coleenp
Copy link
Contributor

@coleenp coleenp commented May 11, 2021

I changed the _contentions and _waiters fields from jint to int and ran tests tier1-3. Tested tier1 with linux, mac, windows platforms. Also changed the _previous_owner_tid to unintptr_t from jlong, since that's what the cast did.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8256306: ObjectMonitor::_contentions field should not be 'jint'

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3980/head:pull/3980
$ git checkout pull/3980

Update a local copy of the PR:
$ git checkout pull/3980
$ git pull https://git.openjdk.java.net/jdk pull/3980/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3980

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3980.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented May 11, 2021

👋 Welcome back coleenp! 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 openjdk bot commented May 11, 2021

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

  • hotspot-runtime
  • serviceability

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.

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jun 8, 2021

@coleenp This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@coleenp coleenp marked this pull request as ready for review Jun 21, 2021
@openjdk openjdk bot added the rfr label Jun 21, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Jun 21, 2021

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Looks fine apart from use of INT32_MIN instead of INT_MIN.

Thanks,
David

src/hotspot/share/runtime/objectMonitor.cpp Outdated Show resolved Hide resolved
@@ -572,7 +572,7 @@ bool ObjectMonitor::deflate_monitor() {

// Make a zero contentions field negative to force any contending threads
// to retry. This is the second part of the async deflation dance.
if (Atomic::cmpxchg(&_contentions, (jint)0, -max_jint) != 0) {
if (Atomic::cmpxchg(&_contentions, (int)0, INT32_MIN) != 0) {
Copy link
Member

@dholmes-ora dholmes-ora Jun 21, 2021

Choose a reason for hiding this comment

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

INT_MIN

Do we really need the cast on 0?

Copy link
Member

@dcubed-ojdk dcubed-ojdk Jun 22, 2021

Choose a reason for hiding this comment

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

The original cast of (jint)0 was to get the right cmpxchg() selected.
I think that with the switch to INT32_MIN, a regular 0 instead of (int)0
should compile.

Copy link
Contributor Author

@coleenp coleenp Jun 22, 2021

Choose a reason for hiding this comment

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

Yes, changing to INT_MIN is more correct and I don't need the cast to int now for zero. Recompiling on all platforms, including the picky ones for verification. Thanks!

@openjdk
Copy link

@openjdk openjdk bot commented Jun 22, 2021

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

8256306: ObjectMonitor::_contentions field should not be 'jint'

Reviewed-by: dholmes, stuefe, dcubed

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

  • 0c693e2: 8268290: Improve LockFreeQueue<> utility
  • 33c23a1: 8264941: Remove CodeCache::mark_for_evol_deoptimization() method
  • 18a1dd2: 8269031: linux x86_64 check for binutils 2.25 or higher after 8265783
  • 2e639dd: 8267657: Add missing PrintC1Statistics before incrementing counters
  • 1f0ea7c: 8268857: Merge VM_PrintJNI and VM_PrintThreads and remove the unused field 'is_deadlock' of DeadlockCycle
  • 1a81815: 8269077: TestSystemGC uses "require vm.gc.G1" for large pages subtest
  • 0458113: Merge
  • d3ad8cd: 8268672: C2: assert(!loop->is_member(u_loop)) failed: can be in outer loop or out of both loops only
  • f25e719: 8268717: Upstream: 8268673: Stack walk across optimized entry frame on fresh native thread fails
  • 22ebd19: 8268362: [REDO] C2 crash when compile negative Arrays.copyOf length after loop
  • ... and 3 more: https://git.openjdk.java.net/jdk/compare/cd20c01942dd8559a31e51ef2a595c6eba44b8ad...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.

➡️ 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 label Jun 22, 2021
Copy link
Member

@tstuefe tstuefe left a comment

LGTM

intptr_t ret_code = intptr_t(_waiters) | intptr_t(_cxq) | intptr_t(_EntryList);
int cnts = contentions(); // read once
if (cnts > 0) {
ret_code |= intptr_t(cnts);
Copy link
Member

@tstuefe tstuefe Jun 22, 2021

Choose a reason for hiding this comment

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

I know it has nothing to do with your patch, but I am just curious. IIUC this is a strange way of saying "if A!=0 || B!=0 || C!=0..." . Is this for performance reasons? Also, why the "if (cnts > 0)", would that not be superfluous?

Copy link
Contributor Author

@coleenp coleenp Jun 22, 2021

Choose a reason for hiding this comment

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

I think this code exists like this from when is_busy returned an uintptr_t. It should be nicely rewritten with if != 0s now and likely would have better performance. I won't do it with this change because these fields are volatile and I think should have Atomic::loads, which would lead to a lot of discussion that should happen independently. I'll file an RFE.

@@ -572,7 +572,7 @@ bool ObjectMonitor::deflate_monitor() {

// Make a zero contentions field negative to force any contending threads
// to retry. This is the second part of the async deflation dance.
if (Atomic::cmpxchg(&_contentions, (jint)0, -max_jint) != 0) {
if (Atomic::cmpxchg(&_contentions, (int)0, INT32_MIN) != 0) {
Copy link
Member

@dcubed-ojdk dcubed-ojdk Jun 22, 2021

Choose a reason for hiding this comment

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

The original cast of (jint)0 was to get the right cmpxchg() selected.
I think that with the switch to INT32_MIN, a regular 0 instead of (int)0
should compile.

src/hotspot/share/runtime/objectMonitor.hpp Show resolved Hide resolved
Copy link
Member

@dcubed-ojdk dcubed-ojdk left a comment

Re-reviewed v01 incremental. Thumbs up!

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Looks good!

Good catch on the padding @dcubed-ojdk !

Thanks,
David

@coleenp
Copy link
Contributor Author

@coleenp coleenp commented Jun 23, 2021

Thank you David, Dan and Thomas. There are a few other jlongs hanging around in that file, but that's for another day.
/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Jun 23, 2021

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

  • 52d5d1b: 8269188: [BACKOUT] Remove CodeCache::mark_for_evol_deoptimization() method
  • f2e690e: 8268720: Unspecified checks on NameAndType constants should not be performed
  • 2c29d79: 8269206: A small typo in comment in test/lib/sun/hotspot/WhiteBox.java
  • 6237630: 8269120: Build failure with GCC 6.3.0 after JDK-8017163
  • a5e4307: 8269134: Remove sparsePRT.inline.hpp after JDK-8017163
  • 17daf32: 8269138: Move typeArrayOop.inline.hpp include to vectorSupport.cpp
  • 36d82b6: 8268858: Determine register pressure automatically by the number of available registers for allocation
  • ae3eedc: 8268727: Remove unused slowpath locking method in OptoRuntime
  • cd678a3: 8268368: Adopt cast notation for JavaThread conversions
  • b6cfca8: Merge
  • ... and 23 more: https://git.openjdk.java.net/jdk/compare/cd20c01942dd8559a31e51ef2a595c6eba44b8ad...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Jun 23, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Jun 23, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jun 23, 2021

@coleenp Pushed as commit f3ba269.

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

@coleenp coleenp deleted the jint branch Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants