RFR: JDK-8301074: Replace NULL with nullptr in share/opto/

Johan Sjölen jsjolen at openjdk.org
Mon Feb 27 10:49:36 UTC 2023


On Wed, 22 Feb 2023 23:21:16 GMT, Vladimir Kozlov <kvn 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/graphKit.cpp line 522:
> 
>> 520:       // Cf. case Bytecodes::_athrow in parse2.cpp.
>> 521:       uncommon_trap(reason, Deoptimization::Action_none,
>> 522:                     (ciKlass*)nullptr, (char*)nullptr, must_throw);
> 
> Do we need these casts? I am still not sure when casts should be used with `nullptr`.

If the function is overloaded `foo(void* x); foo(int* x);` or templated `template<typename T> foo(T* x);` then you have to cast `nullptr`. Perhaps there are more cases. In this case, `uncommon_trap` is overloaded.

> src/hotspot/share/opto/graphKit.cpp line 653:
> 
>> 651:   // of in-edges on the call to the uncommon trap.
>> 652: 
>> 653:   uncommon_trap(reason, action, (ciKlass*)nullptr, (char*)nullptr, must_throw);
> 
> Casts?

`uncommon_trap` overloaded

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

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


More information about the hotspot-compiler-dev mailing list