-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8252136: Several methods in hotspot are missing "static" #17806
Conversation
👋 Welcome back ihse! A progress list of the required criteria for merging this PR into |
@magicus 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. |
65f0514
to
97595a3
Compare
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.
Nice change. I looked at the runtime files, and surprised there weren't more. Thank you.
@magicus 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.
The argument alignment is wonky after this patch. Could you go over the patch and fix 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.
I reviewed compiler code (cpu/, compiler/, c1/, opto/). Looks good to me.
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.
Mostly good, other than the parameter indentation issue mentioned by @stefank .
Just a couple of minor comments.
@@ -199,7 +199,7 @@ static ArrayInfo* array_infos = nullptr; | |||
static FieldTable* field_infos = nullptr; | |||
static RootDescriptionInfo* root_infos = nullptr; | |||
|
|||
int __write_sample_info__(JfrCheckpointWriter* writer, const void* si) { | |||
static int __write_sample_info__(JfrCheckpointWriter* writer, const void* si) { |
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.
pre-existing: all these names starting with underscores are technically reserved names - C++14 17.6.4.3.2.
Shouldn't be changed as part of this PR, but perhaps there should be a bug report? Don't know if anyone
would ever get around to doing anything about it though.
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.
Please feel free to open a bug report. 😉
Unless there is a warning flag to avoid creating reserved names (is there?), it is more of a matter of coding style on the part of Hotspot, and that is basically where I draw the line of my meddling with Hotspot. :)
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 just discovered that Clang 13 added -Wreserved-identifier
. There's also an open gcc bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51437
And a discussion of the "chattiness" of the feature:
llvm/llvm-project#57913 (comment)
Probably there's not much appetite for this sort of thing, and I shouldn't have brought it up.
I did not think of that, sorry. Fixed now. (It turned out that not all places were properly aligned even before my patch...) There are some places with extremely long lines, but that seem to be the style in these files, so I did not introduce line breaks there. |
@stefank Is this version okay? |
Yes, the GC code looks good. 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.
Looks good.
/integrate |
Going to push as commit 09d4936.
Your commit was automatically rebased without conflicts. |
There are several places in hotspot where an internal function should have been declared static, but isn't.
These were discovered by trying to use the gcc option
-Wmissing-declarations
and the corresponding clang option-Wmissing-prototypes
. These warnings check that a function either:a) is declared static, or
b) has a declaration before its definition.
The rationale of this is that functions are either internal to a compilation unit, or exported to be linked by some other compilation unit. In the former case, it should be marked static. In the latter case, it should be declared in a header file, which should be included by the implementation as well. If there is a discrepancy between the exported prototype and the implemented prototype, this will be discovered during compilation (instead of as a runtime error). Additionally, marking internal methods as static allows the compiler to make better optimization, like inlining.
This seem to be to be a sane assumption, and I think Hotspot (and the entire JDK) would increase code quality by turning on these warnings. The absolute majority of the code already adheres to these rules, but there are still some places that needs to be fixed.
This is the first part of addressing these issues, where all places that are trivially missing static are fixed.
I have discovered these by running with the warnings mentioned above turned on. I have filtered out those places were an export was obviously missing. The remaining warnings I have manually inspected. About 1/4 of them were *_init() functions (which are directly declared in
init.cpp
) and another 1/4 were documented as "use in debugger"; these I have not touched. I also ignored functions with names suggesting it might be used in the debugger, even if not documented as such, or any places that even seemed remotely non-trivial. Finally I also reverted a few changes after it turned out that gcc complained about unused functions. These places are actually dead code, but it is not clear if they should be removed or if there is actually a call missing somewhere (I believe it is a mix of both). In any case, I did not want any such complexities in this PR.When the functions where marked static, gcc started complaining if they were not used, since it consider it dead code. To address this, I had to add or fix some
#ifdef
s. Since this code were not actually used unless these criteria were fulfilled before either (it was just not discovered by the compiler), I think this is mostly a good thing.Finally, I have manually searched for each and every one of these functions (tedious!) and verified that they are indeed only called from within the specific file. But in the end, the proof should be in the pudding -- if hotspot still compiles with these changes, then they should be correct. (The one exception to this is if the symbol is supposed to be used in e.g. the debugger, and I've missed that.)
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17806/head:pull/17806
$ git checkout pull/17806
Update a local copy of the PR:
$ git checkout pull/17806
$ git pull https://git.openjdk.org/jdk.git pull/17806/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 17806
View PR using the GUI difftool:
$ git pr show -t 17806
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17806.diff
Webrev
Link to Webrev Comment