RFR: JDK-8301495: Replace NULL with nullptr in cpu/ppc
Richard Reingruber
rrich at openjdk.org
Wed Mar 15 13:13:37 UTC 2023
On Tue, 31 Jan 2023 11:39:48 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:
> Hi, this PR changes all occurrences of NULL to nullptr for the subdirectory cpu/ppc. 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, just a few changes I'd like to suggest.
Thanks, Richard.
src/hotspot/cpu/ppc/abstractInterpreter_ppc.cpp line 97:
> 95: // Parameters:
> 96: //
> 97: // interpreter_frame != null:
Suggestion:
// interpreter_frame != nullptr:
src/hotspot/cpu/ppc/frame_ppc.cpp line 114:
> 112:
> 113: // At this point, there still is a chance that fp_safe is false.
> 114: // In particular, (fp == null) might be true. So let's check and
Suggestion:
// In particular, (fp == nullptr) might be true. So let's check and
src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp line 920:
> 918: // } else if (THREAD->is_lock_owned((address)displaced_header))
> 919: // // Simple recursive case.
> 920: // monitor->lock()->set_displaced_header(null);
Suggestion:
// monitor->lock()->set_displaced_header(nullptr);
src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp line 981:
> 979: // } else if (THREAD->is_lock_owned((address)displaced_header))
> 980: // // Simple recursive case.
> 981: // monitor->lock()->set_displaced_header(null);
Suggestion:
// monitor->lock()->set_displaced_header(nullptr);
src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp line 1031:
> 1029: // template code:
> 1030: //
> 1031: // if ((displaced_header = monitor->displaced_header()) == null) {
Suggestion:
// if ((displaced_header = monitor->displaced_header()) == nullptr) {
src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp line 1033:
> 1031: // if ((displaced_header = monitor->displaced_header()) == null) {
> 1032: // // Recursive unlock. Mark the monitor unlocked by setting the object field to null.
> 1033: // monitor->set_obj(null);
Suggestion:
// monitor->set_obj(nullptr);
src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp line 1036:
> 1034: // } else if (Atomic::cmpxchg(obj->mark_addr(), monitor, displaced_header) == monitor) {
> 1035: // // We swapped the unlocked mark in displaced_header into the object's mark word.
> 1036: // monitor->set_obj(null);
Suggestion:
// monitor->set_obj(nullptr);
src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp line 1062:
> 1060: // } else if (Atomic::cmpxchg(obj->mark_addr(), monitor, displaced_header) == monitor) {
> 1061: // // We swapped the unlocked mark in displaced_header into the object's mark word.
> 1062: // monitor->set_obj(null);
Suggestion:
// monitor->set_obj(nullptr);
src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp line 1097:
> 1095: b(done); // Monitor register may be overwritten! Runtime has already freed the slot.
> 1096:
> 1097: // Exchange worked, do monitor->set_obj(null);
Suggestion:
// Exchange worked, do monitor->set_obj(nullptr);
src/hotspot/cpu/ppc/interpreterRT_ppc.cpp line 102:
> 100:
> 101: // The handle for a receiver will never be null.
> 102: bool do_nullptr_check = offset() != 0 || is_static();
Suggestion:
bool do_null_check = offset() != 0 || is_static();
src/hotspot/cpu/ppc/interpreterRT_ppc.cpp line 105:
> 103:
> 104: Label do_null;
> 105: if (do_nullptr_check) {
Suggestion:
if (do_null_check) {
src/hotspot/cpu/ppc/stubGenerator_ppc.cpp line 2421:
> 2419: BLOCK_COMMENT("arraycopy initial argument checks");
> 2420:
> 2421: __ cmpdi(CCR1, src, 0); // if (src == null) return -1;
Suggestion:
__ cmpdi(CCR1, src, 0); // if (src == nullptr) return -1;
src/hotspot/cpu/ppc/stubGenerator_ppc.cpp line 2423:
> 2421: __ cmpdi(CCR1, src, 0); // if (src == null) return -1;
> 2422: __ extsw_(src_pos, src_pos); // if (src_pos < 0) return -1;
> 2423: __ cmpdi(CCR5, dst, 0); // if (dst == null) return -1;
Suggestion:
__ cmpdi(CCR5, dst, 0); // if (dst == nullptr) return -1;
src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp line 525:
> 523: __ ld(R3_RET, Interpreter::stackElementSize, R15_esp); // get receiver
> 524:
> 525: // Check if receiver == null and go the slow path.
Suggestion:
// Check if receiver == nullptr and go the slow path.
-------------
Changes requested by rrich (Reviewer).
PR: https://git.openjdk.org/jdk/pull/12323
More information about the shenandoah-dev
mailing list