Skip to content

Conversation

@jdksjolen
Copy link
Contributor

@jdksjolen jdksjolen commented Jan 31, 2023

Hi, this PR changes all occurrences of NULL to nullptr for the subdirectory cpu/x86. 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

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12326

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 31, 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 31, 2023

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

  • hotspot
  • shenandoah

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 hotspot hotspot-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Jan 31, 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.

Some things to fix

// value.
// UPDATE: this constructor is only used by trace_method_handle_stub() now.
// assert(_pc != NULL, "no pc?");
// assert(_pc != null, "no pc?");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nullptr

// Calling the runtime using the regular call_VM_leaf mechanism generates
// code (generated by InterpreterMacroAssember::call_VM_leaf_base)
// that checks that the *(ebp+frame::interpreter_frame_last_sp) == NULL.
// that checks that the *(ebp+frame::interpreter_frame_last_sp) == 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.

nullptr

// Calling the runtime using the regular call_VM_leaf mechanism generates
// code (generated by InterpreterMacroAssember::call_VM_leaf_base)
// that checks that the *(ebp+frame::interpreter_frame_last_sp) == NULL.
// that checks that the *(ebp+frame::interpreter_frame_last_sp) == 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.

nullptr

// (1) the value is old (i.e., doesn't matter for scavenges)
// (2) these ICStubs are removed *before* a GC happens, so the roots disappear
// assert(cached_value == NULL || cached_oop->is_perm(), "must be perm oop");
// assert(cached_value == null || cached_oop->is_perm(), "must be perm oop");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nullptr

jcc(Assembler::equal, L);
stop("InterpreterMacroAssembler::call_VM_base:"
" last_sp != NULL");
" last_sp != 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.

nullptr

__ jccb(Assembler::negative, L_failed_0);

// if (dst == NULL) return -1;
// if (dst == null) return -1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nullptr

Comment on lines 1949 to 1956
// if (src->klass() == NULL) return -1;
// if (src->klass() == null) return -1;
Address src_klass_addr(src, oopDesc::klass_offset_in_bytes());
Address dst_klass_addr(dst, oopDesc::klass_offset_in_bytes());
const Register rcx_src_klass = rcx; // array klass
__ movptr(rcx_src_klass, Address(src, oopDesc::klass_offset_in_bytes()));

#ifdef ASSERT
// assert(src->klass() != NULL);
// assert(src->klass() != 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.

nullptr

//

// if (src == NULL) return -1;
// if (src == null) return -1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nullptr

__ jccb(Assembler::negative, L_failed_0);

// if (dst == NULL) return -1;
// if (dst == null) return -1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nullptr

__ load_klass(r10_src_klass, src, rklass_tmp);
#ifdef ASSERT
// assert(src->klass() != NULL);
// assert(src->klass() != 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.

nullptr

@jdksjolen jdksjolen marked this pull request as ready for review February 10, 2023 09:39
@jdksjolen
Copy link
Contributor Author

Builds and sent out for testing.

@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 10, 2023
@mlbridge
Copy link

mlbridge bot commented Feb 10, 2023

Webrevs

@jdksjolen
Copy link
Contributor Author

Passes tier1.

jcc(Assembler::equal, L);
stop("InterpreterMacroAssembler::call_VM_base:"
" last_sp != NULL");
" last_sp != nullptr");
Copy link
Contributor

Choose a reason for hiding this comment

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

null

Copy link
Member

Choose a reason for hiding this comment

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

These are textual code fragments so I think nullptr is more appropriate - as per changes made to cpu/arm code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right.

jcc(Assembler::equal, L);
stop("InterpreterMacroAssembler::call_VM_base:"
" last_sp != NULL");
" last_sp != nullptr");
Copy link
Member

Choose a reason for hiding this comment

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

These are textual code fragments so I think nullptr is more appropriate - as per changes made to cpu/arm code.

jcc(Assembler::equal, L);
stop("InterpreterMacroAssembler::call_VM_leaf_base:"
" last_sp != NULL");
" last_sp != null");
Copy link
Member

Choose a reason for hiding this comment

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

nullptr

void MacroAssembler::null_check(Register reg, int offset) {
if (needs_explicit_null_check(offset)) {
// provoke OS NULL exception if reg = NULL by
// provoke OS null exception if reg = null by
Copy link
Member

Choose a reason for hiding this comment

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

suggestion "reg is null"

} else {
// nothing to do, (later) access of M[reg + offset]
// will provoke OS NULL exception if reg = NULL
// will provoke OS null exception if reg = null
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: "reg is null"

// Support for null-checks
//
// Generates code that causes a NULL OS exception if the content of reg is NULL.
// Generates code that causes a null OS exception if the content of reg is null.
Copy link
Member

Choose a reason for hiding this comment

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

Note use of "reg is null" here :)

in_ByteSize(-1),
in_ByteSize(-1),
(OopMapSet*)NULL);
(OopMapSet*)nullptr);
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary cast?

Comment on lines 4187 to 4188
// rax = 0: obj == null or obj is not an instanceof the specified klass
// rax = 1: obj != null and obj is an instanceof the specified klass
Copy link
Member

Choose a reason for hiding this comment

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

nullptr

@jdksjolen
Copy link
Contributor Author

I added the fixes, thanks! Last commit passed tier1.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks

@openjdk
Copy link

openjdk bot commented Feb 14, 2023

@jdksjolen this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout JDK-8301498
git fetch https://git.openjdk.org/jdk master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Feb 14, 2023
Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

In addition to few missed placed I noticed that you keep mov_metadata(rbx, (Metadata*)nullptr); casting.

Is Metadata* something special we need to cast it?

And more general question - do we need to keep some casting for nullptr?
We kept them in previous PRs which are already pushed #12029

Should we update our "spec" for nullptr to remove all casting or keep some? What is condition to keep?

movptr(tmp, Address(rthread, JavaThread::jvmti_thread_state_offset()));
testptr(tmp, tmp);
jcc(Assembler::zero, L); // if (thread->jvmti_thread_state() == NULL) exit;
jcc(Assembler::zero, L); // if (thread->jvmti_thread_state() == null) exit;
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed change to nullptr as you suggested.

// // main copy of decision tree, rooted at row[1]
// if (row[0].rec == rec) { row[0].incr(); goto done; }
// if (row[0].rec != NULL) {
// if (row[0].rec != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed change to nullptr as you suggested.

Comment on lines 1782 to 1785
// if (row[1].rec != NULL) {
// if (row[1].rec != null) {
// // degenerate decision tree, rooted at row[2]
// if (row[2].rec == rec) { row[2].incr(); goto done; }
// if (row[2].rec != NULL) { count.incr(); goto done; } // overflow
// if (row[2].rec != null) { count.incr(); goto done; } // overflow
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed change to nullptr.

}

// for (scan = klass->itable(); scan->interface() != NULL; scan += scan_step) {
// for (scan = klass->itable(); scan->interface() != null; scan += scan_step) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed change to nullptr as you suggested.

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 14, 2023

@jdksjolen This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@jdksjolen
Copy link
Contributor Author

Hi Vladimir!

I applied your changes, thanks for the review.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Looks good.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Still good. Thanks.

@openjdk
Copy link

openjdk bot commented Mar 21, 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:

8301498: Replace NULL with nullptr in cpu/x86

Reviewed-by: dholmes, kvn

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

  • 0156909: 8304502: Classfile API class hierarchy makes assumptions when class is not resolved
  • 0deb648: 8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears to be hung"
  • 019fcd8: 8304139: Add and method constants to ConstantDescs
  • d6f20e2: 8304680: Problemlist compiler/sharedstubs/SharedStubToInterpTest.java
  • d788a1b: 8304180: Constant Descriptors for MethodHandles::classData and classDataAt
  • bbde215: 8299494: Test vmTestbase/nsk/stress/except/except011.java failed: ExceptionInInitializerError: target class not found
  • 1c04686: 8304387: Fix positions of shared static stubs / trampolines
  • c65bb2c: 8304334: java/awt/color/ICC_ColorSpace/ToFromCIEXYZRoundTrip.java times out on slow platforms
  • 4bf1fbb: 8303648: Add String.indexOf(String str, int beginIndex, int endIndex)
  • c4df9b5: 8304537: Ant-based langtools build fails after JDK-8015831 Add lint check for calling overridable methods from a constructor
  • ... and 64 more: https://git.openjdk.org/jdk/compare/e3777b0c49abb9cc1925f4044392afadf3adef61...master

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 ready Pull request is ready to be integrated and removed merge-conflict Pull request has merge conflict with target branch labels Mar 21, 2023
Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Still good. Thanks.

(incremental change looked weird but end result seems fine)

@jdksjolen
Copy link
Contributor Author

Thanks. All of tier1 and tier2 is passing.

/integrate

@openjdk
Copy link

openjdk bot commented Mar 22, 2023

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

  • ddf1e34: 8304089: Convert TraceDependencies to UL
  • 358c61b: 8294972: Convert jdk.jlink internal plugins to use the Classfile API
  • c74507e: 8304657: G1: Rename set_state_empty to set_state_untracked
  • ca94287: 8304144: G1: Remove unnecessary is_survivor check in G1ClearCardTableTask
  • eda0065: 8304286: java/net/SocketOption/OptionsTest.java failing after JDK-8302659
  • c039d26: 8303804: Fix some errors of If-VectorTest and CMove-VectorTest
  • 0156909: 8304502: Classfile API class hierarchy makes assumptions when class is not resolved
  • 0deb648: 8290200: com/sun/jdi/InvokeHangTest.java fails with "Debuggee appears to be hung"
  • 019fcd8: 8304139: Add and method constants to ConstantDescs
  • d6f20e2: 8304680: Problemlist compiler/sharedstubs/SharedStubToInterpTest.java
  • ... and 70 more: https://git.openjdk.org/jdk/compare/e3777b0c49abb9cc1925f4044392afadf3adef61...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Mar 22, 2023

@jdksjolen Pushed as commit 4154a98.

💡 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 shenandoah shenandoah-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

3 participants