RFR: JDK-8301074: Replace NULL with nullptr in share/opto/
Vladimir Kozlov
kvn at openjdk.org
Thu Feb 23 01:53:26 UTC 2023
On Fri, 17 Feb 2023 13:35:44 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 59:
>
>> 57: add_java_object(C->top(), PointsToNode::GlobalEscape);
>> 58: phantom_obj = ptnode_adr(C->top()->_idx)->as_JavaObject();
>> 59: // Add ConP(#null) and ConN(#null) nodes.
>
> What does `#NULL` mean?
It means these nodes represent null pointer constant oop in IR graph.
I suggest `// Add ConP and ConN null oop nodes`.
> src/hotspot/share/opto/graphKit.cpp line 1610:
>
>> 1608: BasicType bt,
>> 1609: DecoratorSet decorators) {
>> 1610: // Transformation of a value which could be null pointer (CastPP #null)
>
> `#NULL` pattern
okay `#null`.
> src/hotspot/share/opto/graphKit.cpp line 2406:
>
>> 2404: // [foo] indicates that 'foo' is a parameter
>> 2405: //
>> 2406: // [in] null
>
> null OK here?
OK
> src/hotspot/share/opto/graphKit.cpp line 2744:
>
>> 2742: // hierarchy and we have to scan the secondary superclass list the hard way.
>> 2743: // Worst-case type is a little odd: null is allowed as a result (usually
>> 2744: // klass loads can never produce a null).
>
> nullptr or null?
Keep `null`
> src/hotspot/share/opto/matcher.cpp line 328:
>
>> 326: C->print_method(PHASE_BEFORE_MATCHING, 1);
>> 327:
>> 328: // Create new ideal node ConP #null even if it does exist in old space
>
> `#null` pattern
keep it.
> src/hotspot/share/opto/matcher.cpp line 376:
>
>> 374: }
>> 375:
>> 376: // Generate new mach node for ConP #null
>
> `#null`
keep it.
> src/hotspot/share/opto/matcher.hpp line 173:
>
>> 171: #endif
>> 172:
>> 173: // Mach node for ConP #null
>
> `#null`
keep it.
> src/hotspot/share/opto/node.cpp line 2076:
>
>> 2074: tty->print(" else: shortest path or all paths between this/start and target\n");
>> 2075: tty->print(" options:\n");
>> 2076: tty->print(" if null: same as \"cdmox at B\"\n");
>
> null better here imho
yes
-------------
PR: https://git.openjdk.org/jdk/pull/12187
More information about the hotspot-compiler-dev
mailing list