8256306: ObjectMonitor::_contentions field should not be 'jint'#3980
8256306: ObjectMonitor::_contentions field should not be 'jint'#3980coleenp wants to merge 2 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back coleenp! A progress list of the required criteria for merging this PR into |
|
@coleenp The following labels will be automatically applied to this pull request:
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. |
|
@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! |
Webrevs
|
dholmes-ora
left a comment
There was a problem hiding this comment.
Looks fine apart from use of INT32_MIN instead of INT_MIN.
Thanks,
David
| // 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) { |
There was a problem hiding this comment.
INT_MIN
Do we really need the cast on 0?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
|
@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: 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
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 |
| 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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
| // 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) { |
There was a problem hiding this comment.
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.
|
Thank you David, Dan and Thomas. There are a few other jlongs hanging around in that file, but that's for another day. |
|
Going to push as commit f3ba269.
Your commit was automatically rebased without conflicts. |
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
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3980/head:pull/3980$ git checkout pull/3980Update a local copy of the PR:
$ git checkout pull/3980$ git pull https://git.openjdk.java.net/jdk pull/3980/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 3980View PR using the GUI difftool:
$ git pr show -t 3980Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3980.diff