-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
8337995: ZUtils::fill uses std::fill_n #22667
Conversation
👋 Welcome back kbarrett! A progress list of the required criteria for merging this PR into |
@kimbarrett 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 |
@kimbarrett The following label 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 list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
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 wonder how this even got in...
Windows/ARM64 also uses forbidden C++ Standard Library utilities, namely in the atomic implementation. I was thinking about fixing that, but I'm unsure of whether its use is truly needed and justified or not, and additionally Windows/Zero also uses the same atomic header as well |
Sorry I meant orderAccess, not atomic |
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 code change itself looks good.
Just got one question about the rule, I know a c++ compiler needs to support c++14, as std::fill_n
is introduced in 17/20/26, so seems we should not use it in hotspot code, is this the reason why we can not use std::fill_n
here? Or there is a place recording which libaraies/files are allowed or not allowed in hotspot? Thanks!
The hotspot style guide only allows a few libraries from the standard library to be used (https://github.com/openjdk/jdk/blob/master/doc/hotspot-style.md?plain=1#L531). A previous paragraph (https://github.com/openjdk/jdk/blob/master/doc/hotspot-style.md?plain=1#L377) states that unless explicitly allowed, use of other features is disallowed. |
@tschatzl Thank you for the information! |
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!
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 don't really see the need to forbid std::fill_n
, so I would have preferred an update to the style guide. However, if we really need to remove it then I would prefer style modification to the explicit loop.
src/hotspot/share/gc/z/zUtils.cpp
Outdated
for (uintptr_t* end = addr + count; addr < end; ++addr) { | ||
*addr = value; | ||
} |
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 tend to avoid changing values of the input arguments, so I would like to see that changed. Unless there's a problem with the below code I would like to see this changed to this:
for (uintptr_t* current = addr; current < addr + count; ++current) {
*current = value;
}
Or maybe even:
for (size_t i = 0; i < count; ++i) {
*(addr + i) = value;
}
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. I went with something like the 2nd suggestion, though with array syntax
rather than explict pointer arithmetic.
The "approved" HotSpot way to do that operation would be to use something from I considered adding It's less about using There are approaches to dealing with those sorts of things (mostly "wrapper" Also, if you think something in the Style Guide is onorous, confusing, or |
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.
Just to be clear, std::fill_n goes way back. It's in C++98/03, and probably earlier. |
Thanks y'all for reviews. |
/integrate |
Going to push as commit 22845a7.
Your commit was automatically rebased without conflicts. |
@kimbarrett Pushed as commit 22845a7. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Please review this change to zUtils.cpp to use a for-loop to fill a block of
memory rather than using the std::fill_n algorithm. Use of is
currently not permitted in HotSpot.
Testing: mach5 tier1
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22667/head:pull/22667
$ git checkout pull/22667
Update a local copy of the PR:
$ git checkout pull/22667
$ git pull https://git.openjdk.org/jdk.git pull/22667/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 22667
View PR using the GUI difftool:
$ git pr show -t 22667
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22667.diff
Using Webrev
Link to Webrev Comment