-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8309044: Replace NULL with nullptr, final sweep of hotspot code #14198
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 jsjolen! A progress list of the required criteria for merging this PR into |
|
@jdksjolen 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. |
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.
All of the stuff to actually keep.
|
|
||
| void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &cbuf, methodHandle& method, jint pc_offset, JVMCI_TRAPS) { | ||
| NativeCall* call = NULL; | ||
| NativeCall* call = nullptr; |
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.
T
| // Check for proper post_call_nop | ||
| NativePostCallNop* nop = nativePostCallNop_at(call->next_instruction_address()); | ||
| if (nop == NULL) { | ||
| if (nop == nullptr) { |
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.
T
| __ ld_ptr(method, array_base_offset + in_bytes(ResolvedIndyEntry::method_offset()), cache); | ||
|
|
||
| // The invokedynamic is unresolved iff method is NULL | ||
| // The invokedynamic is unresolved iff method is null |
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.
T
| // Make sure klass is 'reasonable', which is not zero. | ||
| __ load_klass(obj, obj, tmp1); // get klass | ||
| __ beqz(obj, error); // if klass is NULL it is broken | ||
| __ beqz(obj, error); // if klass is null it is broken |
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.
T
| StubRoutines::_forward_exception_entry = generate_forward_exception(); | ||
|
|
||
| if (UnsafeCopyMemory::_table == NULL) { | ||
| if (UnsafeCopyMemory::_table == nullptr) { |
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.
T
| start_log(); | ||
| } else { | ||
| // and leave xtty as nullptr | ||
| // and leave xtty as null |
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.
T
| assert(p->key() != nullptr, "p->key() is null"); | ||
| if (p->readable()) { | ||
| // Print in two stages to avoid problems with long | ||
| // keys/values. | ||
| text->print_raw(p->key()); | ||
| text->put('='); | ||
| assert(p->value() != nullptr, "p->value() is nullptr"); | ||
| assert(p->value() != nullptr, "p->value() is null"); |
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.
T
| Writer(const ARR& array) | ||
| : _array(const_cast<ARR&>(array)), _limit_ptr(nullptr), _position(0) { | ||
| // Note: if _limit_ptr is nullptr, the ARR& is never reassigned, | ||
| // Note: if _limit_ptr is null, the ARR& is never reassigned, |
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.
T
| // Utility methods | ||
|
|
||
| // Returns nullptr if 'c' it not found. This only works as long | ||
| // Returns null if 'c' it not found. This only works as long |
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.
T
| static char _detail_msg[1024]; | ||
|
|
||
| static Thread* _thread; // nullptr if it's native thread | ||
| static Thread* _thread; // null if it's native thread |
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.
T
Webrevs
|
|
not a review, but would you like to check if these could replaced 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.
Looks good. Though, I'd prefer if we could slightly tweak the following two print lines.
| st->print(PTR_FORMAT " is a zaddress: ", untype(addr)); | ||
|
|
||
| if (addr == zaddress::null) { | ||
| st->print_raw_cr("NULL"); |
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'd prefer if this were left as either NULL or null.
src/hotspot/share/gc/z/zHeap.cpp
Outdated
|
|
||
| if (addr == zaddress::null) { | ||
| st->print_raw_cr("NULL"); | ||
| st->print_raw_cr("nullptr"); |
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'd prefer if this were left as either NULL or null.
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.
Suggest: null
|
@jdksjolen 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 29 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. A few suggested changes below.
Can we now poison NULL so it can't get reintroduced? Or would that potentially break standard headers?
Thanks
| __ ld_ptr(method, array_base_offset + in_bytes(ResolvedIndyEntry::method_offset()), cache); | ||
|
|
||
| // The invokedynamic is unresolved iff method is NULL | ||
| // The invokedynamic is unresolved iff method is nullptr |
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.
Suggest: null
| __ load_klass(obj, obj, tmp1); // get klass | ||
| __ testptr(obj, obj); | ||
| __ jcc(Assembler::zero, error); // if klass is NULL it is broken | ||
| __ jcc(Assembler::zero, error); // if klass is nullptr it is broken |
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.
suggest: null
src/hotspot/share/gc/z/zHeap.cpp
Outdated
|
|
||
| if (addr == zaddress::null) { | ||
| st->print_raw_cr("NULL"); | ||
| st->print_raw_cr("nullptr"); |
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.
Suggest: null
src/hotspot/share/gc/z/zHeap.cpp
Outdated
|
|
||
| if (addr == zaddress::null) { | ||
| st->print_raw_cr("NULL"); | ||
| st->print_raw_cr("nullptr"); |
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.
Suggest: null
| \ | ||
| develop(bool, InterceptOSException, false, \ | ||
| "Start debugger when an implicit OS (e.g. nullptr) " \ | ||
| "Start debugger when an implicit OS (e.g. null) " \ |
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.
Suggest: null pointer
|
Hi, thank you all for the suggestions! I've now applied them. I'll look at integrating tomorrow. |
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.
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.
Thanks for addressing the comment. Looks Good :-)
|
Right, seems like the Windows CI fails at fetching JTReg. I'm merging this, thank you all for the reviews. /integrate |
|
Going to push as commit 4f16161.
Your commit was automatically rebased without conflicts. |
|
@jdksjolen Pushed as commit 4f16161. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
|
What's the plan now to prevent re-introducing |
I'm sure it would. Maybe some changes to Skara? |
Hi Tobias. The only plan in place is social, the reviewers have to look out for it. I am however researching how to do this through machine. I'm currently researching ways of preventing any re-introductions by machine. These include poisoning the NULL macro by re-defining it and finding a tool which is capable of parsing C++ code which is yet to go through the pre-processor. |
|
It may be simpler to use simple grepping + an allow list. For example using |
|
I think if we just rely on reviews, NULLs will slip through again and we would need to have regular cleanup PRs. Doug's idea seems simple enough to implement in Skara/jcheck. An alternative to whitelisting would be a warning in the offending PR or a requirement for "special approvement" of such changes (for example, via a Skara command). |
|
I'm an entire year late, but if poisoning NULL is desired, what about #pragma GCC poison? |
|
For Visual C++, that would be #pragma deprecated("NULL") To quote Microsoft: I have no idea how to achieve this with the xlc compiler |
|
I don't think MSVC's deprecation pragma might work for this, at least for shared and However, there are still a lot of NULL's left. All of the per-cpu .ad files, But it does look like there's been a bit of backsliding: |
I see, that's a shame in that case
That's a little worrying, maybe the Style Guide's NULL section could be reworded since now most usages of NULL are nullptr? The .ad files and .xsl files are a bit of a problem though
The deprecation pragma only works for macros and identifiers, it doesn't accept method signatures and would warn for every time a identifier is used, even in the method's declaration itself! Probably can't be used in FORBID_C_FUNCTION as mentioned above, but sounds good for a macro like NULL I've also been trying to implement FORBID_C_FUNCTION and ALLOW_C_FUNCTION portably, speaking of it, but it hasn't been going great so far :/ #17387 |
A final sweep of Hotspot to remove all re-added NULLs. With only 110 changes I'd appreciate if this was considered trivial.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14198/head:pull/14198$ git checkout pull/14198Update a local copy of the PR:
$ git checkout pull/14198$ git pull https://git.openjdk.org/jdk.git pull/14198/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 14198View PR using the GUI difftool:
$ git pr show -t 14198Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14198.diff
Webrev
Link to Webrev Comment