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

Johan Sjölen jsjolen at openjdk.org
Wed Jan 25 15:20: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!

Marked fixes.

Passes tier1.

src/hotspot/share/jvmci/jvmciCodeInstaller.cpp line 380:

> 378:   }
> 379:   if (obj == nullptr) {
> 380:     JVMCI_THROW_MSG_(InternalError, "Constant was unexpectedly nullptr", Handle());

null

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

> 593:   if (tag.is_dynamic_constant() || tag.is_dynamic_constant_in_error()) {
> 594:     if (obj == Universe::the_null_sentinel()) {
> 595:       return JVMCIENV->get_jobject(JVMCIENV->get_JavaConstant_nullptr_POINTER());

Fix

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

> 1293: 
> 1294: /*
> 1295:  * Used by c2v_iterateFrames. Returns an array of any unallocated scope objects or nullptr if none.

Fix

src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp line 155:

> 153: 
> 154: #define SET_TRIGFUNC(name)                                      \
> 155:   if (StubRoutines::name() != nullptr) {                           \

Align

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

> 1690:     } else {                                                                                                         \
> 1691:       JNIAccessMark jni(this);                                                                                       \
> 1692:       jobjectArray result = jni()->NewObjectArray(length, JNIJVMCI::className::clazz(), nullptr);                       \

Align

src/hotspot/share/jvmci/jvmciEnv.hpp line 50:

> 48:       if (env != JavaThread::current()->jni_environment()) { \
> 49:         char* sl_path; \
> 50:         if (::JVMCI::get_shared_library(sl_path, false) != nullptr) { \

Align

src/hotspot/share/jvmci/jvmciEnv.hpp line 67:

> 65: 
> 66:   Klass*        klass() const                     { return _klass; }
> 67:   Klass*        non_null_klass() const            { assert(_klass != nullptr, "resolving nullptr _klass"); return _klass; }

null

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

> 487: #define DO_BOX_CLASS(klass, basicType, type) \
> 488:   current_class_name = "java/lang/" #klass;                                                                       \
> 489:   if (JVMCILibDumpJNIConfig == nullptr) {                                                                            \

Align

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

> 149:   start_class(JavaConstant, jdk_vm_ci_meta_JavaConstant)                                                      \
> 150:     static_object_field(JavaConstant, ILLEGAL, "Ljdk/vm/ci/meta/PrimitiveConstant;")                          \
> 151:     static_object_field(JavaConstant, nullptr_POINTER, "Ljdk/vm/ci/meta/JavaConstant;")                          \

Align

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

> 292:   static InstanceKlass* _klass;                                                      \
> 293:  public:                                                                             \
> 294:   static InstanceKlass* klass() { assert(_klass != nullptr, "uninit"); return _klass; } \

Align

src/hotspot/share/jvmci/jvmciRuntime.cpp line 274:

> 272:     pc = exception_frame.pc();
> 273:   }
> 274:   assert(exception.not_null(), "nullptr exceptions should be handled by throw_exception");

str

src/hotspot/share/jvmci/jvmciRuntime.cpp line 336:

> 334:   // If the stack guard pages are enabled, check whether there is a handler in
> 335:   // the current method.  Otherwise (guard pages disabled), force an unwind and
> 336:   // skip the exception cache update (i.e., just leave continuation==null).

Comparison use nullptr

src/hotspot/share/jvmci/jvmciRuntime.cpp line 587:

> 585: 
> 586:   if (obj == nullptr) {
> 587:     tty->print("nullptr");

null

src/hotspot/share/jvmci/jvmci_globals.hpp line 132:

> 130:           range(0, max_jint)                                                \
> 131:                                                                             \
> 132:   product(ccstr, JVMCILibPath, nullptr, EXPERIMENTAL,                          \

Align

src/hotspot/share/jvmci/vmStructs_jvmci.hpp line 33:

> 31: public:
> 32:   /**
> 33:    * The last entry has a nullptr fieldName.

null

src/hotspot/share/jvmci/vmStructs_jvmci.hpp line 38:

> 36: 
> 37:   /**
> 38:    * The last entry has a nullptr typeName.

null

src/hotspot/share/jvmci/vmStructs_jvmci.hpp line 44:

> 42:   /**
> 43:    * Table of integer constants.
> 44:    * The last entry has a nullptr typeName.

null

src/hotspot/share/jvmci/vmStructs_jvmci.hpp line 50:

> 48:   /**
> 49:    * Table of long constants.
> 50:    * The last entry has a nullptr typeName.

null

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

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


More information about the hotspot-compiler-dev mailing list