-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8308850: Change JVM options with small ranges that get -Wconversion warnings to 32 bits #15164
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
Conversation
|
👋 Welcome back azafari! A progress list of the required criteria for merging this PR into |
|
@afshin-zafari 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. |
Webrevs
|
| "switch") \ | ||
| \ | ||
| develop(intx, StopInterpreterAt, 0, \ | ||
| develop(int, StopInterpreterAt, 0, \ |
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.
Some cpu ports access this from assembly, so changing the size is gong to require cpu-specific changes. I'd rather see this and BytecodeCounter::_counter_value both changed to uint64_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.
share/interpreter/bytecodeHistogram.cpp:int BytecodeCounter::_counter_value = 0;
Maybe this should be inx instead.
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.
The only reason to use intx is if this should be 32-bit on 32-bit and 64-bit on 64-bit. I don't think that is the case here.
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.
The reason that this should be reverted is that to fix it, you have to fix all the platform code and that seems out of scope for fixing Wconversion warnings.
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.
Actually this counts bytecodes, so it could easily become 64 bit on 64 bit platforms.
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.
This is complicated. BytecodeCounter::_counter_value is an int, and StopInterpreterAt compares to that in shared code, which is fine because it'll promote the former to intx. The cpu-specific code fetches the former as int and the latter as intx, except in one place so fixing either is going to be work. The one place that complains on x86 is
src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp:1865:12: warning: conversion from 'intx' {aka 'long int'} to 'int32_t' {aka 'int'} may change value [-Wconversion]
1865 | StopInterpreterAt,
| ^~~~~~~~~~~~~~~~~
__ cmp32(ExternalAddress((address) &BytecodeCounter::_counter_value),
StopInterpreterAt,
rscratch1);
We could just static_cast StopInterpreterAt to int here.
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.
Actually this counts bytecodes, so it could easily become 64 bit on 64 bit platforms.
I thought this was the count within a method, in which case the bytecode limit is the same for 32-bit and 64-bit.
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.
It is not.
src/hotspot/share/opto/macro.cpp
Outdated
| uint step_size = AllocatePrefetchStepSize; | ||
| uint distance = AllocatePrefetchDistance; | ||
| int step_size = AllocatePrefetchStepSize; | ||
| int distance = AllocatePrefetchDistance; |
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.
I think this is a step in the wrong direction. Shouldn't these remain uint?
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.
This change also doesn't fit the PR description. There is no need to change this in this PR (or even at all).
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.
Okay. Reverted back.
|
I know HotSpot code is not very careful about distinguishing between int and uint, but shouldn't we prefer uint for values that can't be negative? The disadvantage of uint though is will we get more -Wsign-conversion warnings to fix when that warning gets turned on. |
|
The argument checking code gives a nice error if you pass a negative value for a parameter in the range of 0 .. positive-number if the argument is an int, and a bad one if the argument is uint. That's why in previous changes, I've preferred changing to int. We could file an RFE to improve the error message though. I don't know how hard that would be to fix. |
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.
I think the basic change from intx to int is sound - there is no reason for these flags to have a different size depending on the platform. But you need to check any other references to these flags (e.g. printing) are changed appropriately.
The issue of signed versus unsigned is a topic for a different day IMO.
Thanks.
src/hotspot/share/opto/macro.cpp
Outdated
| uint step_size = AllocatePrefetchStepSize; | ||
| uint distance = AllocatePrefetchDistance; | ||
| int step_size = AllocatePrefetchStepSize; | ||
| int distance = AllocatePrefetchDistance; |
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.
This change also doesn't fit the PR description. There is no need to change this in this PR (or even at all).
src/hotspot/share/opto/macro.cpp
Outdated
| int step_size = AllocatePrefetchStepSize; | ||
| int distance = AllocatePrefetchDistance; |
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.
Ditto no need to change
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.
Okay.
Reverted back.
| "switch") \ | ||
| \ | ||
| develop(intx, StopInterpreterAt, 0, \ | ||
| develop(int, StopInterpreterAt, 0, \ |
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.
The only reason to use intx is if this should be 32-bit on 32-bit and 64-bit on 64-bit. I don't think that is the case here.
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.
This looks good with the minor issue of removing a blank space.
| "switch") \ | ||
| \ | ||
| develop(intx, StopInterpreterAt, 0, \ | ||
| develop(intx, StopInterpreterAt, 0, \ |
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.
Does this add a blank? Should be aligned.
|
@afshin-zafari 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 25 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 |
|
Hi, I thought you were going to change this one too: LogEventsBufferEntries ? |
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.
I only checked the last two flags but in both cases found related changes. Please make sure all the uses of these flags has been checked. Thanks.
| product(int, PerfDataSamplingInterval, 50, \ | ||
| "Data sampling interval (in milliseconds)") \ | ||
| range(PeriodicTask::min_interval, max_jint) \ | ||
| constraint(PerfDataSamplingIntervalFunc, AfterErgo) \ |
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.
You need to change the type of the PerfDataSamplingIntervalFunc as well.
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.
I changed this and checked for the other options I changed.
| "Hit breakpoint when mallocing/freeing this pointer") \ | ||
| \ | ||
| develop(intx, StackPrintLimit, 100, \ | ||
| develop(int, StackPrintLimit, 100, \ |
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.
You can remove this cast now:
./share/utilities/vmError.cpp: const int limit = max_frames == -1 ? StackPrintLimit : MIN2(max_frames, (int)StackPrintLimit);
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.
Fixed.
|
@afshin-zafari this pull request can not be integrated into git checkout wconv_jvm_options
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
|
I also changed the type of LogEventsBufferEntries in |
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.
Updates look good.
Thanks
| "Enable the various ring buffer event logs") \ | ||
| \ | ||
| product(uintx, LogEventsBufferEntries, 20, DIAGNOSTIC, \ | ||
| product(int, LogEventsBufferEntries, 20, DIAGNOSTIC, \ |
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.
I was going to say this should keep its unsignedness but it is treated as an int everywhere anyway.
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.
Just noticed that AllocatePrefetchStyle should also be included in this.
Thanks
|
The criteria for choosing flags was whether they were causing -Wconversion warnings, which this one doesn't. That said, it would be consistent to change this one since other AllocatePrefetch flags are changed. There are likely many other flags that can be int not intx. They can be changed in a different patch. |
There is nothing in the PR or JBS to indicate this is the case. I assumed this would fix all oversized flags as the title indicates. If this is only a restricted subset perhaps the title and description should be updated to reflect that. Thanks. |
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.
Still good.
| do_int_flag(AllocateInstancePrefetchLines) \ | ||
| do_int_flag(AllocatePrefetchDistance) \ | ||
| do_intx_flag(AllocatePrefetchInstr) \ | ||
| do_intx_flag(AllocatePrefetchLines) \ | ||
| do_intx_flag(AllocatePrefetchStepSize) \ | ||
| do_intx_flag(AllocatePrefetchStyle) \ | ||
| do_int_flag(AllocatePrefetchLines) \ | ||
| do_int_flag(AllocatePrefetchStepSize) \ | ||
| do_int_flag(AllocatePrefetchStyle) \ |
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.
Why is AllocatePrefetchInstr not changed? It seems to use 0-3 only.
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 like from the constraints, it's allowed to be max_intx on some platforms, so changing this would be a functional change.
JVMFlag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) {
intx max_value = max_intx;
#if defined(X86)
max_value = 3;
#endif
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.
OK, that sounds reasonable.
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.
Fwiw, only x86 uses AllocatePrefetchInstr. Other platforms never use it, so its value for those is meaningless.
|
Thank you Coleen, Dean, David, Thomas and Ioi for your comments. |
|
Going to push as commit 823f5b9.
Your commit was automatically rebased without conflicts. |
|
@afshin-zafari Pushed as commit 823f5b9. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
The JVM options that are in range of
inttype are converted inglobals.hppand other files where affected.Tests
tiers 1-4 passed for linux-x64, linux-x64-debug, windows-x64, windows-x64-debug
tier1 all passed.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15164/head:pull/15164$ git checkout pull/15164Update a local copy of the PR:
$ git checkout pull/15164$ git pull https://git.openjdk.org/jdk.git pull/15164/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 15164View PR using the GUI difftool:
$ git pr show -t 15164Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15164.diff
Webrev
Link to Webrev Comment