RFR: JDK-8301498: Replace NULL with nullptr in cpu/x86

David Holmes dholmes at openjdk.org
Mon Feb 13 01:46:32 UTC 2023


On Tue, 31 Jan 2023 11:40:19 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

> 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:
> 
> ```c++
> // 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!

src/hotspot/cpu/x86/interp_masm_x86.cpp line 271:

> 269:     jcc(Assembler::equal, L);
> 270:     stop("InterpreterMacroAssembler::call_VM_leaf_base:"
> 271:          " last_sp != null");

nullptr

src/hotspot/cpu/x86/macroAssembler_x86.cpp line 2857:

> 2855: void MacroAssembler::null_check(Register reg, int offset) {
> 2856:   if (needs_explicit_null_check(offset)) {
> 2857:     // provoke OS null exception if reg = null by

suggestion "reg is null"

src/hotspot/cpu/x86/macroAssembler_x86.hpp line 96:

> 94:   // Support for null-checks
> 95:   //
> 96:   // Generates code that causes a null OS exception if the content of reg is null.

Note use of "reg is null" here :)

src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp line 1765:

> 1763:                                        in_ByteSize(-1),
> 1764:                                        in_ByteSize(-1),
> 1765:                                        (OopMapSet*)nullptr);

Unnecessary cast?

src/hotspot/cpu/x86/templateTable_x86.cpp line 4188:

> 4186:   __ bind(done);
> 4187:   // rax = 0: obj == null or  obj is not an instanceof the specified klass
> 4188:   // rax = 1: obj != null and obj is     an instanceof the specified klass

nullptr

-------------

PR: https://git.openjdk.org/jdk/pull/12326


More information about the shenandoah-dev mailing list