Skip to content

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

Closed
coleenp wants to merge 2 commits intoopenjdk:masterfrom
coleenp:jint
Closed

8256306: ObjectMonitor::_contentions field should not be 'jint'#3980
coleenp wants to merge 2 commits intoopenjdk:masterfrom
coleenp:jint

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

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org hotspot-runtime hotspot-runtime-dev@openjdk.org labels May 11, 2021
@bridgekeeper
Copy link

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 June 21, 2021 15:11
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 21, 2021
@mlbridge
Copy link

mlbridge bot commented Jun 21, 2021

Webrevs

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.

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) {
Copy link
Member

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

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

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

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 Jun 22, 2021
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.

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

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

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.

// 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

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
Member

@dcubed-ojdk dcubed-ojdk left a comment

Choose a reason for hiding this comment

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

Re-reviewed v01 incremental. Thumbs up!

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.

Looks good!

Good catch on the padding @dcubed-ojdk !

Thanks,
David

@coleenp
Copy link
Contributor Author

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

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Jun 23, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 23, 2021
@openjdk
Copy link

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 June 23, 2021 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Development

Successfully merging this pull request may close these issues.

4 participants