8313564: Fix -Wconversion warnings in classfile code#15111
8313564: Fix -Wconversion warnings in classfile code#15111coleenp wants to merge 14 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back coleenp! A progress list of the required criteria for merging this PR into |
Webrevs
|
…h. prefetch_data_size() returns uint, so added a checked_cast<> to catch the case where it would return greater than signed int max.
| if (_symbols_counted > 0) { | ||
| tty->print_cr(" Percent removed %3.2f", | ||
| ((float)_symbols_removed / _symbols_counted) * 100); | ||
| ((float)_symbols_removed / (float)_symbols_counted) * 100); |
There was a problem hiding this comment.
I think you can also just cast once here.
There was a problem hiding this comment.
These should probably be double rather than float - the float result will be promoted to double to be passed as an argument anyway.
| tty->print_cr(" Total symbol length " SIZE_FORMAT_W(7), hi.total_length); | ||
| tty->print_cr(" Maximum symbol length " SIZE_FORMAT_W(7), hi.max_length); | ||
| tty->print_cr(" Average symbol length %7.2f", ((float)hi.total_length / hi.total_count)); | ||
| tty->print_cr(" Average symbol length %7.2f", ((float)hi.total_length / (float)hi.total_count)); |
There was a problem hiding this comment.
I think each value needs to be cast to get the correct result.
There was a problem hiding this comment.
Yes size_t values must be cast to float/double. Again I think double should be used here.
There was a problem hiding this comment.
Also changed to double.
coleenp
left a comment
There was a problem hiding this comment.
Thanks for looking at this in detail Matias and for asking questions. I hope I've answered them sufficiently.
| tty->print_cr(" Total symbol length " SIZE_FORMAT_W(7), hi.total_length); | ||
| tty->print_cr(" Maximum symbol length " SIZE_FORMAT_W(7), hi.max_length); | ||
| tty->print_cr(" Average symbol length %7.2f", ((float)hi.total_length / hi.total_count)); | ||
| tty->print_cr(" Average symbol length %7.2f", ((float)hi.total_length / (float)hi.total_count)); |
There was a problem hiding this comment.
I think each value needs to be cast to get the correct result.
matias9927
left a comment
There was a problem hiding this comment.
Thank you for addressing my questions, it looks like everything is good then!
dholmes-ora
left a comment
There was a problem hiding this comment.
A couple of queries/comments but overall seems reasonable.
Thanbks.
|
@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 44 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 |
coleenp
left a comment
There was a problem hiding this comment.
Thanks for reviewing, David. Reran with -Wconversion and now tier1 on your suggestions.
| if (_symbols_counted > 0) { | ||
| tty->print_cr(" Percent removed %3.2f", | ||
| ((float)_symbols_removed / _symbols_counted) * 100); | ||
| ((float)_symbols_removed / (float)_symbols_counted) * 100); |
| tty->print_cr(" Total symbol length " SIZE_FORMAT_W(7), hi.total_length); | ||
| tty->print_cr(" Maximum symbol length " SIZE_FORMAT_W(7), hi.max_length); | ||
| tty->print_cr(" Average symbol length %7.2f", ((float)hi.total_length / hi.total_count)); | ||
| tty->print_cr(" Average symbol length %7.2f", ((float)hi.total_length / (float)hi.total_count)); |
There was a problem hiding this comment.
Also changed to double.
coleenp
left a comment
There was a problem hiding this comment.
I reverted the items_count change.
dholmes-ora
left a comment
There was a problem hiding this comment.
Okay on reverting the item_count changes - but we should look at a follow up RFE to get these types sorted out.
Thanks
| // refer to more than 16384 * 16384 = 26M interned strings! Not a practical concern | ||
| // but bail out for safety. | ||
| log_error(cds)("Too many strings to be archived: %d", _items_count); | ||
| log_error(cds)("Too many strings to be archived: " SIZE_FORMAT, _items_count); |
| size_t SymbolTable::estimate_size_for_archive() { | ||
| return CompactHashtableWriter::estimate_size(_items_count); | ||
| if (_items_count > (size_t)max_jint) { | ||
| fatal("Too many symbols to be archived: " SIZE_FORMAT, _items_count); |
In this case, I think we need items_count to be size_t so that we can do an explicit bounds check for CDS, so this type is correct. Thanks for reviewing, Matias, Dean and David. |
|
Going to push as commit f66cd50.
Your commit was automatically rebased without conflicts. |
This patch fixes various -Wconversion warnings in classfile code. I broke the change into commits so the changes are easier to see.
Tested with tier1-4.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15111/head:pull/15111$ git checkout pull/15111Update a local copy of the PR:
$ git checkout pull/15111$ git pull https://git.openjdk.org/jdk.git pull/15111/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 15111View PR using the GUI difftool:
$ git pr show -t 15111Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15111.diff
Webrev
Link to Webrev Comment