RFR: 8300086: Replace NULL with nullptr in share/c1/
Johan Sjölen
jsjolen at openjdk.org
Tue May 16 16:05:00 UTC 2023
On Tue, 16 May 2023 12:08:47 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:
> Hi, this PR changes all occurrences of NULL to nullptr for the subdirectory share/c1. 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!
Fairly few issues, very nice!
Added my fixes, running tier1.
src/hotspot/share/c1/c1_GraphBuilder.cpp line 3421:
> 3419:
> 3420: # ifdef ASSERT
> 3421: //All blocks reachable from start_block have _end != null
_end isn't null
src/hotspot/share/c1/c1_GraphBuilder.cpp line 3429:
> 3427: BlockBegin* current = to_go.pop();
> 3428: assert(current != nullptr, "Should not happen.");
> 3429: assert(current->end() != nullptr, "All blocks reachable from start_block should have end() != null.");
`end() != nullptr`
src/hotspot/share/c1/c1_Instruction.hpp line 239:
> 237: if (!(enabled) ) return false; \
> 238: class_name* _v = v->as_##class_name(); \
> 239: if (_v == nullptr ) return false; \
align
src/hotspot/share/c1/c1_Instruction.hpp line 252:
> 250: if (!(enabled) ) return false; \
> 251: class_name* _v = v->as_##class_name(); \
> 252: if (_v == nullptr ) return false; \
align
src/hotspot/share/c1/c1_Instruction.hpp line 266:
> 264: if (!(enabled) ) return false; \
> 265: class_name* _v = v->as_##class_name(); \
> 266: if (_v == nullptr ) return false; \
align
src/hotspot/share/c1/c1_LIRGenerator.cpp line 390:
> 388: assert(instr->subst() == instr, "shouldn't have missed substitution");
> 389: instr->visit(this);
> 390: // assert(instr->use_count() > 0 || instr->as_Phi() != null, "leaf instruction must have a use");
nullptr
src/hotspot/share/c1/c1_LinearScan.cpp line 3483:
> 3481: assert(value->operand()->is_register() && value->operand()->is_virtual(), "value must have virtual operand");
> 3482: assert(value->operand()->vreg_number() == r, "register number must match");
> 3483: // TKR assert(value->as_Constant() == null || value->is_pinned(), "only pinned constants can be alive across block boundaries");
nullptr
src/hotspot/share/c1/c1_Runtime1.cpp line 609:
> 607: // If the stack guard pages are enabled, check whether there is a handler in
> 608: // the current method. Otherwise (guard pages disabled), force an unwind and
> 609: // skip the exception cache update (i.e., just leave continuation==null).
as null
src/hotspot/share/c1/c1_ValueMap.cpp line 157:
> 155: ValueMapEntry* prev_entry = nullptr; \
> 156: for (ValueMapEntry* entry = entry_at(i); entry != nullptr; entry = entry->next()) { \
> 157: Value value = entry->value(); \
align
src/hotspot/share/c1/c1_ValueMap.cpp line 165:
> 163: \
> 164: if (prev_entry == nullptr) { \
> 165: _entries.at_put(i, entry->next()); \
align
src/hotspot/share/c1/c1_ValueMap.cpp line 192:
> 190: LoadField* lf = value->as_LoadField(); \
> 191: bool must_kill = lf != nullptr \
> 192: && lf->field()->holder() == field->holder() \
align
src/hotspot/share/c1/c1_ValueStack.hpp line 256:
> 254: index < temp_var && (value = state->local_at(index), true); \
> 255: index += (value == nullptr || value->type()->is_illegal() ? 1 : value->type()->size())) \
> 256: if (value != nullptr)
align
src/hotspot/share/c1/c1_ValueStack.hpp line 329:
> 327: for_each_local_value(cur_state, cur_index, value) { \
> 328: Phi* v_phi = value->as_Phi(); \
> 329: if (v_phi != nullptr && v_phi->block() == v_block) { \
align
-------------
PR Review: https://git.openjdk.org/jdk/pull/14009#pullrequestreview-1428800775
PR Comment: https://git.openjdk.org/jdk/pull/14009#issuecomment-1549951636
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1195305341
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1195307287
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1195309598
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1195309688
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1195309750
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1195312850
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1195315224
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1195317014
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1195317413
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1195317550
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1195317750
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1195318364
PR Review Comment: https://git.openjdk.org/jdk/pull/14009#discussion_r1195318504
More information about the hotspot-compiler-dev
mailing list