RFR: JDK-8301496: Replace NULL with nullptr in cpu/riscv

Johan Sjölen jsjolen at openjdk.org
Tue Mar 28 10:41:54 UTC 2023


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

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

Review of changes to be made.

Don't close yet.

src/hotspot/cpu/riscv/assembler_riscv.hpp line 2174:

> 2172:   }                                                                                          \
> 2173:   void NAME(address dest) {                                                                  \
> 2174:     assert_cond(dest != nullptr);                                                               \

align

src/hotspot/cpu/riscv/assembler_riscv.hpp line 2202:

> 2200:   }                                                                                          \
> 2201:   void NAME(Register Rs1, address dest) {                                                    \
> 2202:     assert_cond(dest != nullptr);                                                               \

align

src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp line 161:

> 159:   // Calling the runtime using the regular call_VM_leaf mechanism generates
> 160:   // code (generated by InterpreterMacroAssember::call_VM_leaf_base)
> 161:   // that checks that the *(rfp+frame::interpreter_frame_last_sp) == null.

is null

src/hotspot/cpu/riscv/interp_masm_riscv.cpp line 159:

> 157:     Label L;
> 158:     ld(t0, Address(xthread, JavaThread::jvmti_thread_state_offset()));
> 159:     beqz(t0, L);  // if [thread->jvmti_thread_state() == null] then exit

is

src/hotspot/cpu/riscv/interp_masm_riscv.cpp line 1335:

> 1333: //       ]
> 1334: //       if (row[2].rec != null) then [
> 1335: //         count.incr()

nullptr

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 836:

> 834: #define INSN(NAME, REGISTER)                                       \
> 835:   void MacroAssembler::NAME(const address dest, Register temp) {   \
> 836:     assert_cond(dest != nullptr);                                     \

align

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 880:

> 878: #define INSN(NAME)                                                                    \
> 879:   void MacroAssembler::NAME(Register Rd, const address dest, Register temp) {         \
> 880:     assert_cond(dest != nullptr);                                                        \

align

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 2025:

> 2023: void MacroAssembler::null_check(Register reg, int offset) {
> 2024:   if (needs_explicit_null_check(offset)) {
> 2025:     // provoke OS null exception if reg = null by

is

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 2031:

> 2029:   } else {
> 2030:     // nothing to do, (later) access of M[reg + offset]
> 2031:     // will provoke OS NULL exception if reg = NULL

is

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 2031:

> 2029:   } else {
> 2030:     // nothing to do, (later) access of M[reg + offset]
> 2031:     // will provoke OS null exception if reg = null

is

src/hotspot/cpu/riscv/macroAssembler_riscv.hpp line 593:

> 591: #define INSN(NAME)                                                                                       \
> 592:   void NAME(Register Rs1, Register Rs2, const address dest) {                                            \
> 593:     assert_cond(dest != nullptr);                                                                           \

align

src/hotspot/cpu/riscv/macroAssembler_riscv.hpp line 783:

> 781: #define INSN(NAME)                                                                                 \
> 782:   void NAME(Register Rd, address dest) {                                                           \
> 783:     assert_cond(dest != nullptr);                                                                     \

align

src/hotspot/cpu/riscv/macroAssembler_riscv.hpp line 840:

> 838: #define INSN(NAME)                                                                                 \
> 839:   void NAME(FloatRegister Rd, address dest, Register temp = t0) {                                  \
> 840:     assert_cond(dest != nullptr);                                                                     \

align

src/hotspot/cpu/riscv/macroAssembler_riscv.hpp line 900:

> 898: #define INSN(NAME)                                                                                 \
> 899:   void NAME(Register Rs, address dest, Register temp = t0) {                                       \
> 900:     assert_cond(dest != nullptr);                                                                     \

align

src/hotspot/cpu/riscv/macroAssembler_riscv.hpp line 946:

> 944: #define INSN(NAME)                                                                                 \
> 945:   void NAME(FloatRegister Rs, address dest, Register temp = t0) {                                  \
> 946:     assert_cond(dest != nullptr);                                                                     \

align

src/hotspot/cpu/riscv/relocInfo_riscv.cpp line 44:

> 42:     case relocInfo::oop_type: {
> 43:       oop_Relocation *reloc = (oop_Relocation *)this;
> 44:       // in movoop when BarrierSet::barrier_set()->barrier_set_nmethod() != null

isn't

src/hotspot/cpu/riscv/stubGenerator_riscv.cpp line 1774:

> 1772:     //
> 1773: 
> 1774:     // if [src == null] then return -1

is

src/hotspot/cpu/riscv/stubGenerator_riscv.cpp line 1782:

> 1780:     __ bnez(t0, L_failed);
> 1781: 
> 1782:     // if [dst == null] then return -1

is

src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp line 833:

> 831:   Label slow_path;
> 832:   const Register local_0 = c_rarg0;
> 833:   // Check if local 0 != null

isn't

src/hotspot/cpu/riscv/templateTable_riscv.cpp line 3605:

> 3603:   __ bind(done);
> 3604:   // x10 = 0: obj == NULL or  obj is not an instanceof the specified klass
> 3605:   // x10 = 1: obj != NULL and obj is     an instanceof the specified klass

is isn't

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

PR Review: https://git.openjdk.org/jdk/pull/12324#pullrequestreview-1360564245
PR Comment: https://git.openjdk.org/jdk/pull/12324#issuecomment-1477544237
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150268232
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150268320
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150271398
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150271778
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150272066
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150272555
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150272631
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150273041
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150272972
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150273240
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150273666
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150273722
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150273798
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150273929
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150274006
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150275666
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150276157
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150276275
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150276773
PR Review Comment: https://git.openjdk.org/jdk/pull/12324#discussion_r1150277254


More information about the shenandoah-dev mailing list