RFR: JDK-8301074: Replace NULL with nullptr in share/opto/
Johan Sjölen
jsjolen at openjdk.org
Mon Feb 20 12:56:03 UTC 2023
On Fri, 17 Feb 2023 13:37:02 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:
>> Hi, this PR changes all occurrences of NULL to nullptr for the subdirectory share/opto/. 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:
>>
>> No changes but copyright header changed (probably because I reverted some changes but forgot the copyright).
>> Macros having their NULL changed to nullptr, these are added to the script when I find them. They should be NULL.
>> 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:
>>
>>
>> // 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!
>
> src/hotspot/share/opto/escape.cpp line 2344:
>
>> 2342: }
>> 2343:
>> 2344: // Returns unique pointed java object or null.
>
> Use nullptr explicitly here?
No, not necessary.
> src/hotspot/share/opto/gcm.cpp line 1212:
>
>> 1210: // Bailout without retry
>> 1211: assert(false, "graph should be schedulable");
>> 1212: C->record_method_not_compilable("late schedule failed: LCA == null");
>
> nullptr
is
> src/hotspot/share/opto/runtime.cpp line 1550:
>
>> 1548: SharedRuntime::_rethrow_ctr++; // count rethrows
>> 1549: #endif
>> 1550: assert (exception != nullptr, "should have thrown a nullPointerException");
>
> Weird looking from the start, surely NullPointerException is the correct one?
I changed it to NullPointerException, avoiding resolving for now.
> src/hotspot/share/opto/stringopts.cpp line 130:
>
>> 128: // Look for a diamond shaped Null check of toString() result
>> 129: // (could be code from String.valueOf()):
>> 130: // (Proj == null) ? "null":"CastPP(Proj)#Notnull
>
> nullptr
Also has a missing ". Should it be `CastPP(proj)#NotNull`?
-------------
PR: https://git.openjdk.org/jdk/pull/12187
More information about the hotspot-compiler-dev
mailing list