Skip to content

JDK-8301070: Replace NULL with nullptr in share/memory/ #12185

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

Closed
wants to merge 3 commits into from

Conversation

jdksjolen
Copy link
Contributor

@jdksjolen jdksjolen commented Jan 25, 2023

Hi, this PR changes all occurrences of NULL to nullptr for the subdirectory share/memory/. Unfortunately the script that does the change isn't perfect, and so we
need to comb through these manually to make sure nothing has gone wrong. I also review these changes but things slip past my eyes sometimes.

Here are some typical things to look out for:

  1. No changes but copyright header changed (probably because I reverted some changes but forgot the copyright).
  2. Macros having their NULL changed to nullptr, these are added to the script when I find them. They should be NULL.
  3. nullptr in comments and logs. We try to use lower case "null" in these cases as it reads better. An exception is made when code expressions are in a comment.

An example of this:

// This function returns null
void* ret_null();
// This function returns true if *x == nullptr
bool is_nullptr(void** x);

Note how nullptr participates in a code expression here, we really are talking about the specific value nullptr.

Thanks!


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8301070: Replace NULL with nullptr in share/memory/

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12185/head:pull/12185
$ git checkout pull/12185

Update a local copy of the PR:
$ git checkout pull/12185
$ git pull https://git.openjdk.org/jdk pull/12185/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12185

View PR using the GUI difftool:
$ git pr show -t 12185

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12185.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 25, 2023

👋 Welcome back jsjolen! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jan 25, 2023

@jdksjolen The following labels will be automatically applied to this pull request:

  • hotspot
  • serviceability

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.

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Jan 25, 2023
Copy link
Contributor Author

@jdksjolen jdksjolen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found one manual fix

insert_after(prev, b);
_last_insert_point = prev;
}

/**
* Search freelist for an entry on the list with the best fit.
* @return NULL, if no one was found
* @return nullptr, if no one was found
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null

@jdksjolen jdksjolen marked this pull request as ready for review January 25, 2023 15:11
@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 25, 2023
@mlbridge
Copy link

mlbridge bot commented Jan 25, 2023

Webrevs

@jdksjolen
Copy link
Contributor Author

Passes tier1.

@@ -226,7 +226,7 @@ class GuardedMemory : StackObj { // Wrapper on stack
/**
* Return the general purpose tag.
*
* @return the general purpose tag, defaults to NULL.
* @return the general purpose tag, defaults to nullptr.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr => null?

void* wrap_with_guards(void* base_ptr, size_t user_size, const void* tag = NULL) {
assert(base_ptr != NULL, "Attempt to wrap NULL with memory guard");
void* wrap_with_guards(void* base_ptr, size_t user_size, const void* tag = nullptr) {
assert(base_ptr != nullptr, "Attempt to wrap nullptr with memory guard");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap nullptr => wrap null?

@@ -303,9 +303,9 @@ class GuardedMemory : StackObj { // Wrapper on stack
* @param len the length of the copy
* @param tag optional general purpose tag (see GuardedMemory::get_tag())
*
* @return guarded wrapped memory pointer to the user area, or NULL if OOM.
* @return guarded wrapped memory pointer to the user area, or nullptr if OOM.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr => null?

@openjdk
Copy link

openjdk bot commented Jan 26, 2023

@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:

8301070: Replace NULL with nullptr in share/memory/

Reviewed-by: stefank, stuefe

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 116 new commits pushed to the master branch:

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 26, 2023
Copy link
Member

@tstuefe tstuefe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metaspace changes are good.

for (;;) {
DEBUG_ONLY(check_node(insertion_point);)
if (n->_word_size == insertion_point->_word_size) {
add_to_list(n, insertion_point); // parent stays NULL in this case.
add_to_list(n, insertion_point); // parent stays null in this case.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit. Do we have a unified naming scheme for comments?

"null" reads like a java null. I prefer keeping NULL in comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit. Do we have a unified naming scheme for comments?

Yeah, I forgot to update the PR message with all of the info. If you check now you can see what's been decided upon. The discussions can be found in previous PRs, I can link to them if you're curious.

"null" reads like a java null. I prefer keeping NULL in comments.

That's true, but this probably can be inferred from context which one is meant quite easily? I'd be more keen on explicitly saying that something is a Java null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, from fixing these reviews I've never seen us referring to a Java null when we meant a C++ nullptr.

@jdksjolen
Copy link
Contributor Author

/integrate

Passes tests and two approvals (with stefank's suggested fixes included), integrating.

@openjdk
Copy link

openjdk bot commented Jan 26, 2023

Going to push as commit d98a323.
Since your change was applied there have been 119 commits pushed to the master branch:

  • 315398c: 8221785: Let possibly_parallel_threads_do cover the same threads as threads_do
  • 14114c2: 8301005: Clean up Copy::conjoint_*_atomic on windows
  • 973f741: 8300968: Accessorize raw oop load in DeadCounterClosure
  • 64ddf95: 8299858: [Metrics] Swap memory limit reported incorrectly when too large
  • 28545dc: 8300247: Harden C1 xchg on AArch64 and PPC
  • 3f63381: 8300913: ZGC: assert(to_addr != 0) failed: Should be forwarded
  • da80e7a: 8300962: Parallel: Remove PSParallelCompact::_total_invocations
  • 7725fe8: 8299953: Merge ContiguousSpaceDCTOC into DirtyCardToOopClosure
  • a9b8acb: 8300652: Parallel: Refactor oop marking stack in Full GC
  • 15a1488: 8297437: javadoc cannot link to old docs (with old style anchors)
  • ... and 109 more: https://git.openjdk.org/jdk/compare/e326b86d37cec3b395b88598cf30ce4239732a15...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 26, 2023
@openjdk openjdk bot closed this Jan 26, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 26, 2023
@openjdk
Copy link

openjdk bot commented Jan 26, 2023

@jdksjolen Pushed as commit d98a323.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

3 participants