RFR: 8300086: Replace NULL with nullptr in share/c1/

Tobias Hartmann thartmann at openjdk.org
Wed May 17 10:45:48 UTC 2023


On Tue, 16 May 2023 12:08:47 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

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

Looks good to me otherwise.

Just wondering, can / will we put any safeguards in place once we migrated all code to `nullptr` to make sure new changes don't re-introduce `NULL`?

src/hotspot/share/c1/c1_GraphBuilder.cpp line 2954:

> 2952:       case Bytecodes::_dreturn        : method_return(dpop(), ignore_return); break;
> 2953:       case Bytecodes::_areturn        : method_return(apop(), ignore_return); break;
> 2954:       case Bytecodes::_return         : method_return(nullptr  , ignore_return); break;

Suggestion:

      case Bytecodes::_return         : method_return(nullptr, ignore_return); break;

src/hotspot/share/c1/c1_Instruction.hpp line 239:

> 237:     if (!(enabled)  ) return false;                   \
> 238:     class_name* _v = v->as_##class_name();            \
> 239:     if (_v == nullptr  ) return false;                \

Suggestion:

    if (_v == nullptr) return false;                  \

src/hotspot/share/c1/c1_Instruction.hpp line 252:

> 250:     if (!(enabled)  ) return false;                   \
> 251:     class_name* _v = v->as_##class_name();            \
> 252:     if (_v == nullptr  ) return false;                \

Suggestion:

    if (_v == nullptr) return false;                  \

src/hotspot/share/c1/c1_Instruction.hpp line 266:

> 264:     if (!(enabled)  ) return false;                   \
> 265:     class_name* _v = v->as_##class_name();            \
> 266:     if (_v == nullptr  ) return false;                \

Suggestion:

    if (_v == nullptr) return false;                  \

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

Marked as reviewed by thartmann (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/14009#pullrequestreview-1430330221
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1196283705
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1196286525
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1196286831
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1196286969


More information about the hotspot-compiler-dev mailing list