11/*
2- * Copyright (c) 2016, 2022 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2016, 2023 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
3434#include " utilities/powerOfTwo.hpp"
3535
3636ArrayCopyNode::ArrayCopyNode (Compile* C, bool alloc_tightly_coupled, bool has_negative_length_guard)
37- : CallNode(arraycopy_type(), NULL , TypePtr::BOTTOM),
37+ : CallNode(arraycopy_type(), nullptr , TypePtr::BOTTOM),
3838 _kind(None),
3939 _alloc_tightly_coupled(alloc_tightly_coupled),
4040 _has_negative_length_guard(has_negative_length_guard),
@@ -131,7 +131,7 @@ int ArrayCopyNode::get_count(PhaseGVN *phase) const {
131131 return nb_fields;
132132 } else {
133133 const TypeAryPtr* ary_src = src_type->isa_aryptr ();
134- assert (ary_src != NULL , " not an array or instance?" );
134+ assert (ary_src != nullptr , " not an array or instance?" );
135135 // clone passes a length as a rounded number of longs. If we're
136136 // cloning an array we'll do it element by element. If the
137137 // length input to ArrayCopyNode is constant, length of input
@@ -174,7 +174,7 @@ void ArrayCopyNode::store(BarrierSetC2* bs, PhaseGVN *phase, Node*& ctl, MergeMe
174174
175175Node* ArrayCopyNode::try_clone_instance (PhaseGVN *phase, bool can_reshape, int count) {
176176 if (!is_clonebasic ()) {
177- return NULL ;
177+ return nullptr ;
178178 }
179179
180180 Node* base_src = in (ArrayCopyNode::Src);
@@ -184,8 +184,8 @@ Node* ArrayCopyNode::try_clone_instance(PhaseGVN *phase, bool can_reshape, int c
184184
185185 const Type* src_type = phase->type (base_src);
186186 const TypeInstPtr* inst_src = src_type->isa_instptr ();
187- if (inst_src == NULL ) {
188- return NULL ;
187+ if (inst_src == nullptr ) {
188+ return nullptr ;
189189 }
190190
191191 MergeMemNode* mem = phase->transform (MergeMemNode::make (in_mem))->as_MergeMem ();
@@ -264,8 +264,8 @@ bool ArrayCopyNode::prepare_array_copy(PhaseGVN *phase, bool can_reshape,
264264
265265 // newly allocated object is guaranteed to not overlap with source object
266266 disjoint_bases = is_alloc_tightly_coupled ();
267- if (ary_src == NULL || ary_src->elem () == Type::BOTTOM ||
268- ary_dest == NULL || ary_dest->elem () == Type::BOTTOM) {
267+ if (ary_src == nullptr || ary_src->elem () == Type::BOTTOM ||
268+ ary_dest == nullptr || ary_dest->elem () == Type::BOTTOM) {
269269 // We don't know if arguments are arrays
270270 return false ;
271271 }
@@ -324,7 +324,7 @@ bool ArrayCopyNode::prepare_array_copy(PhaseGVN *phase, bool can_reshape,
324324
325325 copy_type = dest_elem;
326326 } else {
327- assert (ary_src != NULL , " should be a clone" );
327+ assert (ary_src != nullptr , " should be a clone" );
328328 assert (is_clonebasic (), " should be" );
329329
330330 disjoint_bases = true ;
@@ -372,7 +372,7 @@ void ArrayCopyNode::array_copy_test_overlap(PhaseGVN *phase, bool can_reshape, b
372372 if (!disjoint_bases && count > 1 ) {
373373 Node* src_offset = in (ArrayCopyNode::SrcPos);
374374 Node* dest_offset = in (ArrayCopyNode::DestPos);
375- assert (src_offset != NULL && dest_offset != NULL , " should be" );
375+ assert (src_offset != nullptr && dest_offset != nullptr , " should be" );
376376 Node* cmp = phase->transform (new CmpINode (src_offset, dest_offset));
377377 Node *bol = phase->transform (new BoolNode (cmp, BoolTest::lt));
378378 IfNode *iff = new IfNode (ctl, bol, PROB_FAIR, COUNT_UNKNOWN);
@@ -489,13 +489,13 @@ bool ArrayCopyNode::finish_transform(PhaseGVN *phase, bool can_reshape,
489489 CallProjections callprojs;
490490 extract_projections (&callprojs, true , false );
491491
492- if (callprojs.fallthrough_ioproj != NULL ) {
492+ if (callprojs.fallthrough_ioproj != nullptr ) {
493493 igvn->replace_node (callprojs.fallthrough_ioproj , in (TypeFunc::I_O));
494494 }
495- if (callprojs.fallthrough_memproj != NULL ) {
495+ if (callprojs.fallthrough_memproj != nullptr ) {
496496 igvn->replace_node (callprojs.fallthrough_memproj , mem);
497497 }
498- if (callprojs.fallthrough_catchproj != NULL ) {
498+ if (callprojs.fallthrough_catchproj != nullptr ) {
499499 igvn->replace_node (callprojs.fallthrough_catchproj , ctl);
500500 }
501501
@@ -525,7 +525,7 @@ Node *ArrayCopyNode::Ideal(PhaseGVN *phase, bool can_reshape) {
525525
526526 if (StressArrayCopyMacroNode && !can_reshape) {
527527 phase->record_for_igvn (this );
528- return NULL ;
528+ return nullptr ;
529529 }
530530
531531 // See if it's a small array copy and we can inline it as
@@ -537,51 +537,51 @@ Node *ArrayCopyNode::Ideal(PhaseGVN *phase, bool can_reshape) {
537537
538538 if (!is_clonebasic () && !is_arraycopy_validated () &&
539539 !is_copyofrange_validated () && !is_copyof_validated ()) {
540- return NULL ;
540+ return nullptr ;
541541 }
542542
543- assert (in (TypeFunc::Control) != NULL &&
544- in (TypeFunc::Memory) != NULL &&
545- in (ArrayCopyNode::Src) != NULL &&
546- in (ArrayCopyNode::Dest) != NULL &&
547- in (ArrayCopyNode::Length) != NULL &&
548- in (ArrayCopyNode::SrcPos) != NULL &&
549- in (ArrayCopyNode::DestPos) != NULL , " broken inputs" );
543+ assert (in (TypeFunc::Control) != nullptr &&
544+ in (TypeFunc::Memory) != nullptr &&
545+ in (ArrayCopyNode::Src) != nullptr &&
546+ in (ArrayCopyNode::Dest) != nullptr &&
547+ in (ArrayCopyNode::Length) != nullptr &&
548+ in (ArrayCopyNode::SrcPos) != nullptr &&
549+ in (ArrayCopyNode::DestPos) != nullptr , " broken inputs" );
550550
551551 if (in (TypeFunc::Control)->is_top () ||
552552 in (TypeFunc::Memory)->is_top () ||
553553 phase->type (in (ArrayCopyNode::Src)) == Type::TOP ||
554554 phase->type (in (ArrayCopyNode::Dest)) == Type::TOP ||
555- (in (ArrayCopyNode::SrcPos) != NULL && in (ArrayCopyNode::SrcPos)->is_top ()) ||
556- (in (ArrayCopyNode::DestPos) != NULL && in (ArrayCopyNode::DestPos)->is_top ())) {
557- return NULL ;
555+ (in (ArrayCopyNode::SrcPos) != nullptr && in (ArrayCopyNode::SrcPos)->is_top ()) ||
556+ (in (ArrayCopyNode::DestPos) != nullptr && in (ArrayCopyNode::DestPos)->is_top ())) {
557+ return nullptr ;
558558 }
559559
560560 int count = get_count (phase);
561561
562562 if (count < 0 || count > ArrayCopyLoadStoreMaxElem) {
563- return NULL ;
563+ return nullptr ;
564564 }
565565
566566 Node* mem = try_clone_instance (phase, can_reshape, count);
567- if (mem != NULL ) {
568- return (mem == NodeSentinel) ? NULL : mem;
567+ if (mem != nullptr ) {
568+ return (mem == NodeSentinel) ? nullptr : mem;
569569 }
570570
571- Node* adr_src = NULL ;
572- Node* base_src = NULL ;
573- Node* adr_dest = NULL ;
574- Node* base_dest = NULL ;
571+ Node* adr_src = nullptr ;
572+ Node* base_src = nullptr ;
573+ Node* adr_dest = nullptr ;
574+ Node* base_dest = nullptr ;
575575 BasicType copy_type = T_ILLEGAL;
576- const Type* value_type = NULL ;
576+ const Type* value_type = nullptr ;
577577 bool disjoint_bases = false ;
578578
579579 if (!prepare_array_copy (phase, can_reshape,
580580 adr_src, base_src, adr_dest, base_dest,
581581 copy_type, value_type, disjoint_bases)) {
582- assert (adr_src == NULL , " no node can be left behind" );
583- assert (adr_dest == NULL , " no node can be left behind" );
584- return NULL ;
582+ assert (adr_src == nullptr , " no node can be left behind" );
583+ assert (adr_dest == nullptr , " no node can be left behind" );
584+ return nullptr ;
585585 }
586586
587587 Node* src = in (ArrayCopyNode::Src);
@@ -611,7 +611,7 @@ Node *ArrayCopyNode::Ideal(PhaseGVN *phase, bool can_reshape) {
611611 adr_src, base_src, adr_dest, base_dest,
612612 copy_type, value_type, count);
613613
614- Node* ctl = NULL ;
614+ Node* ctl = nullptr ;
615615 if (!forward_ctl->is_top () && !backward_ctl->is_top ()) {
616616 ctl = new RegionNode (3 );
617617 ctl->init_req (1 , forward_ctl);
@@ -648,7 +648,7 @@ Node *ArrayCopyNode::Ideal(PhaseGVN *phase, bool can_reshape) {
648648 // put in worklist, so that if it happens to be dead it is removed
649649 phase->is_IterGVN ()->_worklist .push (mem);
650650 }
651- return NULL ;
651+ return nullptr ;
652652 }
653653
654654 return mem;
@@ -673,7 +673,7 @@ bool ArrayCopyNode::may_modify(const TypeOopPtr *t_oop, PhaseTransform *phase) {
673673}
674674
675675bool ArrayCopyNode::may_modify_helper (const TypeOopPtr *t_oop, Node* n, PhaseTransform *phase, CallNode*& call) {
676- if (n != NULL &&
676+ if (n != nullptr &&
677677 n->is_Call () &&
678678 n->as_Call ()->may_modify (t_oop, phase) &&
679679 (n->as_Call ()->is_ArrayCopy () || n->as_Call ()->is_call_to_arraycopystub ())) {
@@ -691,11 +691,11 @@ bool ArrayCopyNode::may_modify(const TypeOopPtr *t_oop, MemBarNode* mb, PhaseTra
691691 // step over g1 gc barrier if we're at e.g. a clone with ReduceInitialCardMarks off
692692 c = bs->step_over_gc_barrier (c);
693693
694- CallNode* call = NULL ;
695- guarantee (c != NULL , " step_over_gc_barrier failed, there must be something to step to." );
694+ CallNode* call = nullptr ;
695+ guarantee (c != nullptr , " step_over_gc_barrier failed, there must be something to step to." );
696696 if (c->is_Region ()) {
697697 for (uint i = 1 ; i < c->req (); i++) {
698- if (c->in (i) != NULL ) {
698+ if (c->in (i) != nullptr ) {
699699 Node* n = c->in (i)->in (0 );
700700 if (may_modify_helper (t_oop, n, phase, call)) {
701701 ac = call->isa_ArrayCopy ();
@@ -709,7 +709,7 @@ bool ArrayCopyNode::may_modify(const TypeOopPtr *t_oop, MemBarNode* mb, PhaseTra
709709#ifdef ASSERT
710710 bool use_ReduceInitialCardMarks = BarrierSet::barrier_set ()->is_a (BarrierSet::CardTableBarrierSet) &&
711711 static_cast <CardTableBarrierSetC2*>(bs)->use_ReduceInitialCardMarks ();
712- assert (c == mb->in (0 ) || (ac != NULL && ac->is_clonebasic () && !use_ReduceInitialCardMarks), " only for clone" );
712+ assert (c == mb->in (0 ) || (ac != nullptr && ac->is_clonebasic () && !use_ReduceInitialCardMarks), " only for clone" );
713713#endif
714714 return true ;
715715 } else if (mb->trailing_partial_array_copy ()) {
@@ -736,7 +736,7 @@ bool ArrayCopyNode::modifies(intptr_t offset_lo, intptr_t offset_hi, PhaseTransf
736736 const TypeInt *len_t = phase->type (len)->isa_int ();
737737 const TypeAryPtr* ary_t = phase->type (dest)->isa_aryptr ();
738738
739- if (dest_pos_t == NULL || len_t == NULL || ary_t == NULL ) {
739+ if (dest_pos_t == nullptr || len_t == nullptr || ary_t == nullptr ) {
740740 return !must_modify;
741741 }
742742
0 commit comments