RFR: JDK-8301068: Replace NULL with nullptr in share/jvmci/

Vladimir Kozlov kvn at openjdk.org
Wed Jan 25 17:37:26 UTC 2023


On Wed, 25 Jan 2023 11:45:21 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

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

Few missed `nullptr` in messages.

src/hotspot/share/jvmci/jvmciCompilerToVM.cpp line 1244:

> 1242:     *resolved_methods_ref = resolved_methods;
> 1243:   }
> 1244:   assert(method != nullptr, "method should not be nullptr");

`nullptr` in message.

src/hotspot/share/jvmci/jvmciEnv.cpp line 1462:

> 1460:     oop result = resolve_oop_handle(object_handle);
> 1461:     if (result == nullptr) {
> 1462:       JVMCI_THROW_MSG_(InternalError, "Constant was unexpectedly nullptr", Handle());

`nullptr` in message.

src/hotspot/share/jvmci/jvmciEnv.cpp line 1475:

> 1473: 
> 1474: jlong JVMCIEnv::make_oop_handle(const Handle& obj) {
> 1475:   assert(!obj.is_null(), "should only create handle for non-nullptr oops");

`nullptr` in message.

src/hotspot/share/jvmci/jvmciJavaClasses.cpp line 202:

> 200:   }                                                                                     \
> 201:   void HotSpotJVMCI::className::check(oop obj, const char* field_name, int offset) {    \
> 202:     assert(obj != nullptr, "nullptr field access of %s.%s", #className, field_name); \

`nullptr` in message

src/hotspot/share/jvmci/jvmciJavaClasses.cpp line 236:

> 234:     void HotSpotJVMCI::className::set_##name(JVMCIEnv* env, type x) {                                                     \
> 235:       assert(className::klass() != nullptr && className::klass()->is_linked(), "Class not yet linked: " #className);         \
> 236:       assert(className::klass() != nullptr, "Class not yet loaded: " #className);                                            \

Align ``

src/hotspot/share/jvmci/jvmciJavaClasses.cpp line 243:

> 241: #define STATIC_PRIMITIVE_FIELD(className, name, jtypename)                                                                \
> 242:     jtypename HotSpotJVMCI::className::get_##name(JVMCIEnv* env) {                                                        \
> 243:       assert(className::klass() != nullptr && className::klass()->is_linked(), "Class not yet linked: " #className);         \

Align ``

src/hotspot/share/jvmci/jvmciJavaClasses.cpp line 249:

> 247:     }                                                                                                                     \
> 248:     void HotSpotJVMCI::className::set_##name(JVMCIEnv* env, jtypename x) {                                                \
> 249:       assert(className::klass() != nullptr && className::klass()->is_linked(), "Class not yet linked: " #className);         \

Align ``

src/hotspot/share/jvmci/jvmciJavaClasses.cpp line 269:

> 267:  * void HotSpotJVMCI::Architecture::set_wordKind(JVMCIEnv* env, oop obj, oop x) { ... }
> 268:  *
> 269:  * InstanceKlass *HotSpotJVMCI::Architecture::_klass = nullptr;

Right. This is exception case you listed: expression in comment.

src/hotspot/share/jvmci/jvmciJavaClasses.cpp line 624:

> 622:   }                                                                                                                               \
> 623:   void JNIJVMCI::className::check(JVMCIEnv* jvmciEnv, JVMCIObject obj, const char* field_name, jfieldID offset) {                 \
> 624:     assert(obj.is_non_null(), "nullptr field access of %s.%s", #className, field_name);                                     \

`nullptr` in message

src/hotspot/share/jvmci/jvmciJavaClasses.hpp line 394:

> 392:   static jclass _class;                                                                             \
> 393: public:                                                                                             \
> 394:  static jclass clazz() { assert(_class != nullptr, #fullClassName " uninitialized"); return _class; }  \

Should we align `` in previous lines?

src/hotspot/share/jvmci/jvmciObject.hpp line 68:

> 66:  public:
> 67:   JVMCIObjectArray() {}
> 68:   JVMCIObjectArray(void* v): JVMCIArray() { assert(v == nullptr, "must be nullptr"); }

`nullptr` in message

src/hotspot/share/jvmci/jvmciObject.hpp line 77:

> 75:  public:
> 76:   JVMCIPrimitiveArray() {}
> 77:   JVMCIPrimitiveArray(void* v): JVMCIArray() { assert(v == nullptr, "must be nullptr"); }

`nullptr` in message

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

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


More information about the hotspot-compiler-dev mailing list