-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Conversation
👋 Welcome back coleenp! A progress list of the required criteria for merging this PR into |
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())); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
delta_as_int() could also be: delta2int() ptrdelta2int() ptrdiff2int() ptrsub2int() in the theme of shorter names. Brainstorming in a PR. Your suggestions welcome. |
…gative case to just do checked_cast.
There was a problem hiding this 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))); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, 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 42 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 |
There was a problem hiding this 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.
Thanks Ioi and Fred and Stefan for suggestions. |
Going to push as commit 9f46fc2.
Your commit was automatically rebased without conflicts. |
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
Issue
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