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

8310906: Fix -Wconversion warnings in runtime, oops and some code header files. #14675

Closed
wants to merge 5 commits into from

Conversation

coleenp
Copy link
Contributor

@coleenp coleenp commented Jun 27, 2023

This is another version of PR #14659 but I've added a pointer delta function in globalDefinitions.hpp to use for these pointer diff calculations that return int everywhere. If the name is agreeable, I'll fix the other cases of this like this. It's better than raw casts.
Tested with tier1-4.


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-8310906: Fix -Wconversion warnings in runtime, oops and some code header files. (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14675

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 27, 2023

👋 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 openjdk bot changed the title 8310906: Fix -Wconversion warnings in runtime, oops and some code header files 8310906: Fix -Wconversion warnings in runtime, oops and some code header files. Jun 27, 2023
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 27, 2023
@openjdk
Copy link

openjdk bot commented Jun 27, 2023

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

  • hotspot
  • 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 hotspot-dev@openjdk.org labels Jun 27, 2023
@mlbridge
Copy link

mlbridge bot commented Jun 27, 2023

Webrevs

@@ -33,7 +33,7 @@

inline const ImmutableOopMap* CodeBlob::oop_map_for_slot(int slot, address return_address) const {
assert(_oop_maps != nullptr, "nope");
return _oop_maps->find_map_at_slot(slot, (intptr_t) return_address - (intptr_t) code_begin());
return _oop_maps->find_map_at_slot(slot, delta_as_int((intptr_t) return_address, (intptr_t) code_begin()));
Copy link
Member

Choose a reason for hiding this comment

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

Is this the only usage of delta_as_int that operates on intptr_t? If we remove the casts then all usages would operate on pointers. Maybe this is an indication that we only need a pointer_delta_as_int function, to go hand in hand with the other pointer_delta functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm. Maybe this would be ok. Our original idea was to make it T* not T until this cast. I don't know how many other cases there are that I haven't gotten to yet. But it would eliminate a cast, so that's good (unless these aren't the same). Some instances have ptr - constant that gets promoted I think.
The reason we didn't pick pointer_delta_as_int because pointer_delta has different semantics. pointer_delta insists on positive results.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Taking out that cast does work, so I've fixed that.

Copy link
Member

Choose a reason for hiding this comment

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

pointer_delta has different semantics

Right. That was "recently" added to pointer_delta with JDK-8260046. It begs the question why felt the need to add it there but feel that it is OK to skip it for delta_as_int? Is there some usage of delta_as_int that gives back negative values? Could that call site be changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are sites where the result is negative but this is a good suggestion because it makes the name more consistent. I can change those to plain check_casts.

@coleenp
Copy link
Contributor Author

coleenp commented Jun 27, 2023

delta_as_int() could also be: delta2int() ptrdelta2int() ptrdiff2int() ptrsub2int() in the theme of shorter names.
pointer_delta_as_int() ignoring it does something different than pointer_delta() (allows negative returns).
Change them all to check_cast(a - b) - losing identifiable name
ptrdiff_cast(a - b) where int ptrdiff_cast(ptrdiff_t val) { return check(val); }

Brainstorming in a PR. Your suggestions welcome.

Copy link
Member

@iklam iklam left a comment

Choose a reason for hiding this comment

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

LGTM.

inline int delta_as_int(const volatile T* left, const volatile T* right) {
return checked_cast<int>(left - right);
inline int pointer_delta_as_int(const volatile T* left, const volatile T* right) {
return checked_cast<int>(pointer_delta(left, right, sizeof(T)));
Copy link
Member

Choose a reason for hiding this comment

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

For clarity, I think you should add a comment saying the returned value is always non-negative.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, thanks!

@openjdk
Copy link

openjdk bot commented Jun 28, 2023

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

8310906: Fix -Wconversion warnings in runtime, oops and some code header files.

Reviewed-by: iklam, fparain

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 42 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 28, 2023
Copy link
Contributor

@fparain fparain 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 to me.

@coleenp
Copy link
Contributor Author

coleenp commented Jun 28, 2023

Thanks Ioi and Fred and Stefan for suggestions.
/integrate

@openjdk
Copy link

openjdk bot commented Jun 28, 2023

Going to push as commit 9f46fc2.
Since your change was applied there have been 42 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 Jun 28, 2023
@openjdk openjdk bot closed this Jun 28, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 28, 2023
@openjdk
Copy link

openjdk bot commented Jun 28, 2023

@coleenp Pushed as commit 9f46fc2.

💡 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 serviceability serviceability-dev@openjdk.org
4 participants