From cfe57466ddecb93b528478d0b053b089dd1ed285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Sj=C3=B6len?= Date: Thu, 19 Jan 2023 08:48:36 +0000 Subject: [PATCH] 8300242: Replace NULL with nullptr in share/code/ Reviewed-by: kvn, thartmann --- src/hotspot/share/code/codeBehaviours.cpp | 4 +- src/hotspot/share/code/codeBlob.cpp | 58 ++-- src/hotspot/share/code/codeBlob.hpp | 6 +- src/hotspot/share/code/codeBlob.inline.hpp | 4 +- src/hotspot/share/code/codeCache.cpp | 98 +++--- src/hotspot/share/code/codeCache.hpp | 26 +- src/hotspot/share/code/codeCache.inline.hpp | 8 +- src/hotspot/share/code/codeHeapState.cpp | 224 ++++++------ src/hotspot/share/code/compiledIC.cpp | 96 ++--- src/hotspot/share/code/compiledIC.hpp | 10 +- src/hotspot/share/code/compiledMethod.cpp | 86 ++--- src/hotspot/share/code/compiledMethod.hpp | 10 +- .../share/code/compiledMethod.inline.hpp | 8 +- src/hotspot/share/code/compressedStream.cpp | 4 +- src/hotspot/share/code/debugInfo.cpp | 20 +- src/hotspot/share/code/debugInfo.hpp | 8 +- src/hotspot/share/code/debugInfoRec.cpp | 18 +- src/hotspot/share/code/debugInfoRec.hpp | 8 +- src/hotspot/share/code/dependencies.cpp | 328 +++++++++--------- src/hotspot/share/code/dependencies.hpp | 92 ++--- src/hotspot/share/code/dependencyContext.cpp | 38 +- src/hotspot/share/code/dependencyContext.hpp | 4 +- .../share/code/exceptionHandlerTable.cpp | 20 +- .../share/code/exceptionHandlerTable.hpp | 6 +- src/hotspot/share/code/icBuffer.cpp | 30 +- src/hotspot/share/code/icBuffer.hpp | 6 +- src/hotspot/share/code/nmethod.cpp | 310 ++++++++--------- src/hotspot/share/code/nmethod.hpp | 24 +- src/hotspot/share/code/oopRecorder.cpp | 34 +- src/hotspot/share/code/oopRecorder.hpp | 22 +- src/hotspot/share/code/oopRecorder.inline.hpp | 4 +- src/hotspot/share/code/pcDesc.cpp | 4 +- src/hotspot/share/code/relocInfo.cpp | 106 +++--- src/hotspot/share/code/relocInfo.hpp | 48 +-- src/hotspot/share/code/scopeDesc.cpp | 24 +- src/hotspot/share/code/scopeDesc.hpp | 8 +- src/hotspot/share/code/stubs.cpp | 24 +- src/hotspot/share/code/stubs.hpp | 10 +- src/hotspot/share/code/vmreg.cpp | 4 +- src/hotspot/share/code/vtableStubs.cpp | 32 +- src/hotspot/share/code/vtableStubs.hpp | 6 +- 41 files changed, 940 insertions(+), 940 deletions(-) diff --git a/src/hotspot/share/code/codeBehaviours.cpp b/src/hotspot/share/code/codeBehaviours.cpp index c0605c61bf7..279eca4738e 100644 --- a/src/hotspot/share/code/codeBehaviours.cpp +++ b/src/hotspot/share/code/codeBehaviours.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ #include "runtime/mutexLocker.hpp" #include "runtime/safepoint.hpp" -CompiledICProtectionBehaviour* CompiledICProtectionBehaviour::_current = NULL; +CompiledICProtectionBehaviour* CompiledICProtectionBehaviour::_current = nullptr; bool DefaultICProtectionBehaviour::lock(CompiledMethod* method) { if (is_safe(method)) { diff --git a/src/hotspot/share/code/codeBlob.cpp b/src/hotspot/share/code/codeBlob.cpp index c71a5dc3dee..18843ad9622 100644 --- a/src/hotspot/share/code/codeBlob.cpp +++ b/src/hotspot/share/code/codeBlob.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -140,7 +140,7 @@ CodeBlob::CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& la // Creates a simple CodeBlob. Sets up the size of the different regions. RuntimeBlob::RuntimeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size) - : CodeBlob(name, compiler_none, CodeBlobLayout((address) this, size, header_size, locs_size, size), frame_complete, 0, NULL, false /* caller_must_gc_arguments */) + : CodeBlob(name, compiler_none, CodeBlobLayout((address) this, size, header_size, locs_size, size), frame_complete, 0, nullptr, false /* caller_must_gc_arguments */) { assert(is_aligned(locs_size, oopSize), "unaligned size"); } @@ -162,7 +162,7 @@ RuntimeBlob::RuntimeBlob( } void RuntimeBlob::free(RuntimeBlob* blob) { - assert(blob != NULL, "caller must check for NULL"); + assert(blob != nullptr, "caller must check for nullptr"); ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock blob->flush(); { @@ -175,7 +175,7 @@ void RuntimeBlob::free(RuntimeBlob* blob) { void CodeBlob::flush() { FREE_C_HEAP_ARRAY(unsigned char, _oop_maps); - _oop_maps = NULL; + _oop_maps = nullptr; NOT_PRODUCT(_asm_remarks.clear()); NOT_PRODUCT(_dbg_strings.clear()); } @@ -183,10 +183,10 @@ void CodeBlob::flush() { void CodeBlob::set_oop_maps(OopMapSet* p) { // Danger Will Robinson! This method allocates a big // chunk of memory, its your job to free it. - if (p != NULL) { + if (p != nullptr) { _oop_maps = ImmutableOopMapSet::build_from(p); } else { - _oop_maps = NULL; + _oop_maps = nullptr; } } @@ -195,7 +195,7 @@ void RuntimeBlob::trace_new_stub(RuntimeBlob* stub, const char* name1, const cha // Do not hold the CodeCache lock during name formatting. assert(!CodeCache_lock->owned_by_self(), "release CodeCache before registering the stub"); - if (stub != NULL && (PrintStubCode || + if (stub != nullptr && (PrintStubCode || Forte::is_enabled() || JvmtiExport::should_post_dynamic_code_generated())) { char stub_id[256]; @@ -207,7 +207,7 @@ void RuntimeBlob::trace_new_stub(RuntimeBlob* stub, const char* name1, const cha tty->print_cr("Decoding %s " INTPTR_FORMAT, stub_id, (intptr_t) stub); Disassembler::decode(stub->code_begin(), stub->code_end(), tty NOT_PRODUCT(COMMA &stub->asm_remarks())); - if ((stub->oop_maps() != NULL) && AbstractDisassembler::show_structs()) { + if ((stub->oop_maps() != nullptr) && AbstractDisassembler::show_structs()) { tty->print_cr("- - - [OOP MAPS]- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); stub->oop_maps()->print(); } @@ -230,7 +230,7 @@ void RuntimeBlob::trace_new_stub(RuntimeBlob* stub, const char* name1, const cha } const ImmutableOopMap* CodeBlob::oop_map_for_return_address(address return_address) const { - assert(_oop_maps != NULL, "nope"); + assert(_oop_maps != nullptr, "nope"); return _oop_maps->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin()); } @@ -250,12 +250,12 @@ BufferBlob::BufferBlob(const char* name, int size) BufferBlob* BufferBlob::create(const char* name, int buffer_size) { ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock - BufferBlob* blob = NULL; + BufferBlob* blob = nullptr; unsigned int size = sizeof(BufferBlob); // align the size to CodeEntryAlignment size = CodeBlob::align_code_offset(size); size += align_up(buffer_size, oopSize); - assert(name != NULL, "must provide a name"); + assert(name != nullptr, "must provide a name"); { MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); blob = new (size) BufferBlob(name, size); @@ -268,15 +268,15 @@ BufferBlob* BufferBlob::create(const char* name, int buffer_size) { BufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb) - : RuntimeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, NULL) + : RuntimeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, nullptr) {} BufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) { ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock - BufferBlob* blob = NULL; + BufferBlob* blob = nullptr; unsigned int size = CodeBlob::allocation_size(cb, sizeof(BufferBlob)); - assert(name != NULL, "must provide a name"); + assert(name != nullptr, "must provide a name"); { MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); blob = new (size) BufferBlob(name, size, cb); @@ -309,7 +309,7 @@ AdapterBlob* AdapterBlob::create(CodeBuffer* cb) { CodeCache::gc_on_allocation(); - AdapterBlob* blob = NULL; + AdapterBlob* blob = nullptr; unsigned int size = CodeBlob::allocation_size(cb, sizeof(AdapterBlob)); { MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); @@ -338,12 +338,12 @@ VtableBlob::VtableBlob(const char* name, int size) : VtableBlob* VtableBlob::create(const char* name, int buffer_size) { assert(JavaThread::current()->thread_state() == _thread_in_vm, "called with the wrong state"); - VtableBlob* blob = NULL; + VtableBlob* blob = nullptr; unsigned int size = sizeof(VtableBlob); // align the size to CodeEntryAlignment size = align_code_offset(size); size += align_up(buffer_size, oopSize); - assert(name != NULL, "must provide a name"); + assert(name != nullptr, "must provide a name"); { if (!CodeCache_lock->try_lock()) { // If we can't take the CodeCache_lock, then this is a bad time to perform the ongoing @@ -356,7 +356,7 @@ VtableBlob* VtableBlob::create(const char* name, int buffer_size) { // consistently taken in the opposite order. Bailing out results in an IC transition to // the clean state instead, which will cause subsequent calls to retry the transitioning // eventually. - return NULL; + return nullptr; } blob = new (size) VtableBlob(name, size); CodeCache_lock->unlock(); @@ -373,7 +373,7 @@ VtableBlob* VtableBlob::create(const char* name, int buffer_size) { MethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) { ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock - MethodHandlesAdapterBlob* blob = NULL; + MethodHandlesAdapterBlob* blob = nullptr; unsigned int size = sizeof(MethodHandlesAdapterBlob); // align the size to CodeEntryAlignment size = CodeBlob::align_code_offset(size); @@ -381,7 +381,7 @@ MethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) { { MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); blob = new (size) MethodHandlesAdapterBlob(size); - if (blob == NULL) { + if (blob == nullptr) { vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "CodeCache: no room for method handle adapter blob"); } } @@ -414,7 +414,7 @@ RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name, OopMapSet* oop_maps, bool caller_must_gc_arguments) { - RuntimeStub* stub = NULL; + RuntimeStub* stub = nullptr; unsigned int size = CodeBlob::allocation_size(cb, sizeof(RuntimeStub)); ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock { @@ -473,7 +473,7 @@ DeoptimizationBlob* DeoptimizationBlob::create( int unpack_with_reexecution_offset, int frame_size) { - DeoptimizationBlob* blob = NULL; + DeoptimizationBlob* blob = nullptr; unsigned int size = CodeBlob::allocation_size(cb, sizeof(DeoptimizationBlob)); ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock { @@ -512,7 +512,7 @@ UncommonTrapBlob* UncommonTrapBlob::create( OopMapSet* oop_maps, int frame_size) { - UncommonTrapBlob* blob = NULL; + UncommonTrapBlob* blob = nullptr; unsigned int size = CodeBlob::allocation_size(cb, sizeof(UncommonTrapBlob)); ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock { @@ -548,7 +548,7 @@ ExceptionBlob* ExceptionBlob::create( OopMapSet* oop_maps, int frame_size) { - ExceptionBlob* blob = NULL; + ExceptionBlob* blob = nullptr; unsigned int size = CodeBlob::allocation_size(cb, sizeof(ExceptionBlob)); ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock { @@ -583,7 +583,7 @@ SafepointBlob* SafepointBlob::create( OopMapSet* oop_maps, int frame_size) { - SafepointBlob* blob = NULL; + SafepointBlob* blob = nullptr; unsigned int size = CodeBlob::allocation_size(cb, sizeof(SafepointBlob)); ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock { @@ -615,7 +615,7 @@ void CodeBlob::dump_for_addr(address addr, outputStream* st, bool verbose) const if (is_buffer_blob()) { // the interpreter is generated into a buffer blob InterpreterCodelet* i = Interpreter::codelet_containing(addr); - if (i != NULL) { + if (i != nullptr) { st->print_cr(INTPTR_FORMAT " is at code_begin+%d in an Interpreter codelet", p2i(addr), (int)(addr - i->code_begin())); i->print_on(st); return; @@ -632,7 +632,7 @@ void CodeBlob::dump_for_addr(address addr, outputStream* st, bool verbose) const } // the stubroutines are generated into a buffer blob StubCodeDesc* d = StubCodeDesc::desc_for(addr); - if (d != NULL) { + if (d != nullptr) { st->print_cr(INTPTR_FORMAT " is at begin+%d in a stub", p2i(addr), (int)(addr - d->begin())); d->print_on(st); st->cr(); @@ -648,7 +648,7 @@ void CodeBlob::dump_for_addr(address addr, outputStream* st, bool verbose) const return; } VtableStub* v = VtableStubs::stub_containing(addr); - if (v != NULL) { + if (v != nullptr) { st->print_cr(INTPTR_FORMAT " is at entry_point+%d in a vtable stub", p2i(addr), (int)(addr - v->entry_point())); v->print_on(st); st->cr(); @@ -775,7 +775,7 @@ JavaFrameAnchor* UpcallStub::jfa_for_frame(const frame& frame) const { } void UpcallStub::free(UpcallStub* blob) { - assert(blob != nullptr, "caller must check for NULL"); + assert(blob != nullptr, "caller must check for nullptr"); JNIHandles::destroy_global(blob->receiver()); RuntimeBlob::free(blob); } diff --git a/src/hotspot/share/code/codeBlob.hpp b/src/hotspot/share/code/codeBlob.hpp index 8e66deb914e..eb7f49b185a 100644 --- a/src/hotspot/share/code/codeBlob.hpp +++ b/src/hotspot/share/code/codeBlob.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -165,9 +165,9 @@ public: CompilerType compiler_type() const { return _type; } // Casting - nmethod* as_nmethod_or_null() { return is_nmethod() ? (nmethod*) this : NULL; } + nmethod* as_nmethod_or_null() { return is_nmethod() ? (nmethod*) this : nullptr; } nmethod* as_nmethod() { assert(is_nmethod(), "must be nmethod"); return (nmethod*) this; } - CompiledMethod* as_compiled_method_or_null() { return is_compiled() ? (CompiledMethod*) this : NULL; } + CompiledMethod* as_compiled_method_or_null() { return is_compiled() ? (CompiledMethod*) this : nullptr; } CompiledMethod* as_compiled_method() { assert(is_compiled(), "must be compiled"); return (CompiledMethod*) this; } CodeBlob* as_codeblob_or_null() const { return (CodeBlob*) this; } UpcallStub* as_upcall_stub() const { assert(is_upcall_stub(), "must be upcall stub"); return (UpcallStub*) this; } diff --git a/src/hotspot/share/code/codeBlob.inline.hpp b/src/hotspot/share/code/codeBlob.inline.hpp index 9fce879a67e..bd49fdba210 100644 --- a/src/hotspot/share/code/codeBlob.inline.hpp +++ b/src/hotspot/share/code/codeBlob.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ #include "utilities/globalDefinitions.hpp" inline const ImmutableOopMap* CodeBlob::oop_map_for_slot(int slot, address return_address) const { - assert(_oop_maps != NULL, "nope"); + assert(_oop_maps != nullptr, "nope"); return _oop_maps->find_map_at_slot(slot, (intptr_t) return_address - (intptr_t) code_begin()); } diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index 1ecefbe26c2..e4537c11f99 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -163,12 +163,12 @@ class CodeBlob_sizes { #define FOR_ALL_ALLOCABLE_HEAPS(heap) for (GrowableArrayIterator heap = _allocable_heaps->begin(); heap != _allocable_heaps->end(); ++heap) // Iterate over all CodeBlobs (cb) on the given CodeHeap -#define FOR_ALL_BLOBS(cb, heap) for (CodeBlob* cb = first_blob(heap); cb != NULL; cb = next_blob(heap, cb)) +#define FOR_ALL_BLOBS(cb, heap) for (CodeBlob* cb = first_blob(heap); cb != nullptr; cb = next_blob(heap, cb)) address CodeCache::_low_bound = 0; address CodeCache::_high_bound = 0; int CodeCache::_number_of_nmethods_with_dependencies = 0; -ExceptionCache* volatile CodeCache::_exception_cache_purge_list = NULL; +ExceptionCache* volatile CodeCache::_exception_cache_purge_list = nullptr; // Initialize arrays of CodeHeap subsets GrowableArray* CodeCache::_heaps = new(mtCode) GrowableArray (static_cast(CodeBlobType::All), mtCode); @@ -398,7 +398,7 @@ const char* CodeCache::get_code_heap_flag_name(CodeBlobType code_blob_type) { break; default: ShouldNotReachHere(); - return NULL; + return nullptr; } } @@ -455,18 +455,18 @@ CodeHeap* CodeCache::get_code_heap_containing(void* start) { return *heap; } } - return NULL; + return nullptr; } CodeHeap* CodeCache::get_code_heap(const CodeBlob* cb) { - assert(cb != NULL, "CodeBlob is null"); + assert(cb != nullptr, "CodeBlob is null"); FOR_ALL_HEAPS(heap) { if ((*heap)->contains_blob(cb)) { return *heap; } } ShouldNotReachHere(); - return NULL; + return nullptr; } CodeHeap* CodeCache::get_code_heap(CodeBlobType code_blob_type) { @@ -475,12 +475,12 @@ CodeHeap* CodeCache::get_code_heap(CodeBlobType code_blob_type) { return *heap; } } - return NULL; + return nullptr; } CodeBlob* CodeCache::first_blob(CodeHeap* heap) { assert_locked_or_safepoint(CodeCache_lock); - assert(heap != NULL, "heap is null"); + assert(heap != nullptr, "heap is null"); return (CodeBlob*)heap->first(); } @@ -488,13 +488,13 @@ CodeBlob* CodeCache::first_blob(CodeBlobType code_blob_type) { if (heap_available(code_blob_type)) { return first_blob(get_code_heap(code_blob_type)); } else { - return NULL; + return nullptr; } } CodeBlob* CodeCache::next_blob(CodeHeap* heap, CodeBlob* cb) { assert_locked_or_safepoint(CodeCache_lock); - assert(heap != NULL, "heap is null"); + assert(heap != nullptr, "heap is null"); return (CodeBlob*)heap->next(cb); } @@ -509,17 +509,17 @@ CodeBlob* CodeCache::allocate(int size, CodeBlobType code_blob_type, bool handle assert_locked_or_safepoint(CodeCache_lock); assert(size > 0, "Code cache allocation request must be > 0 but is %d", size); if (size <= 0) { - return NULL; + return nullptr; } - CodeBlob* cb = NULL; + CodeBlob* cb = nullptr; // Get CodeHeap for the given CodeBlobType CodeHeap* heap = get_code_heap(code_blob_type); - assert(heap != NULL, "heap is null"); + assert(heap != nullptr, "heap is null"); while (true) { cb = (CodeBlob*)heap->allocate(size); - if (cb != NULL) break; + if (cb != nullptr) break; if (!heap->expand_by(CodeCacheExpansionSize)) { // Save original type for error reporting if (orig_code_blob_type == CodeBlobType::All) { @@ -558,7 +558,7 @@ CodeBlob* CodeCache::allocate(int size, CodeBlobType code_blob_type, bool handle MutexUnlocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); CompileBroker::handle_full_code_cache(orig_code_blob_type); } - return NULL; + return nullptr; } if (PrintCodeCacheExtension) { ResourceMark rm; @@ -632,7 +632,7 @@ void CodeCache::commit(CodeBlob* cb) { bool CodeCache::contains(void *p) { // S390 uses contains() in current_frame(), which is used before // code cache initialization if NativeMemoryTracking=detail is set. - S390_ONLY(if (_heaps == NULL) return false;) + S390_ONLY(if (_heaps == nullptr) return false;) // It should be ok to call contains without holding a lock. FOR_ALL_HEAPS(heap) { if ((*heap)->contains(p)) { @@ -650,13 +650,13 @@ bool CodeCache::contains(nmethod *nm) { // valid indices, which it will always do, as long as the CodeBlob is not in the process of being recycled. CodeBlob* CodeCache::find_blob(void* start) { // NMT can walk the stack before code cache is created - if (_heaps != NULL) { + if (_heaps != nullptr) { CodeHeap* heap = get_code_heap_containing(start); - if (heap != NULL) { + if (heap != nullptr) { return heap->find_blob(start); } } - return NULL; + return nullptr; } nmethod* CodeCache::find_nmethod(void* start) { @@ -871,7 +871,7 @@ void CodeCache::on_gc_marking_cycle_finish() { void CodeCache::arm_all_nmethods() { BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod(); - if (bs_nm != NULL) { + if (bs_nm != nullptr) { bs_nm->arm_all_nmethods(); } } @@ -917,7 +917,7 @@ void CodeCache::verify_icholder_relocations() { FOR_ALL_HEAPS(heap) { FOR_ALL_BLOBS(cb, *heap) { CompiledMethod *nm = cb->as_compiled_method_or_null(); - if (nm != NULL) { + if (nm != nullptr) { count += nm->verify_icholder_relocations(); } } @@ -947,22 +947,22 @@ void CodeCache::release_exception_cache(ExceptionCache* entry) { // followed by a global handshake operation. void CodeCache::purge_exception_caches() { ExceptionCache* curr = _exception_cache_purge_list; - while (curr != NULL) { + while (curr != nullptr) { ExceptionCache* next = curr->purge_list_next(); delete curr; curr = next; } - _exception_cache_purge_list = NULL; + _exception_cache_purge_list = nullptr; } // Register an is_unloading nmethod to be flushed after unlinking void CodeCache::register_unlinked(nmethod* nm) { - assert(nm->unlinked_next() == NULL, "Only register for unloading once"); + assert(nm->unlinked_next() == nullptr, "Only register for unloading once"); for (;;) { // Only need acquire when reading the head, when the next // pointer is walked, which it is not here. nmethod* head = Atomic::load(&_unlinked_head); - nmethod* next = head != NULL ? head : nm; // Self looped means end of list + nmethod* next = head != nullptr ? head : nm; // Self looped means end of list nm->set_unlinked_next(next); if (Atomic::cmpxchg(&_unlinked_head, head, nm) == head) { break; @@ -973,9 +973,9 @@ void CodeCache::register_unlinked(nmethod* nm) { // Flush all the nmethods the GC unlinked void CodeCache::flush_unlinked_nmethods() { nmethod* nm = _unlinked_head; - _unlinked_head = NULL; + _unlinked_head = nullptr; size_t freed_memory = 0; - while (nm != NULL) { + while (nm != nullptr) { nmethod* next = nm->unlinked_next(); freed_memory += nm->total_size(); nm->flush(); @@ -998,7 +998,7 @@ void CodeCache::flush_unlinked_nmethods() { } uint8_t CodeCache::_unloading_cycle = 1; -nmethod* volatile CodeCache::_unlinked_head = NULL; +nmethod* volatile CodeCache::_unlinked_head = nullptr; void CodeCache::increment_unloading_cycle() { // 2-bit value (see IsUnloadingState in nmethod.cpp for details) @@ -1037,7 +1037,7 @@ void CodeCache::verify_oops() { int CodeCache::blob_count(CodeBlobType code_blob_type) { CodeHeap* heap = get_code_heap(code_blob_type); - return (heap != NULL) ? heap->blob_count() : 0; + return (heap != nullptr) ? heap->blob_count() : 0; } int CodeCache::blob_count() { @@ -1050,7 +1050,7 @@ int CodeCache::blob_count() { int CodeCache::nmethod_count(CodeBlobType code_blob_type) { CodeHeap* heap = get_code_heap(code_blob_type); - return (heap != NULL) ? heap->nmethod_count() : 0; + return (heap != nullptr) ? heap->nmethod_count() : 0; } int CodeCache::nmethod_count() { @@ -1063,7 +1063,7 @@ int CodeCache::nmethod_count() { int CodeCache::adapter_count(CodeBlobType code_blob_type) { CodeHeap* heap = get_code_heap(code_blob_type); - return (heap != NULL) ? heap->adapter_count() : 0; + return (heap != nullptr) ? heap->adapter_count() : 0; } int CodeCache::adapter_count() { @@ -1076,12 +1076,12 @@ int CodeCache::adapter_count() { address CodeCache::low_bound(CodeBlobType code_blob_type) { CodeHeap* heap = get_code_heap(code_blob_type); - return (heap != NULL) ? (address)heap->low_boundary() : NULL; + return (heap != nullptr) ? (address)heap->low_boundary() : nullptr; } address CodeCache::high_bound(CodeBlobType code_blob_type) { CodeHeap* heap = get_code_heap(code_blob_type); - return (heap != NULL) ? (address)heap->high_boundary() : NULL; + return (heap != nullptr) ? (address)heap->high_boundary() : nullptr; } size_t CodeCache::capacity() { @@ -1094,7 +1094,7 @@ size_t CodeCache::capacity() { size_t CodeCache::unallocated_capacity(CodeBlobType code_blob_type) { CodeHeap* heap = get_code_heap(code_blob_type); - return (heap != NULL) ? heap->unallocated_capacity() : 0; + return (heap != nullptr) ? heap->unallocated_capacity() : 0; } size_t CodeCache::unallocated_capacity() { @@ -1266,33 +1266,33 @@ int CodeCache::mark_for_deoptimization(KlassDepChange& changes) { CompiledMethod* CodeCache::find_compiled(void* start) { CodeBlob *cb = find_blob(start); - assert(cb == NULL || cb->is_compiled(), "did not find an compiled_method"); + assert(cb == nullptr || cb->is_compiled(), "did not find an compiled_method"); return (CompiledMethod*)cb; } #if INCLUDE_JVMTI // RedefineClasses support for saving nmethods that are dependent on "old" methods. // We don't really expect this table to grow very large. If it does, it can become a hashtable. -static GrowableArray* old_compiled_method_table = NULL; +static GrowableArray* old_compiled_method_table = nullptr; static void add_to_old_table(CompiledMethod* c) { - if (old_compiled_method_table == NULL) { + if (old_compiled_method_table == nullptr) { old_compiled_method_table = new (mtCode) GrowableArray(100, mtCode); } old_compiled_method_table->push(c); } static void reset_old_method_table() { - if (old_compiled_method_table != NULL) { + if (old_compiled_method_table != nullptr) { delete old_compiled_method_table; - old_compiled_method_table = NULL; + old_compiled_method_table = nullptr; } } // Remove this method when flushed. void CodeCache::unregister_old_nmethod(CompiledMethod* c) { assert_lock_strong(CodeCache_lock); - if (old_compiled_method_table != NULL) { + if (old_compiled_method_table != nullptr) { int index = old_compiled_method_table->find(c); if (index != -1) { old_compiled_method_table->delete_at(index); @@ -1303,7 +1303,7 @@ void CodeCache::unregister_old_nmethod(CompiledMethod* c) { void CodeCache::old_nmethods_do(MetadataClosure* f) { // Walk old method table and mark those on stack. int length = 0; - if (old_compiled_method_table != NULL) { + if (old_compiled_method_table != nullptr) { length = old_compiled_method_table->length(); for (int i = 0; i < length; i++) { // Walk all methods saved on the last pass. Concurrent class unloading may @@ -1468,7 +1468,7 @@ PRAGMA_FORMAT_NONLITERAL_IGNORED void CodeCache::report_codemem_full(CodeBlobType code_blob_type, bool print) { // Get nmethod heap for the given CodeBlobType and build CodeCacheFull event CodeHeap* heap = get_code_heap(code_blob_type); - assert(heap != NULL, "heap is null"); + assert(heap != nullptr, "heap is null"); int full_count = heap->report_full(); @@ -1536,7 +1536,7 @@ void CodeCache::print_memory_overhead() { size_t wasted_bytes = 0; FOR_ALL_ALLOCABLE_HEAPS(heap) { CodeHeap* curr_heap = *heap; - for (CodeBlob* cb = (CodeBlob*)curr_heap->first(); cb != NULL; cb = (CodeBlob*)curr_heap->next(cb)) { + for (CodeBlob* cb = (CodeBlob*)curr_heap->first(); cb != nullptr; cb = (CodeBlob*)curr_heap->next(cb)) { HeapBlock* heap_block = ((HeapBlock*)cb) - 1; wasted_bytes += heap_block->length() * CodeCacheSegmentSize - cb->size(); } @@ -1586,7 +1586,7 @@ void CodeCache::print_internals() { if (cb->is_nmethod()) { nmethod* nm = (nmethod*)cb; - if (Verbose && nm->method() != NULL) { + if (Verbose && nm->method() != nullptr) { ResourceMark rm; char *method_name = nm->method()->name_and_sig_as_C_string(); tty->print("%s", method_name); @@ -1596,9 +1596,9 @@ void CodeCache::print_internals() { nmethodCount++; if(nm->is_not_entrant()) { nmethodNotEntrant++; } - if(nm->method() != NULL && nm->is_native_method()) { nmethodNative++; } + if(nm->method() != nullptr && nm->is_native_method()) { nmethodNative++; } - if(nm->method() != NULL && nm->is_java_method()) { + if(nm->method() != nullptr && nm->is_java_method()) { nmethodJava++; max_nm_size = MAX2(max_nm_size, nm->size()); } @@ -1624,7 +1624,7 @@ void CodeCache::print_internals() { NMethodIterator iter(NMethodIterator::all_blobs); while(iter.next()) { nmethod* nm = iter.method(); - if(nm->method() != NULL && nm->is_java_method()) { + if(nm->method() != nullptr && nm->is_java_method()) { buckets[nm->size() / bucketSize]++; } } @@ -1737,7 +1737,7 @@ void CodeCache::print() { number_of_blobs++; code_size += cb->code_size(); ImmutableOopMapSet* set = cb->oop_maps(); - if (set != NULL) { + if (set != nullptr) { number_of_oop_maps += set->count(); map_size += set->nr_of_bytes(); } diff --git a/src/hotspot/share/code/codeCache.hpp b/src/hotspot/share/code/codeCache.hpp index 19eba85914d..df138deb8b2 100644 --- a/src/hotspot/share/code/codeCache.hpp +++ b/src/hotspot/share/code/codeCache.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -115,7 +115,7 @@ class CodeCache : AllStatic { static void check_heap_sizes(size_t non_nmethod_size, size_t profiled_size, size_t non_profiled_size, size_t cache_size, bool all_set); // Creates a new heap with the given name and size, containing CodeBlobs of the given type static void add_heap(ReservedSpace rs, const char* name, CodeBlobType code_blob_type); - static CodeHeap* get_code_heap_containing(void* p); // Returns the CodeHeap containing the given pointer, or NULL + static CodeHeap* get_code_heap_containing(void* p); // Returns the CodeHeap containing the given pointer, or nullptr static CodeHeap* get_code_heap(const CodeBlob* cb); // Returns the CodeHeap for the given CodeBlob static CodeHeap* get_code_heap(CodeBlobType code_blob_type); // Returns the CodeHeap for the given CodeBlobType // Returns the name of the VM option to set the size of the corresponding CodeHeap @@ -321,7 +321,7 @@ class CodeCache : AllStatic { static int get_codemem_full_count(CodeBlobType code_blob_type) { CodeHeap* heap = get_code_heap(code_blob_type); - return (heap != NULL) ? heap->full_count() : 0; + return (heap != nullptr) ? heap->full_count() : 0; } // CodeHeap State Analytics. @@ -366,7 +366,7 @@ template class CodeBlobIterator : publi // Filter is_unloading as required if (_only_not_unloading) { CompiledMethod* cm = _code_blob->as_compiled_method_or_null(); - if (cm != NULL && cm->is_unloading()) { + if (cm != nullptr && cm->is_unloading()) { continue; } } @@ -376,10 +376,10 @@ template class CodeBlobIterator : publi } public: - CodeBlobIterator(LivenessFilter filter, T* nm = NULL) + CodeBlobIterator(LivenessFilter filter, T* nm = nullptr) : _only_not_unloading(filter == only_not_unloading) { - if (Filter::heaps() == NULL) { + if (Filter::heaps() == nullptr) { // The iterator is supposed to shortcut since we have // _heap == _end, but make sure we do not have garbage // in other fields as well. @@ -388,9 +388,9 @@ template class CodeBlobIterator : publi } _heap = Filter::heaps()->begin(); _end = Filter::heaps()->end(); - // If set to NULL, initialized by first call to next() + // If set to nullptr, initialized by first call to next() _code_blob = nm; - if (nm != NULL) { + if (nm != nullptr) { while(!(*_heap)->contains_blob(_code_blob)) { ++_heap; } @@ -409,7 +409,7 @@ template class CodeBlobIterator : publi } } - bool end() const { return _code_blob == NULL; } + bool end() const { return _code_blob == nullptr; } T* method() const { return (T*)_code_blob; } private: @@ -421,9 +421,9 @@ private: } CodeHeap *heap = *_heap; // Get first method CodeBlob - if (_code_blob == NULL) { + if (_code_blob == nullptr) { _code_blob = CodeCache::first_blob(heap); - if (_code_blob == NULL) { + if (_code_blob == nullptr) { return false; } else if (Filter::apply(_code_blob)) { return true; @@ -431,10 +431,10 @@ private: } // Search for next method CodeBlob _code_blob = CodeCache::next_blob(heap, _code_blob); - while (_code_blob != NULL && !Filter::apply(_code_blob)) { + while (_code_blob != nullptr && !Filter::apply(_code_blob)) { _code_blob = CodeCache::next_blob(heap, _code_blob); } - return _code_blob != NULL; + return _code_blob != nullptr; } }; diff --git a/src/hotspot/share/code/codeCache.inline.hpp b/src/hotspot/share/code/codeCache.inline.hpp index 1a0330561fe..bea66cf0010 100644 --- a/src/hotspot/share/code/codeCache.inline.hpp +++ b/src/hotspot/share/code/codeCache.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ inline CodeBlob* CodeCache::find_blob_fast(void* pc) { inline CodeBlob* CodeCache::find_blob_and_oopmap(void* pc, int& slot) { NativePostCallNop* nop = nativePostCallNop_at((address) pc); CodeBlob* cb; - if (nop != NULL && nop->displacement() != 0) { + if (nop != nullptr && nop->displacement() != 0) { int offset = (nop->displacement() & 0xffffff); cb = (CodeBlob*) ((address) pc - offset); slot = ((nop->displacement() >> 24) & 0xff); @@ -46,13 +46,13 @@ inline CodeBlob* CodeCache::find_blob_and_oopmap(void* pc, int& slot) { cb = CodeCache::find_blob(pc); slot = -1; } - assert(cb != NULL, "must be"); + assert(cb != nullptr, "must be"); return cb; } inline int CodeCache::find_oopmap_slot_fast(void* pc) { NativePostCallNop* nop = nativePostCallNop_at((address) pc); - return (nop != NULL && nop->displacement() != 0) + return (nop != nullptr && nop->displacement() != 0) ? ((nop->displacement() >> 24) & 0xff) : -1; } diff --git a/src/hotspot/share/code/codeHeapState.cpp b/src/hotspot/share/code/codeHeapState.cpp index fd3b203548d..580610b2f75 100644 --- a/src/hotspot/share/code/codeHeapState.cpp +++ b/src/hotspot/share/code/codeHeapState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -139,7 +139,7 @@ // Flush the buffer contents unconditionally. // No action if the buffer is empty. #define BUFFEREDSTREAM_FLUSH(_termString) \ - if (((_termString) != NULL) && (strlen(_termString) > 0)){\ + if (((_termString) != nullptr) && (strlen(_termString) > 0)){\ _sstbuf->print("%s", _termString); \ } \ if (_sstbuf != _outbuf) { \ @@ -153,7 +153,7 @@ // Flush the buffer contents if the remaining capacity is // less than the given threshold. #define BUFFEREDSTREAM_FLUSH_IF(_termString, _remSize) \ - if (((_termString) != NULL) && (strlen(_termString) > 0)){\ + if (((_termString) != nullptr) && (strlen(_termString) > 0)){\ _sstbuf->print("%s", _termString); \ } \ if (_sstbuf != _outbuf) { \ @@ -193,7 +193,7 @@ BUFFEREDSTREAM_DECL_SIZE(_anyst, _outst, 4*K) #define BUFFEREDSTREAM_FLUSH(_termString) \ - if (((_termString) != NULL) && (strlen(_termString) > 0)){\ + if (((_termString) != nullptr) && (strlen(_termString) > 0)){\ _outbuf->print("%s", _termString); \ } @@ -237,8 +237,8 @@ const unsigned int maxHeaps = 10; static unsigned int nHeaps = 0; static struct CodeHeapStat CodeHeapStatArray[maxHeaps]; -// static struct StatElement *StatArray = NULL; -static StatElement* StatArray = NULL; +// static struct StatElement *StatArray = nullptr; +static StatElement* StatArray = nullptr; static int log2_seg_size = 0; static size_t seg_size = 0; static size_t alloc_granules = 0; @@ -249,14 +249,14 @@ static unsigned int nBlocks_t2 = 0; // counting "in_use" nmethods on static unsigned int nBlocks_alive = 0; // counting "not_used" and "not_entrant" nmethods only. static unsigned int nBlocks_stub = 0; -static struct FreeBlk* FreeArray = NULL; +static struct FreeBlk* FreeArray = nullptr; static unsigned int alloc_freeBlocks = 0; -static struct TopSizeBlk* TopSizeArray = NULL; +static struct TopSizeBlk* TopSizeArray = nullptr; static unsigned int alloc_topSizeBlocks = 0; static unsigned int used_topSizeBlocks = 0; -static struct SizeDistributionElement* SizeDistributionArray = NULL; +static struct SizeDistributionElement* SizeDistributionArray = nullptr; static int latest_compilation_id = 0; static volatile bool initialization_complete = false; @@ -271,13 +271,13 @@ const char* CodeHeapState::get_heapName(CodeHeap* heap) { // returns the index for the heap being processed. unsigned int CodeHeapState::findHeapIndex(outputStream* out, const char* heapName) { - if (heapName == NULL) { + if (heapName == nullptr) { return maxHeaps; } if (SegmentedCodeCache) { // Search for a pre-existing entry. If found, return that index. for (unsigned int i = 0; i < nHeaps; i++) { - if (CodeHeapStatArray[i].heapName != NULL && strcmp(heapName, CodeHeapStatArray[i].heapName) == 0) { + if (CodeHeapStatArray[i].heapName != nullptr && strcmp(heapName, CodeHeapStatArray[i].heapName) == 0) { return i; } } @@ -318,7 +318,7 @@ void CodeHeapState::get_HeapStatGlobals(outputStream* out, const char* heapName) used_topSizeBlocks = CodeHeapStatArray[ix].used_topSizeBlocks; SizeDistributionArray = CodeHeapStatArray[ix].SizeDistributionArray; } else { - StatArray = NULL; + StatArray = nullptr; seg_size = 0; log2_seg_size = 0; alloc_granules = 0; @@ -328,12 +328,12 @@ void CodeHeapState::get_HeapStatGlobals(outputStream* out, const char* heapName) nBlocks_t2 = 0; nBlocks_alive = 0; nBlocks_stub = 0; - FreeArray = NULL; + FreeArray = nullptr; alloc_freeBlocks = 0; - TopSizeArray = NULL; + TopSizeArray = nullptr; alloc_topSizeBlocks = 0; used_topSizeBlocks = 0; - SizeDistributionArray = NULL; + SizeDistributionArray = nullptr; } } @@ -360,14 +360,14 @@ void CodeHeapState::set_HeapStatGlobals(outputStream* out, const char* heapName) //---< get a new statistics array >--- void CodeHeapState::prepare_StatArray(outputStream* out, size_t nElem, size_t granularity, const char* heapName) { - if (StatArray == NULL) { + if (StatArray == nullptr) { StatArray = new StatElement[nElem]; //---< reset some counts >--- alloc_granules = nElem; granule_size = granularity; } - if (StatArray == NULL) { + if (StatArray == nullptr) { //---< just do nothing if allocation failed >--- out->print_cr("Statistics could not be collected for %s, probably out of memory.", heapName); out->print_cr("Current granularity is " SIZE_FORMAT " bytes. Try a coarser granularity.", granularity); @@ -381,13 +381,13 @@ void CodeHeapState::prepare_StatArray(outputStream* out, size_t nElem, size_t gr //---< get a new free block array >--- void CodeHeapState::prepare_FreeArray(outputStream* out, unsigned int nElem, const char* heapName) { - if (FreeArray == NULL) { + if (FreeArray == nullptr) { FreeArray = new FreeBlk[nElem]; //---< reset some counts >--- alloc_freeBlocks = nElem; } - if (FreeArray == NULL) { + if (FreeArray == nullptr) { //---< just do nothing if allocation failed >--- out->print_cr("Free space analysis cannot be done for %s, probably out of memory.", heapName); alloc_freeBlocks = 0; @@ -399,14 +399,14 @@ void CodeHeapState::prepare_FreeArray(outputStream* out, unsigned int nElem, con //---< get a new TopSizeArray >--- void CodeHeapState::prepare_TopSizeArray(outputStream* out, unsigned int nElem, const char* heapName) { - if (TopSizeArray == NULL) { + if (TopSizeArray == nullptr) { TopSizeArray = new TopSizeBlk[nElem]; //---< reset some counts >--- alloc_topSizeBlocks = nElem; used_topSizeBlocks = 0; } - if (TopSizeArray == NULL) { + if (TopSizeArray == nullptr) { //---< just do nothing if allocation failed >--- out->print_cr("Top-%d list of largest CodeHeap blocks can not be collected for %s, probably out of memory.", nElem, heapName); alloc_topSizeBlocks = 0; @@ -419,11 +419,11 @@ void CodeHeapState::prepare_TopSizeArray(outputStream* out, unsigned int nElem, //---< get a new SizeDistributionArray >--- void CodeHeapState::prepare_SizeDistArray(outputStream* out, unsigned int nElem, const char* heapName) { - if (SizeDistributionArray == NULL) { + if (SizeDistributionArray == nullptr) { SizeDistributionArray = new SizeDistributionElement[nElem]; } - if (SizeDistributionArray == NULL) { + if (SizeDistributionArray == nullptr) { //---< just do nothing if allocation failed >--- out->print_cr("Size distribution can not be collected for %s, probably out of memory.", heapName); } else { @@ -440,7 +440,7 @@ void CodeHeapState::prepare_SizeDistArray(outputStream* out, unsigned int nElem, //---< get a new SizeDistributionArray >--- void CodeHeapState::update_SizeDistArray(outputStream* out, unsigned int len) { - if (SizeDistributionArray != NULL) { + if (SizeDistributionArray != nullptr) { for (unsigned int i = log2_seg_size-1; i < nSizeDistElements; i++) { if ((SizeDistributionArray[i].rangeStart <= len) && (len < SizeDistributionArray[i].rangeEnd)) { SizeDistributionArray[i].lenSum += len; @@ -452,40 +452,40 @@ void CodeHeapState::update_SizeDistArray(outputStream* out, unsigned int len) { } void CodeHeapState::discard_StatArray(outputStream* out) { - if (StatArray != NULL) { + if (StatArray != nullptr) { delete StatArray; - StatArray = NULL; + StatArray = nullptr; alloc_granules = 0; granule_size = 0; } } void CodeHeapState::discard_FreeArray(outputStream* out) { - if (FreeArray != NULL) { + if (FreeArray != nullptr) { delete[] FreeArray; - FreeArray = NULL; + FreeArray = nullptr; alloc_freeBlocks = 0; } } void CodeHeapState::discard_TopSizeArray(outputStream* out) { - if (TopSizeArray != NULL) { + if (TopSizeArray != nullptr) { for (unsigned int i = 0; i < alloc_topSizeBlocks; i++) { - if (TopSizeArray[i].blob_name != NULL) { + if (TopSizeArray[i].blob_name != nullptr) { os::free((void*)TopSizeArray[i].blob_name); } } delete[] TopSizeArray; - TopSizeArray = NULL; + TopSizeArray = nullptr; alloc_topSizeBlocks = 0; used_topSizeBlocks = 0; } } void CodeHeapState::discard_SizeDistArray(outputStream* out) { - if (SizeDistributionArray != NULL) { + if (SizeDistributionArray != nullptr) { delete[] SizeDistributionArray; - SizeDistributionArray = NULL; + SizeDistributionArray = nullptr; } } @@ -504,7 +504,7 @@ void CodeHeapState::discard(outputStream* out, CodeHeap* heap) { discard_TopSizeArray(out); discard_SizeDistArray(out); set_HeapStatGlobals(out, CodeHeapStatArray[ix].heapName); - CodeHeapStatArray[ix].heapName = NULL; + CodeHeapStatArray[ix].heapName = nullptr; } nHeaps = 0; } @@ -538,7 +538,7 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular memset(CodeHeapStatArray, 0, sizeof(CodeHeapStatArray)); initialization_complete = true; - printBox(ast, '=', "C O D E H E A P A N A L Y S I S (general remarks)", NULL); + printBox(ast, '=', "C O D E H E A P A N A L Y S I S (general remarks)", nullptr); ast->print_cr(" The code heap analysis function provides deep insights into\n" " the inner workings and the internal state of the Java VM's\n" " code cache - the place where all the JVM generated machine\n" @@ -651,7 +651,7 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular //---< allocate arrays if they don't yet exist, initialize >--- prepare_StatArray(out, granules, granularity, heapName); - if (StatArray == NULL) { + if (StatArray == nullptr) { set_HeapStatGlobals(out, heapName); return; } @@ -669,12 +669,12 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular size_t stubSpace = 0; size_t freeSpace = 0; size_t maxFreeSize = 0; - HeapBlock* maxFreeBlock = NULL; + HeapBlock* maxFreeBlock = nullptr; bool insane = false; unsigned int n_methods = 0; - for (HeapBlock *h = heap->first_block(); h != NULL && !insane; h = heap->next_block(h)) { + for (HeapBlock *h = heap->first_block(); h != nullptr && !insane; h = heap->next_block(h)) { unsigned int hb_len = (unsigned int)h->length(); // despite being size_t, length can never overflow an unsigned int. size_t hb_bytelen = ((size_t)hb_len)<find_start(h); - cbType = get_cbType(cb); // Will check for cb == NULL and other safety things. + cbType = get_cbType(cb); // Will check for cb == nullptr and other safety things. if (cbType != noType) { const char* blob_name = nullptr; unsigned int nm_size = 0; nmethod* nm = cb->as_nmethod_or_null(); - if (nm != NULL) { // no is_readable check required, nm = (nmethod*)cb. + if (nm != nullptr) { // no is_readable check required, nm = (nmethod*)cb. ResourceMark rm; Method* method = nm->method(); if (nm->is_in_use() || nm->is_not_entrant()) { @@ -790,7 +790,7 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular currMin = hb_len; currMin_ix = 0; used_topSizeBlocks++; - blob_name = NULL; // indicate blob_name was consumed + blob_name = nullptr; // indicate blob_name was consumed // This check roughly cuts 5000 iterations (JVM98, mixed, dbg, termination stats): } else if ((used_topSizeBlocks < alloc_topSizeBlocks) && (hb_len < currMin)) { //---< all blocks in list are larger, but there is room left in array >--- @@ -806,7 +806,7 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular currMin = hb_len; currMin_ix = used_topSizeBlocks; used_topSizeBlocks++; - blob_name = NULL; // indicate blob_name was consumed + blob_name = nullptr; // indicate blob_name was consumed } else { // This check cuts total_iterations by a factor of 6 (JVM98, mixed, dbg, termination stats): // We don't need to search the list if we know beforehand that the current block size is @@ -846,7 +846,7 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular TopSizeArray[i].level = comp_lvl; TopSizeArray[i].type = cbType; used_topSizeBlocks++; - blob_name = NULL; // indicate blob_name was consumed + blob_name = nullptr; // indicate blob_name was consumed } else { // no room for new entries, current block replaces entry for smallest block //---< Find last entry (entry for smallest remembered block) >--- // We either want to insert right before the smallest entry, which is when @@ -870,7 +870,7 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular j = TopSizeArray[j].index; } if (!insane) { - if (TopSizeArray[j].blob_name != NULL) { + if (TopSizeArray[j].blob_name != nullptr) { os::free((void*)TopSizeArray[j].blob_name); } if (prev_j == tsbStopper) { @@ -902,7 +902,7 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular TopSizeArray[i].level = comp_lvl; TopSizeArray[i].type = cbType; } - blob_name = NULL; // indicate blob_name was consumed + blob_name = nullptr; // indicate blob_name was consumed } // insane } break; @@ -917,9 +917,9 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular } } } - if (blob_name != NULL) { + if (blob_name != nullptr) { os::free((void*)blob_name); - blob_name = NULL; + blob_name = nullptr; } //---------------------------------------------- //---< END register block in TopSizeArray >--- @@ -1138,7 +1138,7 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular } prepare_FreeArray(out, nBlocks_free, heapName); - if (FreeArray == NULL) { + if (FreeArray == nullptr) { done = true; continue; } @@ -1150,7 +1150,7 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular unsigned int ix = 0; FreeBlock* cur = heap->freelist(); - while (cur != NULL) { + while (cur != nullptr) { if (ix < alloc_freeBlocks) { // don't index out of bounds if _freelist has more blocks than anticipated FreeArray[ix].start = cur; FreeArray[ix].len = (unsigned int)(cur->length()<--- - if (FreeArray != NULL) { + if (FreeArray != nullptr) { // This loop is intentionally printing directly to "out". // It should not print anything, anyway. for (unsigned int ix = 0; ix < alloc_freeBlocks-1; ix++) { size_t lenSum = 0; FreeArray[ix].gap = (unsigned int)((address)FreeArray[ix+1].start - ((address)FreeArray[ix].start + FreeArray[ix].len)); - for (HeapBlock *h = heap->next_block(FreeArray[ix].start); (h != NULL) && (h != FreeArray[ix+1].start); h = heap->next_block(h)) { + for (HeapBlock *h = heap->next_block(FreeArray[ix].start); (h != nullptr) && (h != FreeArray[ix+1].start); h = heap->next_block(h)) { CodeBlob *cb = (CodeBlob*)(heap->find_start(h)); - if ((cb != NULL) && !cb->is_nmethod()) { // checks equivalent to those in get_cbType() + if ((cb != nullptr) && !cb->is_nmethod()) { // checks equivalent to those in get_cbType() FreeArray[ix].stubs_in_gap = true; } FreeArray[ix].n_gapBlocks++; @@ -1222,7 +1222,7 @@ void CodeHeapState::print_usedSpace(outputStream* out, CodeHeap* heap) { const char* heapName = get_heapName(heap); get_HeapStatGlobals(out, heapName); - if ((StatArray == NULL) || (TopSizeArray == NULL) || (used_topSizeBlocks == 0)) { + if ((StatArray == nullptr) || (TopSizeArray == nullptr) || (used_topSizeBlocks == 0)) { return; } BUFFEREDSTREAM_DECL(ast, out) @@ -1263,14 +1263,14 @@ void CodeHeapState::print_usedSpace(outputStream* out, CodeHeap* heap) { unsigned int printed_topSizeBlocks = 0; for (unsigned int i = 0; i != tsbStopper; i = TopSizeArray[i].index) { printed_topSizeBlocks++; - if (TopSizeArray[i].blob_name == NULL) { + if (TopSizeArray[i].blob_name == nullptr) { TopSizeArray[i].blob_name = os::strdup("unnamed blob or blob name unavailable"); } // heap->find_start() is safe. Only works on _segmap. - // Returns NULL or void*. Returned CodeBlob may be uninitialized. + // Returns nullptr or void*. Returned CodeBlob may be uninitialized. HeapBlock* heapBlock = TopSizeArray[i].start; CodeBlob* this_blob = (CodeBlob*)(heap->find_start(heapBlock)); - if (this_blob != NULL) { + if (this_blob != nullptr) { //---< access these fields only if we own the CodeCache_lock >--- //---< blob address >--- ast->print(INTPTR_FORMAT, p2i(this_blob)); @@ -1329,7 +1329,7 @@ void CodeHeapState::print_usedSpace(outputStream* out, CodeHeap* heap) { //-- Print Usage Histogram -- //----------------------------- - if (SizeDistributionArray != NULL) { + if (SizeDistributionArray != nullptr) { unsigned long total_count = 0; unsigned long total_size = 0; const unsigned long pctFactor = 200; @@ -1432,7 +1432,7 @@ void CodeHeapState::print_freeSpace(outputStream* out, CodeHeap* heap) { const char* heapName = get_heapName(heap); get_HeapStatGlobals(out, heapName); - if ((StatArray == NULL) || (FreeArray == NULL) || (alloc_granules == 0)) { + if ((StatArray == nullptr) || (FreeArray == nullptr) || (alloc_granules == 0)) { return; } BUFFEREDSTREAM_DECL(ast, out) @@ -1483,13 +1483,13 @@ void CodeHeapState::print_freeSpace(outputStream* out, CodeHeap* heap) { unsigned int currSize = FreeArray[ix].len; unsigned int iy; - for (iy = 0; iy < nTop && FreeTopTen[iy] != NULL; iy++) { + for (iy = 0; iy < nTop && FreeTopTen[iy] != nullptr; iy++) { if (FreeTopTen[iy]->len < currSize) { for (unsigned int iz = nTop-1; iz > iy; iz--) { // make room to insert new free block FreeTopTen[iz] = FreeTopTen[iz-1]; } FreeTopTen[iy] = &FreeArray[ix]; // insert new free block - if (FreeTopTen[nTop-1] != NULL) { + if (FreeTopTen[nTop-1] != nullptr) { currMax10 = FreeTopTen[nTop-1]->len; } break; // done with this, check next free block @@ -1500,7 +1500,7 @@ void CodeHeapState::print_freeSpace(outputStream* out, CodeHeap* heap) { currSize, currMax10); continue; } - if (FreeTopTen[iy] == NULL) { + if (FreeTopTen[iy] == nullptr) { FreeTopTen[iy] = &FreeArray[ix]; if (iy == (nTop-1)) { currMax10 = currSize; @@ -1514,7 +1514,7 @@ void CodeHeapState::print_freeSpace(outputStream* out, CodeHeap* heap) { printBox(ast, '-', "Top Ten Free Blocks in ", heapName); //---< print Top Ten Free Blocks >--- - for (unsigned int iy = 0; (iy < nTop) && (FreeTopTen[iy] != NULL); iy++) { + for (unsigned int iy = 0; (iy < nTop) && (FreeTopTen[iy] != nullptr); iy++) { ast->print("Pos %3d: Block %4d - size " HEX32_FORMAT ",", iy+1, FreeTopTen[iy]->index, FreeTopTen[iy]->len); ast->fill_to(39); if (FreeTopTen[iy]->index == (alloc_freeBlocks-1)) { @@ -1548,13 +1548,13 @@ void CodeHeapState::print_freeSpace(outputStream* out, CodeHeap* heap) { if (lenTriple > currMax10) { // larger than the ten largest found so far unsigned int iy; - for (iy = 0; (iy < nTop) && (FreeTopTenTriple[iy] != NULL); iy++) { + for (iy = 0; (iy < nTop) && (FreeTopTenTriple[iy] != nullptr); iy++) { if (FreeTopTenTriple[iy]->len < lenTriple) { for (unsigned int iz = nTop-1; iz > iy; iz--) { FreeTopTenTriple[iz] = FreeTopTenTriple[iz-1]; } FreeTopTenTriple[iy] = &FreeArray[ix]; - if (FreeTopTenTriple[nTop-1] != NULL) { + if (FreeTopTenTriple[nTop-1] != nullptr) { currMax10 = FreeTopTenTriple[nTop-1]->len; } break; @@ -1565,7 +1565,7 @@ void CodeHeapState::print_freeSpace(outputStream* out, CodeHeap* heap) { lenTriple, currMax10); continue; } - if (FreeTopTenTriple[iy] == NULL) { + if (FreeTopTenTriple[iy] == nullptr) { FreeTopTenTriple[iy] = &FreeArray[ix]; if (iy == (nTop-1)) { currMax10 = lenTriple; @@ -1584,7 +1584,7 @@ void CodeHeapState::print_freeSpace(outputStream* out, CodeHeap* heap) { " fragmentation.\n"); //---< print Top Ten Free-Occupied-Free Triples >--- - for (unsigned int iy = 0; (iy < nTop) && (FreeTopTenTriple[iy] != NULL); iy++) { + for (unsigned int iy = 0; (iy < nTop) && (FreeTopTenTriple[iy] != nullptr); iy++) { ast->print("Pos %3d: Block %4d - size " HEX32_FORMAT ",", iy+1, FreeTopTenTriple[iy]->index, FreeTopTenTriple[iy]->len); ast->fill_to(39); ast->print("Gap (to next) " HEX32_FORMAT ",", FreeTopTenTriple[iy]->gap); @@ -1606,7 +1606,7 @@ void CodeHeapState::print_count(outputStream* out, CodeHeap* heap) { const char* heapName = get_heapName(heap); get_HeapStatGlobals(out, heapName); - if ((StatArray == NULL) || (alloc_granules == 0)) { + if ((StatArray == nullptr) || (alloc_granules == 0)) { return; } BUFFEREDSTREAM_DECL(ast, out) @@ -1630,7 +1630,7 @@ void CodeHeapState::print_count(outputStream* out, CodeHeap* heap) { { if (segment_granules) { - printBox(ast, '-', "Total (all types) count for granule size == segment size", NULL); + printBox(ast, '-', "Total (all types) count for granule size == segment size", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1638,7 +1638,7 @@ void CodeHeapState::print_count(outputStream* out, CodeHeap* heap) { print_blobType_single(ast, StatArray[ix].type); } } else { - printBox(ast, '-', "Total (all tiers) count, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); + printBox(ast, '-', "Total (all tiers) count, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1653,7 +1653,7 @@ void CodeHeapState::print_count(outputStream* out, CodeHeap* heap) { { if (nBlocks_t1 > 0) { - printBox(ast, '-', "Tier1 nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); + printBox(ast, '-', "Tier1 nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1673,7 +1673,7 @@ void CodeHeapState::print_count(outputStream* out, CodeHeap* heap) { { if (nBlocks_t2 > 0) { - printBox(ast, '-', "Tier2 nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); + printBox(ast, '-', "Tier2 nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1693,7 +1693,7 @@ void CodeHeapState::print_count(outputStream* out, CodeHeap* heap) { { if (nBlocks_alive > 0) { - printBox(ast, '-', "not_used/not_entrant/not_installed nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); + printBox(ast, '-', "not_used/not_entrant/not_installed nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1713,7 +1713,7 @@ void CodeHeapState::print_count(outputStream* out, CodeHeap* heap) { { if (nBlocks_stub > 0) { - printBox(ast, '-', "Stub & Blob count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); + printBox(ast, '-', "Stub & Blob count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1733,7 +1733,7 @@ void CodeHeapState::print_count(outputStream* out, CodeHeap* heap) { { if (!segment_granules) { // Prevent totally redundant printouts - printBox(ast, '-', "Count by tier (combined): <#t1>:<#t2>:<#s>, 0x0..0xf. '*' indicates >= 16 blocks", NULL); + printBox(ast, '-', "Count by tier (combined): <#t1>:<#t2>:<#s>, 0x0..0xf. '*' indicates >= 16 blocks", nullptr); granules_per_line = 24; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1764,7 +1764,7 @@ void CodeHeapState::print_space(outputStream* out, CodeHeap* heap) { const char* heapName = get_heapName(heap); get_HeapStatGlobals(out, heapName); - if ((StatArray == NULL) || (alloc_granules == 0)) { + if ((StatArray == nullptr) || (alloc_granules == 0)) { return; } BUFFEREDSTREAM_DECL(ast, out) @@ -1791,7 +1791,7 @@ void CodeHeapState::print_space(outputStream* out, CodeHeap* heap) { { if (segment_granules) { - printBox(ast, '-', "Total (all types) space consumption for granule size == segment size", NULL); + printBox(ast, '-', "Total (all types) space consumption for granule size == segment size", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1799,7 +1799,7 @@ void CodeHeapState::print_space(outputStream* out, CodeHeap* heap) { print_blobType_single(ast, StatArray[ix].type); } } else { - printBox(ast, '-', "Total (all types) space consumption. ' ' indicates empty, '*' indicates full.", NULL); + printBox(ast, '-', "Total (all types) space consumption. ' ' indicates empty, '*' indicates full.", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1814,7 +1814,7 @@ void CodeHeapState::print_space(outputStream* out, CodeHeap* heap) { { if (nBlocks_t1 > 0) { - printBox(ast, '-', "Tier1 space consumption. ' ' indicates empty, '*' indicates full", NULL); + printBox(ast, '-', "Tier1 space consumption. ' ' indicates empty, '*' indicates full", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1834,7 +1834,7 @@ void CodeHeapState::print_space(outputStream* out, CodeHeap* heap) { { if (nBlocks_t2 > 0) { - printBox(ast, '-', "Tier2 space consumption. ' ' indicates empty, '*' indicates full", NULL); + printBox(ast, '-', "Tier2 space consumption. ' ' indicates empty, '*' indicates full", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1854,7 +1854,7 @@ void CodeHeapState::print_space(outputStream* out, CodeHeap* heap) { { if (nBlocks_alive > 0) { - printBox(ast, '-', "not_used/not_entrant/not_installed space consumption. ' ' indicates empty, '*' indicates full", NULL); + printBox(ast, '-', "not_used/not_entrant/not_installed space consumption. ' ' indicates empty, '*' indicates full", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1874,7 +1874,7 @@ void CodeHeapState::print_space(outputStream* out, CodeHeap* heap) { { if (nBlocks_stub > 0) { - printBox(ast, '-', "Stub and Blob space consumption. ' ' indicates empty, '*' indicates full", NULL); + printBox(ast, '-', "Stub and Blob space consumption. ' ' indicates empty, '*' indicates full", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1894,7 +1894,7 @@ void CodeHeapState::print_space(outputStream* out, CodeHeap* heap) { { if (!segment_granules) { // Prevent totally redundant printouts - printBox(ast, '-', "Space consumption by tier (combined): ::. ' ' indicates empty, '*' indicates full", NULL); + printBox(ast, '-', "Space consumption by tier (combined): ::. ' ' indicates empty, '*' indicates full", nullptr); granules_per_line = 24; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1933,7 +1933,7 @@ void CodeHeapState::print_age(outputStream* out, CodeHeap* heap) { const char* heapName = get_heapName(heap); get_HeapStatGlobals(out, heapName); - if ((StatArray == NULL) || (alloc_granules == 0)) { + if ((StatArray == nullptr) || (alloc_granules == 0)) { return; } BUFFEREDSTREAM_DECL(ast, out) @@ -1954,7 +1954,7 @@ void CodeHeapState::print_age(outputStream* out, CodeHeap* heap) { } { - printBox(ast, '-', "Age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL); + printBox(ast, '-', "Age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1972,7 +1972,7 @@ void CodeHeapState::print_age(outputStream* out, CodeHeap* heap) { { if (nBlocks_t1 > 0) { - printBox(ast, '-', "Tier1 age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL); + printBox(ast, '-', "Tier1 age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -1988,7 +1988,7 @@ void CodeHeapState::print_age(outputStream* out, CodeHeap* heap) { { if (nBlocks_t2 > 0) { - printBox(ast, '-', "Tier2 age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL); + printBox(ast, '-', "Tier2 age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -2004,7 +2004,7 @@ void CodeHeapState::print_age(outputStream* out, CodeHeap* heap) { { if (nBlocks_alive > 0) { - printBox(ast, '-', "not_used/not_entrant/not_installed age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL); + printBox(ast, '-', "not_used/not_entrant/not_installed age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", nullptr); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -2020,7 +2020,7 @@ void CodeHeapState::print_age(outputStream* out, CodeHeap* heap) { { if (!segment_granules) { // Prevent totally redundant printouts - printBox(ast, '-', "age distribution by tier :. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL); + printBox(ast, '-', "age distribution by tier :. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", nullptr); granules_per_line = 32; for (unsigned int ix = 0; ix < alloc_granules; ix++) { @@ -2045,14 +2045,14 @@ void CodeHeapState::print_names(outputStream* out, CodeHeap* heap) { const char* heapName = get_heapName(heap); get_HeapStatGlobals(out, heapName); - if ((StatArray == NULL) || (alloc_granules == 0)) { + if ((StatArray == nullptr) || (alloc_granules == 0)) { return; } BUFFEREDSTREAM_DECL(ast, out) unsigned int granules_per_line = 128; char* low_bound = heap->low_boundary(); - CodeBlob* last_blob = NULL; + CodeBlob* last_blob = nullptr; bool name_in_addr_range = true; bool have_locks = holding_required_locks(); @@ -2090,7 +2090,7 @@ void CodeHeapState::print_names(outputStream* out, CodeHeap* heap) { if (nBlobs > 0 ) { for (unsigned int is = 0; is < granule_size; is+=(unsigned int)seg_size) { // heap->find_start() is safe. Only works on _segmap. - // Returns NULL or void*. Returned CodeBlob may be uninitialized. + // Returns nullptr or void*. Returned CodeBlob may be uninitialized. char* this_seg = low_bound + ix*granule_size + is; CodeBlob* this_blob = (CodeBlob*)(heap->find_start(this_seg)); bool blob_is_safe = blob_access_is_safe(this_blob); @@ -2112,12 +2112,12 @@ void CodeHeapState::print_names(outputStream* out, CodeHeap* heap) { //---< access these fields only if we own the CodeCache_lock >--- const char* blob_name = ""; - nmethod* nm = NULL; + nmethod* nm = nullptr; if (have_locks) { blob_name = this_blob->name(); nm = this_blob->as_nmethod_or_null(); - // this_blob->name() could return NULL if no name was given to CTOR. Inlined, maybe invisible on stack - if (blob_name == NULL) { + // this_blob->name() could return nullptr if no name was given to CTOR. Inlined, maybe invisible on stack + if (blob_name == nullptr) { blob_name = ""; } } @@ -2140,7 +2140,7 @@ void CodeHeapState::print_names(outputStream* out, CodeHeap* heap) { ast->fill_to(33); // access nmethod and Method fields only if we own the CodeCache_lock. - // This fact is implicitly transported via nm != NULL. + // This fact is implicitly transported via nm != nullptr. if (nmethod_access_is_safe(nm)) { Method* method = nm->method(); ResourceMark rm; @@ -2160,11 +2160,11 @@ void CodeHeapState::print_names(outputStream* out, CodeHeap* heap) { if (get_name) { Symbol* methName = method->name(); - const char* methNameS = (methName == NULL) ? NULL : methName->as_C_string(); - methNameS = (methNameS == NULL) ? "" : methNameS; + const char* methNameS = (methName == nullptr) ? nullptr : methName->as_C_string(); + methNameS = (methNameS == nullptr) ? "" : methNameS; Symbol* methSig = method->signature(); - const char* methSigS = (methSig == NULL) ? NULL : methSig->as_C_string(); - methSigS = (methSigS == NULL) ? "" : methSigS; + const char* methSigS = (methSig == nullptr) ? nullptr : methSig->as_C_string(); + methSigS = (methSigS == nullptr) ? "" : methSigS; Klass* klass = method->method_holder(); assert(klass != nullptr, "No method holder"); const char* classNameS = (klass->name() == nullptr) ? "" : klass->external_name(); @@ -2186,7 +2186,7 @@ void CodeHeapState::print_names(outputStream* out, CodeHeap* heap) { } ast->cr(); BUFFEREDSTREAM_FLUSH_AUTO("") - } else if (!blob_is_safe && (this_blob != last_blob) && (this_blob != NULL)) { + } else if (!blob_is_safe && (this_blob != last_blob) && (this_blob != nullptr)) { last_blob = this_blob; } } @@ -2200,10 +2200,10 @@ void CodeHeapState::printBox(outputStream* ast, const char border, const char* t unsigned int lineLen = 1 + 2 + 2 + 1; char edge, frame; - if (text1 != NULL) { + if (text1 != nullptr) { lineLen += (unsigned int)strlen(text1); // text1 is much shorter than MAX_INT chars. } - if (text2 != NULL) { + if (text2 != nullptr) { lineLen += (unsigned int)strlen(text2); // text2 is much shorter than MAX_INT chars. } if (border == '-') { @@ -2221,10 +2221,10 @@ void CodeHeapState::printBox(outputStream* ast, const char border, const char* t ast->print_cr("%c", edge); ast->print("%c ", frame); - if (text1 != NULL) { + if (text1 != nullptr) { ast->print("%s", text1); } - if (text2 != NULL) { + if (text2 != nullptr) { ast->print("%s", text2); } ast->print_cr(" %c", frame); @@ -2238,7 +2238,7 @@ void CodeHeapState::printBox(outputStream* ast, const char border, const char* t void CodeHeapState::print_blobType_legend(outputStream* out) { out->cr(); - printBox(out, '-', "Block types used in the following CodeHeap dump", NULL); + printBox(out, '-', "Block types used in the following CodeHeap dump", nullptr); for (int type = noType; type < lastType; type += 1) { out->print_cr(" %c - %s", blobTypeChar[type], blobTypeName[type]); } @@ -2249,7 +2249,7 @@ void CodeHeapState::print_blobType_legend(outputStream* out) { void CodeHeapState::print_space_legend(outputStream* out) { int range_beg = latest_compilation_id; out->cr(); - printBox(out, '-', "Space ranges, based on granule occupancy", NULL); + printBox(out, '-', "Space ranges, based on granule occupancy", nullptr); out->print_cr(" - 0%% == occupancy"); for (int i=0; i<=9; i++) { out->print_cr(" %d - %3d%% < occupancy < %3d%%", i, 10*i, 10*(i+1)); @@ -2264,7 +2264,7 @@ void CodeHeapState::print_age_legend(outputStream* out) { int age_range = 256; int range_beg = latest_compilation_id; out->cr(); - printBox(out, '-', "Age ranges, based on compilation id", NULL); + printBox(out, '-', "Age ranges, based on compilation id", nullptr); while (age_range > 0) { out->print_cr(" %u - %6d to %6d", indicator, range_beg, latest_compilation_id - latest_compilation_id/age_range); range_beg = latest_compilation_id - latest_compilation_id/age_range; @@ -2346,7 +2346,7 @@ void CodeHeapState::print_line_delim(outputStream* out, bufferedStream* ast, cha // Find out which blob type we have at hand. // Return "noType" if anything abnormal is detected. CodeHeapState::blobType CodeHeapState::get_cbType(CodeBlob* cb) { - if (cb != NULL) { + if (cb != nullptr) { if (cb->is_runtime_stub()) return runtimeStub; if (cb->is_deoptimization_stub()) return deoptimizationStub; if (cb->is_uncommon_trap_stub()) return uncommonTrapStub; @@ -2360,7 +2360,7 @@ CodeHeapState::blobType CodeHeapState::get_cbType(CodeBlob* cb) { // Should be ensured by caller. aggregate() and print_names() do that. if (holding_required_locks()) { nmethod* nm = cb->as_nmethod_or_null(); - if (nm != NULL) { // no is_readable check required, nm = (nmethod*)cb. + if (nm != nullptr) { // no is_readable check required, nm = (nmethod*)cb. if (nm->is_in_use()) return nMethod_inuse; if (!nm->is_not_entrant()) return nMethod_notused; return nMethod_notentrant; @@ -2372,7 +2372,7 @@ CodeHeapState::blobType CodeHeapState::get_cbType(CodeBlob* cb) { // make sure the blob at hand is not garbage. bool CodeHeapState::blob_access_is_safe(CodeBlob* this_blob) { - return (this_blob != NULL) && // a blob must have been found, obviously + return (this_blob != nullptr) && // a blob must have been found, obviously (this_blob->header_size() >= 0) && (this_blob->relocation_size() >= 0) && ((address)this_blob + this_blob->header_size() == (address)(this_blob->relocation_begin())) && @@ -2381,8 +2381,8 @@ bool CodeHeapState::blob_access_is_safe(CodeBlob* this_blob) { // make sure the nmethod at hand (and the linked method) is not garbage. bool CodeHeapState::nmethod_access_is_safe(nmethod* nm) { - Method* method = (nm == NULL) ? NULL : nm->method(); // nm->method() was found to be uninitialized, i.e. != NULL, but invalid. - return (nm != NULL) && (method != NULL) && (method->signature() != NULL); + Method* method = (nm == nullptr) ? nullptr : nm->method(); // nm->method() was found to be uninitialized, i.e. != nullptr, but invalid. + return (nm != nullptr) && (method != nullptr) && (method->signature() != nullptr); } bool CodeHeapState::holding_required_locks() { diff --git a/src/hotspot/share/code/compiledIC.cpp b/src/hotspot/share/code/compiledIC.cpp index 715a79ab11a..ea4b3d78b9b 100644 --- a/src/hotspot/share/code/compiledIC.cpp +++ b/src/hotspot/share/code/compiledIC.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,7 +69,7 @@ bool CompiledICLocker::is_safe(CompiledMethod* method) { bool CompiledICLocker::is_safe(address code) { CodeBlob* cb = CodeCache::find_blob(code); - assert(cb != NULL && cb->is_compiled(), "must be compiled"); + assert(cb != nullptr && cb->is_compiled(), "must be compiled"); CompiledMethod* cm = cb->as_compiled_method(); return CompiledICProtectionBehaviour::current()->is_safe(cm); } @@ -85,9 +85,9 @@ void* CompiledIC::cached_value() const { if (!is_in_transition_state()) { void* data = get_data(); // If we let the metadata value here be initialized to zero... - assert(data != NULL || Universe::non_oop_word() == NULL, + assert(data != nullptr || Universe::non_oop_word() == nullptr, "no raw nulls in CompiledIC metadatas, because of patching races"); - return (data == (void*)Universe::non_oop_word()) ? NULL : data; + return (data == (void*)Universe::non_oop_word()) ? nullptr : data; } else { return InlineCacheBuffer::cached_value_for((CompiledIC *)this); } @@ -95,10 +95,10 @@ void* CompiledIC::cached_value() const { void CompiledIC::internal_set_ic_destination(address entry_point, bool is_icstub, void* cache, bool is_icholder) { - assert(entry_point != NULL, "must set legal entry point"); + assert(entry_point != nullptr, "must set legal entry point"); assert(CompiledICLocker::is_safe(_method), "mt unsafe call"); - assert (!is_optimized() || cache == NULL, "an optimized virtual call does not have a cached metadata"); - assert (cache == NULL || cache != (Metadata*)badOopVal, "invalid metadata"); + assert (!is_optimized() || cache == nullptr, "an optimized virtual call does not have a cached metadata"); + assert (cache == nullptr || cache != (Metadata*)badOopVal, "invalid metadata"); assert(!is_icholder || is_icholder_entry(entry_point), "must be"); @@ -129,7 +129,7 @@ void CompiledIC::internal_set_ic_destination(address entry_point, bool is_icstub { CodeBlob* cb = CodeCache::find_blob(_call->instruction_address()); - assert(cb != NULL && cb->is_compiled(), "must be compiled"); + assert(cb != nullptr && cb->is_compiled(), "must be compiled"); _call->set_destination_mt_safe(entry_point); } @@ -137,18 +137,18 @@ void CompiledIC::internal_set_ic_destination(address entry_point, bool is_icstub // Optimized call sites don't have a cache value and ICStub call // sites only change the entry point. Changing the value in that // case could lead to MT safety issues. - assert(cache == NULL, "must be null"); + assert(cache == nullptr, "must be null"); return; } - if (cache == NULL) cache = Universe::non_oop_word(); + if (cache == nullptr) cache = Universe::non_oop_word(); set_data((intptr_t)cache); } void CompiledIC::set_ic_destination(ICStub* stub) { - internal_set_ic_destination(stub->code_begin(), true, NULL, false); + internal_set_ic_destination(stub->code_begin(), true, nullptr, false); } @@ -202,7 +202,7 @@ void CompiledIC::initialize_from_iter(RelocIterator* iter) { } else { assert(iter->type() == relocInfo::opt_virtual_call_type, "must be a virtual call"); _is_optimized = true; - _value = NULL; + _value = nullptr; } } @@ -212,8 +212,8 @@ CompiledIC::CompiledIC(CompiledMethod* cm, NativeCall* call) _call = _method->call_wrapper_at((address) call); address ic_call = _call->instruction_address(); - assert(ic_call != NULL, "ic_call address must be set"); - assert(cm != NULL, "must pass compiled method"); + assert(ic_call != nullptr, "ic_call address must be set"); + assert(cm != nullptr, "must pass compiled method"); assert(cm->contains(ic_call), "must be in compiled method"); // Search for the ic_call at the given address. @@ -232,8 +232,8 @@ CompiledIC::CompiledIC(RelocIterator* iter) address ic_call = _call->instruction_address(); CompiledMethod* nm = iter->code(); - assert(ic_call != NULL, "ic_call address must be set"); - assert(nm != NULL, "must pass compiled method"); + assert(ic_call != nullptr, "ic_call address must be set"); + assert(nm != nullptr, "must pass compiled method"); assert(nm->contains(ic_call), "must be in compiled method"); initialize_from_iter(iter); @@ -255,7 +255,7 @@ bool CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecod assert(bytecode == Bytecodes::_invokeinterface, ""); int itable_index = call_info->itable_index(); entry = VtableStubs::find_itable_stub(itable_index); - if (entry == NULL) { + if (entry == nullptr) { return false; } #ifdef ASSERT @@ -278,10 +278,10 @@ bool CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecod int vtable_index = call_info->vtable_index(); assert(call_info->resolved_klass()->verify_vtable_index(vtable_index), "sanity check"); entry = VtableStubs::find_vtable_stub(vtable_index); - if (entry == NULL) { + if (entry == nullptr) { return false; } - if (!InlineCacheBuffer::create_transition_stub(this, NULL, entry)) { + if (!InlineCacheBuffer::create_transition_stub(this, nullptr, entry)) { needs_ic_stub_refill = true; return false; } @@ -289,7 +289,7 @@ bool CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecod if (TraceICs) { ResourceMark rm; - assert(call_info->selected_method() != NULL, "Unexpected null selected method"); + assert(call_info->selected_method() != nullptr, "Unexpected null selected method"); tty->print_cr ("IC@" INTPTR_FORMAT ": to megamorphic %s entry: " INTPTR_FORMAT, p2i(instruction_address()), call_info->selected_method()->print_value_string(), p2i(entry)); } @@ -311,17 +311,17 @@ bool CompiledIC::is_megamorphic() const { assert(!is_optimized(), "an optimized call cannot be megamorphic"); // Cannot rely on cached_value. It is either an interface or a method. - return VtableStubs::entry_point(ic_destination()) != NULL; + return VtableStubs::entry_point(ic_destination()) != nullptr; } bool CompiledIC::is_call_to_compiled() const { assert(CompiledICLocker::is_safe(_method), "mt unsafe call"); CodeBlob* cb = CodeCache::find_blob(ic_destination()); - bool is_monomorphic = (cb != NULL && cb->is_compiled()); + bool is_monomorphic = (cb != nullptr && cb->is_compiled()); // Check that the cached_value is a klass for non-optimized monomorphic calls // This assertion is invalid for compiler1: a call that does not look optimized (no static stub) can be used - // for calling directly to vep without using the inline cache (i.e., cached_value == NULL). + // for calling directly to vep without using the inline cache (i.e., cached_value == nullptr). // For JVMCI this occurs because CHA is only used to improve inlining so call sites which could be optimized // virtuals because there are no currently loaded subclasses of a type are left as virtual call sites. #ifdef ASSERT @@ -330,7 +330,7 @@ bool CompiledIC::is_call_to_compiled() const { assert( is_c1_or_jvmci_method || !is_monomorphic || is_optimized() || - (cached_metadata() != NULL && cached_metadata()->is_klass()), "sanity check"); + (cached_metadata() != nullptr && cached_metadata()->is_klass()), "sanity check"); #endif // ASSERT return is_monomorphic; } @@ -343,8 +343,8 @@ bool CompiledIC::is_call_to_interpreted() const { bool is_call_to_interpreted = false; if (!is_optimized()) { CodeBlob* cb = CodeCache::find_blob(ic_destination()); - is_call_to_interpreted = (cb != NULL && cb->is_adapter_blob()); - assert(!is_call_to_interpreted || (is_icholder_call() && cached_icholder() != NULL), "sanity check"); + is_call_to_interpreted = (cb != nullptr && cb->is_adapter_blob()); + assert(!is_call_to_interpreted || (is_icholder_call() && cached_icholder() != nullptr), "sanity check"); } else { // Check if we are calling into our own codeblob (i.e., to a stub) address dest = ic_destination(); @@ -375,11 +375,11 @@ bool CompiledIC::set_to_clean(bool in_use) { if (is_optimized()) { set_ic_destination(entry); } else { - set_ic_destination_and_value(entry, (void*)NULL); + set_ic_destination_and_value(entry, (void*)nullptr); } } else { // Unsafe transition - create stub. - if (!InlineCacheBuffer::create_transition_stub(this, NULL, entry)) { + if (!InlineCacheBuffer::create_transition_stub(this, nullptr, entry)) { return false; } } @@ -398,7 +398,7 @@ bool CompiledIC::is_clean() const { bool is_clean = false; address dest = ic_destination(); is_clean = dest == _call->get_resolve_call_stub(is_optimized()); - assert(!is_clean || is_optimized() || cached_value() == NULL, "sanity check"); + assert(!is_clean || is_optimized() || cached_value() == nullptr, "sanity check"); return is_clean; } @@ -425,7 +425,7 @@ bool CompiledIC::set_to_monomorphic(CompiledICInfo& info) { // (either because of CHA or the static target is final) // At code generation time, this call has been emitted as static call // Call via stub - assert(info.cached_metadata() != NULL && info.cached_metadata()->is_method(), "sanity check"); + assert(info.cached_metadata() != nullptr && info.cached_metadata()->is_method(), "sanity check"); methodHandle method (thread, (Method*)info.cached_metadata()); _call->set_to_interpreted(method, info); @@ -449,10 +449,10 @@ bool CompiledIC::set_to_monomorphic(CompiledICInfo& info) { } } else { // Call to compiled code - bool static_bound = info.is_optimized() || (info.cached_metadata() == NULL); + bool static_bound = info.is_optimized() || (info.cached_metadata() == nullptr); #ifdef ASSERT CodeBlob* cb = CodeCache::find_blob(info.entry()); - assert (cb != NULL && cb->is_compiled(), "must be compiled!"); + assert (cb != nullptr && cb->is_compiled(), "must be compiled!"); #endif /* ASSERT */ // This is MT safe if we come from a clean-cache and go through a @@ -474,10 +474,10 @@ bool CompiledIC::set_to_monomorphic(CompiledICInfo& info) { if (TraceICs) { ResourceMark rm(thread); - assert(info.cached_metadata() == NULL || info.cached_metadata()->is_klass(), "must be"); + assert(info.cached_metadata() == nullptr || info.cached_metadata()->is_klass(), "must be"); tty->print_cr ("IC@" INTPTR_FORMAT ": monomorphic to compiled (rcvr klass = %s) %s", p2i(instruction_address()), - (info.cached_metadata() != NULL) ? ((Klass*)info.cached_metadata())->print_value_string() : "NULL", + (info.cached_metadata() != nullptr) ? ((Klass*)info.cached_metadata())->print_value_string() : "nullptr", (safe) ? "" : " via stub"); } } @@ -506,8 +506,8 @@ void CompiledIC::compute_monomorphic_entry(const methodHandle& method, TRAPS) { CompiledMethod* method_code = method->code(); - address entry = NULL; - if (method_code != NULL && method_code->is_in_use() && !method_code->is_unloading()) { + address entry = nullptr; + if (method_code != nullptr && method_code->is_in_use() && !method_code->is_unloading()) { assert(method_code->is_compiled(), "must be compiled"); // Call to compiled code // @@ -532,16 +532,16 @@ void CompiledIC::compute_monomorphic_entry(const methodHandle& method, entry = method_code->entry_point(); } } - if (entry != NULL) { + if (entry != nullptr) { // Call to near compiled code. - info.set_compiled_entry(entry, is_optimized ? NULL : receiver_klass, is_optimized); + info.set_compiled_entry(entry, is_optimized ? nullptr : receiver_klass, is_optimized); } else { if (is_optimized) { // Use stub entry info.set_interpreter_entry(method()->get_c2i_entry(), method()); } else { // Use icholder entry - assert(method_code == NULL || method_code->is_compiled(), "must be compiled"); + assert(method_code == nullptr || method_code->is_compiled(), "must be compiled"); CompiledICHolder* holder = new CompiledICHolder(method(), receiver_klass); info.set_icholder_entry(method()->get_c2i_unverified_entry(), holder); } @@ -552,13 +552,13 @@ void CompiledIC::compute_monomorphic_entry(const methodHandle& method, bool CompiledIC::is_icholder_entry(address entry) { CodeBlob* cb = CodeCache::find_blob(entry); - if (cb != NULL && cb->is_adapter_blob()) { + if (cb != nullptr && cb->is_adapter_blob()) { return true; } // itable stubs also use CompiledICHolder - if (cb != NULL && cb->is_vtable_blob()) { + if (cb != nullptr && cb->is_vtable_blob()) { VtableStub* s = VtableStubs::entry_point(entry); - return (s != NULL) && s->is_itable_stub(); + return (s != nullptr) && s->is_itable_stub(); } return false; @@ -633,7 +633,7 @@ void CompiledStaticCall::set(const StaticCallInfo& info) { void CompiledStaticCall::compute_entry(const methodHandle& m, bool caller_is_nmethod, StaticCallInfo& info) { CompiledMethod* m_code = m->code(); info._callee = m; - if (m_code != NULL && m_code->is_in_use() && !m_code->is_unloading()) { + if (m_code != nullptr && m_code->is_in_use() && !m_code->is_unloading()) { info._to_interpreter = false; info._entry = m_code->verified_entry_point(); } else { @@ -654,7 +654,7 @@ void CompiledStaticCall::compute_entry_for_continuation_entry(const methodHandle address CompiledDirectStaticCall::find_stub_for(address instruction) { // Find reloc. information containing this call-site - RelocIterator iter((nmethod*)NULL, instruction); + RelocIterator iter((nmethod*)nullptr, instruction); while (iter.next()) { if (iter.addr() == instruction) { switch(iter.type()) { @@ -671,7 +671,7 @@ address CompiledDirectStaticCall::find_stub_for(address instruction) { } } } - return NULL; + return nullptr; } address CompiledDirectStaticCall::find_stub() { @@ -699,7 +699,7 @@ void CompiledIC::print() { void CompiledIC::print_compiled_ic() { tty->print("Inline cache at " INTPTR_FORMAT ", calling %s " INTPTR_FORMAT " cached_value " INTPTR_FORMAT, - p2i(instruction_address()), is_call_to_interpreted() ? "interpreted " : "", p2i(ic_destination()), p2i(is_optimized() ? NULL : cached_value())); + p2i(instruction_address()), is_call_to_interpreted() ? "interpreted " : "", p2i(ic_destination()), p2i(is_optimized() ? nullptr : cached_value())); } void CompiledDirectStaticCall::print() { @@ -722,7 +722,7 @@ void CompiledDirectStaticCall::verify_mt_safe(const methodHandle& callee, addres // becomes not entrant and the cache access returns null, the new // resolve will lead to a new generated LambdaForm. Method* old_method = reinterpret_cast(method_holder->data()); - assert(old_method == NULL || old_method == callee() || + assert(old_method == nullptr || old_method == callee() || callee->is_compiled_lambda_form() || !old_method->method_holder()->is_loader_alive() || old_method->is_old(), // may be race patching deoptimized nmethod due to redefinition. @@ -730,7 +730,7 @@ void CompiledDirectStaticCall::verify_mt_safe(const methodHandle& callee, addres address destination = jump->jump_destination(); assert(destination == (address)-1 || destination == entry - || old_method == NULL || !old_method->method_holder()->is_loader_alive() // may have a race due to class unloading. + || old_method == nullptr || !old_method->method_holder()->is_loader_alive() // may have a race due to class unloading. || old_method->is_old(), // may be race patching deoptimized nmethod due to redefinition. "b) MT-unsafe modification of inline cache"); } diff --git a/src/hotspot/share/code/compiledIC.hpp b/src/hotspot/share/code/compiledIC.hpp index 18bd3765507..9933310c239 100644 --- a/src/hotspot/share/code/compiledIC.hpp +++ b/src/hotspot/share/code/compiledIC.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -90,7 +90,7 @@ class CompiledICInfo : public StackObj { Metadata* cached_metadata() const { assert(!_is_icholder, ""); return (Metadata*)_cached_value; } CompiledICHolder* claim_cached_icholder() { assert(_is_icholder, ""); - assert(_cached_value != NULL, "must be non-NULL"); + assert(_cached_value != nullptr, "must be non-nullptr"); _release_icholder = false; CompiledICHolder* icholder = (CompiledICHolder*)_cached_value; icholder->claim(); @@ -126,7 +126,7 @@ class CompiledICInfo : public StackObj { _release_icholder = true; } - CompiledICInfo(): _entry(NULL), _cached_value(NULL), _is_icholder(false), + CompiledICInfo(): _entry(nullptr), _cached_value(nullptr), _is_icholder(false), _is_optimized(false), _to_interpreter(false), _release_icholder(false) { } ~CompiledICInfo() { @@ -186,7 +186,7 @@ class CompiledIC: public ResourceObj { void set_ic_destination(ICStub* stub); void set_ic_destination(address entry_point) { assert(_is_optimized, "use set_ic_destination_and_value instead"); - internal_set_ic_destination(entry_point, false, NULL, false); + internal_set_ic_destination(entry_point, false, nullptr, false); } // This only for use by ICStubs where the type of the value isn't known void set_ic_destination_and_value(address entry_point, void* value) { @@ -338,7 +338,7 @@ class StaticCallInfo { class CompiledStaticCall : public ResourceObj { public: // Code - static address emit_to_interp_stub(CodeBuffer &cbuf, address mark = NULL); + static address emit_to_interp_stub(CodeBuffer &cbuf, address mark = nullptr); static int to_interp_stub_size(); static int to_trampoline_stub_size(); static int reloc_to_interp_stub(); diff --git a/src/hotspot/share/code/compiledMethod.cpp b/src/hotspot/share/code/compiledMethod.cpp index 6e83e17b482..442de79c13a 100644 --- a/src/hotspot/share/code/compiledMethod.cpp +++ b/src/hotspot/share/code/compiledMethod.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType ty : CodeBlob(name, type, layout, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments, compiled), _mark_for_deoptimization_status(not_marked), _method(method), - _gc_data(NULL) + _gc_data(nullptr) { init_defaults(); } @@ -68,17 +68,17 @@ CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType ty frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments, compiled), _mark_for_deoptimization_status(not_marked), _method(method), - _gc_data(NULL) + _gc_data(nullptr) { init_defaults(); } void CompiledMethod::init_defaults() { { // avoid uninitialized fields, even for short time periods - _scopes_data_begin = NULL; - _deopt_handler_begin = NULL; - _deopt_mh_handler_begin = NULL; - _exception_cache = NULL; + _scopes_data_begin = nullptr; + _deopt_handler_begin = nullptr; + _deopt_mh_handler_begin = nullptr; + _exception_cache = nullptr; } _has_unsafe_access = 0; _has_method_handle_invokes = 0; @@ -89,7 +89,7 @@ void CompiledMethod::init_defaults() { bool CompiledMethod::is_method_handle_return(address return_pc) { if (!has_method_handle_invokes()) return false; PcDesc* pd = pc_desc_at(return_pc); - if (pd == NULL) + if (pd == nullptr) return false; return pd->is_method_handle_invoke(); } @@ -108,14 +108,14 @@ const char* CompiledMethod::state() const { return "not_entrant"; default: fatal("unexpected method state: %d", state); - return NULL; + return nullptr; } } //----------------------------------------------------------------------------- void CompiledMethod::mark_for_deoptimization(bool inc_recompile_counts) { // assert(can_be_deoptimized(), ""); // in some places we check before marking, in others not. - MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock, + MutexLocker ml(CompiledMethod_lock->owned_by_self() ? nullptr : CompiledMethod_lock, Mutex::_no_safepoint_check_flag); if (_mark_for_deoptimization_status != deoptimize_done) { // can't go backwards _mark_for_deoptimization_status = (inc_recompile_counts ? deoptimize : deoptimize_noupdate); @@ -130,12 +130,12 @@ ExceptionCache* CompiledMethod::exception_cache_acquire() const { void CompiledMethod::add_exception_cache_entry(ExceptionCache* new_entry) { assert(ExceptionCache_lock->owned_by_self(),"Must hold the ExceptionCache_lock"); - assert(new_entry != NULL,"Must be non null"); - assert(new_entry->next() == NULL, "Must be null"); + assert(new_entry != nullptr,"Must be non null"); + assert(new_entry->next() == nullptr, "Must be null"); for (;;) { ExceptionCache *ec = exception_cache(); - if (ec != NULL) { + if (ec != nullptr) { Klass* ex_klass = ec->exception_type(); if (!ex_klass->is_loader_alive()) { // We must guarantee that entries are not inserted with new next pointer @@ -151,7 +151,7 @@ void CompiledMethod::add_exception_cache_entry(ExceptionCache* new_entry) { continue; } ec = exception_cache(); - if (ec != NULL) { + if (ec != nullptr) { new_entry->set_next(ec); } } @@ -177,19 +177,19 @@ void CompiledMethod::clean_exception_cache() { // That similarly implies that CAS operations on ExceptionCache entries do not // suffer from ABA problems as unlinking and deletion is separated by a global // handshake operation. - ExceptionCache* prev = NULL; + ExceptionCache* prev = nullptr; ExceptionCache* curr = exception_cache_acquire(); - while (curr != NULL) { + while (curr != nullptr) { ExceptionCache* next = curr->next(); if (!curr->exception_type()->is_loader_alive()) { - if (prev == NULL) { + if (prev == nullptr) { // Try to clean head; this is contended by concurrent inserts, that // both lazily clean the head, and insert entries at the head. If // the CAS fails, the operation is restarted. if (Atomic::cmpxchg(&_exception_cache, curr, next) != curr) { - prev = NULL; + prev = nullptr; curr = exception_cache_acquire(); continue; } @@ -217,14 +217,14 @@ address CompiledMethod::handler_for_exception_and_pc(Handle exception, address p // have false negatives. This is okay, as it can only happen during // the first few exception lookups for a given nmethod. ExceptionCache* ec = exception_cache_acquire(); - while (ec != NULL) { + while (ec != nullptr) { address ret_val; - if ((ret_val = ec->match(exception,pc)) != NULL) { + if ((ret_val = ec->match(exception,pc)) != nullptr) { return ret_val; } ec = ec->next(); } - return NULL; + return nullptr; } void CompiledMethod::add_handler_for_exception_and_pc(Handle exception, address pc, address handler) { @@ -237,7 +237,7 @@ void CompiledMethod::add_handler_for_exception_and_pc(Handle exception, address MutexLocker ml(ExceptionCache_lock); ExceptionCache* target_entry = exception_cache_entry_for_exception(exception); - if (target_entry == NULL || !target_entry->add_address_and_handler(pc,handler)) { + if (target_entry == nullptr || !target_entry->add_address_and_handler(pc,handler)) { target_entry = new ExceptionCache(exception,pc,handler); add_exception_cache_entry(target_entry); } @@ -248,13 +248,13 @@ void CompiledMethod::add_handler_for_exception_and_pc(Handle exception, address // directly. ExceptionCache* CompiledMethod::exception_cache_entry_for_exception(Handle exception) { ExceptionCache* ec = exception_cache_acquire(); - while (ec != NULL) { + while (ec != nullptr) { if (ec->match_exception_with_space(exception)) { return ec; } ec = ec->next(); } - return NULL; + return nullptr; } //-------------end of code for ExceptionCache-------------- @@ -281,7 +281,7 @@ bool CompiledMethod::is_at_poll_or_poll_return(address pc) { void CompiledMethod::verify_oop_relocations() { // Ensure sure that the code matches the current oop values - RelocIterator iter(this, NULL, NULL); + RelocIterator iter(this, nullptr, nullptr); while (iter.next()) { if (iter.type() == relocInfo::oop_type) { oop_Relocation* reloc = iter.oop_reloc(); @@ -295,13 +295,13 @@ void CompiledMethod::verify_oop_relocations() { ScopeDesc* CompiledMethod::scope_desc_at(address pc) { PcDesc* pd = pc_desc_at(pc); - guarantee(pd != NULL, "scope must be present"); + guarantee(pd != nullptr, "scope must be present"); return new ScopeDesc(this, pd); } ScopeDesc* CompiledMethod::scope_desc_near(address pc) { PcDesc* pd = pc_desc_near(pc); - guarantee(pd != NULL, "scope must be present"); + guarantee(pd != nullptr, "scope must be present"); return new ScopeDesc(this, pd); } @@ -322,7 +322,7 @@ address CompiledMethod::oops_reloc_begin() const { // It is not safe to read oops concurrently using entry barriers, if their // location depend on whether the nmethod is entrant or not. - // assert(BarrierSet::barrier_set()->barrier_set_nmethod() == NULL, "Not safe oop scan"); + // assert(BarrierSet::barrier_set()->barrier_set_nmethod() == nullptr, "Not safe oop scan"); address low_boundary = verified_entry_point(); if (!is_in_use() && is_nmethod()) { @@ -348,7 +348,7 @@ int CompiledMethod::verify_icholder_relocations() { tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder())); ic->print(); } - assert(ic->cached_icholder() != NULL, "must be non-NULL"); + assert(ic->cached_icholder() != nullptr, "must be non-nullptr"); count++; } } @@ -360,7 +360,7 @@ int CompiledMethod::verify_icholder_relocations() { // Method that knows how to preserve outgoing arguments at call. This method must be // called with a frame corresponding to a Java invoke void CompiledMethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { - if (method() == NULL) { + if (method() == nullptr) { return; } @@ -378,7 +378,7 @@ void CompiledMethod::preserve_callee_argument_oops(frame fr, const RegisterMap * // The method attached by JIT-compilers should be used, if present. // Bytecode can be inaccurate in such case. Method* callee = attached_method_before_pc(pc); - if (callee != NULL) { + if (callee != nullptr) { has_receiver = !(callee->access_flags().is_static()); has_appendix = false; signature = callee->signature(); @@ -412,7 +412,7 @@ Method* CompiledMethod::attached_method(address call_instr) { } } } - return NULL; // not found + return nullptr; // not found } Method* CompiledMethod::attached_method_before_pc(address pc) { @@ -420,7 +420,7 @@ Method* CompiledMethod::attached_method_before_pc(address pc) { NativeCall* ncall = nativeCall_before(pc); return attached_method(ncall->instruction_address()); } - return NULL; // not a call + return nullptr; // not a call } void CompiledMethod::clear_inline_caches() { @@ -449,7 +449,7 @@ void CompiledMethod::clear_ic_callsites() { // Check class_loader is alive for this bit of metadata. class CheckClass : public MetadataClosure { void do_metadata(Metadata* md) { - Klass* klass = NULL; + Klass* klass = nullptr; if (md->is_klass()) { klass = ((Klass*)md); } else if (md->is_method()) { @@ -480,7 +480,7 @@ bool CompiledMethod::clean_ic_if_metadata_is_dead(CompiledIC *ic) { } } else { Metadata* ic_metdata = ic->cached_metadata(); - if (ic_metdata != NULL) { + if (ic_metdata != nullptr) { if (ic_metdata->is_klass()) { if (((Klass*)ic_metdata)->is_loader_alive()) { return true; @@ -509,8 +509,8 @@ template static bool clean_if_nmethod_is_unloaded(CompiledICorStaticCall *ic, address addr, CompiledMethod* from, bool clean_all) { CodeBlob *cb = CodeCache::find_blob(addr); - CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; - if (nm != NULL) { + CompiledMethod* nm = (cb != nullptr) ? cb->as_compiled_method_or_null() : nullptr; + if (nm != nullptr) { // Clean inline caches pointing to bad nmethods if (clean_all || !nm->is_in_use() || nm->is_unloading() || (nm->method()->code() != nm)) { if (!ic->set_to_clean(!from->is_unloading())) { @@ -561,13 +561,13 @@ bool CompiledMethod::unload_nmethod_caches(bool unloading_occurred) { void CompiledMethod::run_nmethod_entry_barrier() { BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod(); - if (bs_nm != NULL) { + if (bs_nm != nullptr) { // We want to keep an invariant that nmethods found through iterations of a Thread's // nmethods found in safepoints have gone through an entry barrier and are not armed. // By calling this nmethod entry barrier, it plays along and acts // like any other nmethod found on the stack of a thread (fewer surprises). nmethod* nm = as_nmethod_or_null(); - if (nm != NULL && bs_nm->is_armed(nm)) { + if (nm != nullptr && bs_nm->is_armed(nm)) { bool alive = bs_nm->nmethod_entry_barrier(nm); assert(alive, "should be alive"); } @@ -655,10 +655,10 @@ bool CompiledMethod::cleanup_inline_caches_impl(bool unloading_occurred, bool cl } metadata_Relocation* r = iter.metadata_reloc(); Metadata* md = r->metadata_value(); - if (md != NULL && md->is_method()) { + if (md != nullptr && md->is_method()) { Method* method = static_cast(md); if (!method->method_holder()->is_loader_alive()) { - Atomic::store(r->metadata_addr(), (Method*)NULL); + Atomic::store(r->metadata_addr(), (Method*)nullptr); if (!r->metadata_is_immediate()) { r->fix_metadata_relocation(); @@ -686,7 +686,7 @@ address CompiledMethod::continuation_for_implicit_exception(address pc, bool for Thread* thread = Thread::current(); ResourceMark rm(thread); CodeBlob* cb = CodeCache::find_blob(pc); - assert(cb != NULL && cb == this, ""); + assert(cb != nullptr && cb == this, ""); ttyLocker ttyl; tty->print_cr("implicit exception happened at " INTPTR_FORMAT, p2i(pc)); print(); @@ -697,7 +697,7 @@ address CompiledMethod::continuation_for_implicit_exception(address pc, bool for #endif if (cont_offset == 0) { // Let the normal error handling report the exception - return NULL; + return nullptr; } if (cont_offset == exception_offset) { #if INCLUDE_JVMCI diff --git a/src/hotspot/share/code/compiledMethod.hpp b/src/hotspot/share/code/compiledMethod.hpp index f1a7bd1997d..8a4f08e3b12 100644 --- a/src/hotspot/share/code/compiledMethod.hpp +++ b/src/hotspot/share/code/compiledMethod.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -95,7 +95,7 @@ class PcDescCache { typedef PcDesc* PcDescPtr; volatile PcDescPtr _pc_descs[cache_size]; // last cache_size pc_descs found public: - PcDescCache() { debug_only(_pc_descs[0] = NULL); } + PcDescCache() { debug_only(_pc_descs[0] = nullptr); } void reset_to(PcDesc* initial_pc_desc); PcDesc* find_pc_desc(int pc_offset, bool approximate); void add_pc_desc(PcDesc* pc_desc); @@ -130,7 +130,7 @@ public: PcDesc* find_pc_desc(address pc, bool approximate, const PcDescSearch& search) { address base_address = search.code_begin(); PcDesc* desc = _pc_desc_cache.last_pc_desc(); - if (desc != NULL && desc->pc_offset() == pc - base_address) { + if (desc != nullptr && desc->pc_offset() == pc - base_address) { return desc; } return find_pc_desc_internal(pc, approximate, search); @@ -221,8 +221,8 @@ public: virtual int osr_entry_bci() const = 0; Method* method() const { return _method; } virtual void print_pcs() = 0; - bool is_native_method() const { return _method != NULL && _method->is_native(); } - bool is_java_method() const { return _method != NULL && !_method->is_native(); } + bool is_native_method() const { return _method != nullptr && _method->is_native(); } + bool is_java_method() const { return _method != nullptr && !_method->is_native(); } // ScopeDesc retrieval operation PcDesc* pc_desc_at(address pc) { return find_pc_desc(pc, false); } diff --git a/src/hotspot/share/code/compiledMethod.inline.hpp b/src/hotspot/share/code/compiledMethod.inline.hpp index 30b5d0b67c6..a5f768fc973 100644 --- a/src/hotspot/share/code/compiledMethod.inline.hpp +++ b/src/hotspot/share/code/compiledMethod.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,13 +58,13 @@ inline bool CompiledMethod::is_deopt_mh_entry(address pc) { // (b) it is a deopt PC inline address CompiledMethod::get_deopt_original_pc(const frame* fr) { - if (fr->cb() == NULL) return NULL; + if (fr->cb() == nullptr) return nullptr; CompiledMethod* cm = fr->cb()->as_compiled_method_or_null(); - if (cm != NULL && cm->is_deopt_pc(fr->pc())) + if (cm != nullptr && cm->is_deopt_pc(fr->pc())) return cm->get_original_pc(fr); - return NULL; + return nullptr; } diff --git a/src/hotspot/share/code/compressedStream.cpp b/src/hotspot/share/code/compressedStream.cpp index 29d19177cf6..a26b78e47e5 100644 --- a/src/hotspot/share/code/compressedStream.cpp +++ b/src/hotspot/share/code/compressedStream.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,7 +72,7 @@ jlong CompressedReadStream::read_long() { return jlong_from(high, low); } -CompressedWriteStream::CompressedWriteStream(int initial_size) : CompressedStream(NULL, 0) { +CompressedWriteStream::CompressedWriteStream(int initial_size) : CompressedStream(nullptr, 0) { _buffer = NEW_RESOURCE_ARRAY(u_char, initial_size); _size = initial_size; _position = 0; diff --git a/src/hotspot/share/code/debugInfo.cpp b/src/hotspot/share/code/debugInfo.cpp index 8b735932720..5a420fd8a14 100644 --- a/src/hotspot/share/code/debugInfo.cpp +++ b/src/hotspot/share/code/debugInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ void DebugInfoWriteStream::write_metadata(Metadata* h) { oop DebugInfoReadStream::read_oop() { nmethod* nm = const_cast(code())->as_nmethod_or_null(); oop o; - if (nm != NULL) { + if (nm != nullptr) { // Despite these oops being found inside nmethods that are on-stack, // they are not kept alive by all GCs (e.g. G1 and Shenandoah). o = nm->oop_at_phantom(read_int()); @@ -68,7 +68,7 @@ oop DebugInfoReadStream::read_oop() { ScopeValue* DebugInfoReadStream::read_object_value(bool is_auto_box) { int id = read_int(); #ifdef ASSERT - assert(_obj_pool != NULL, "object pool does not exist"); + assert(_obj_pool != nullptr, "object pool does not exist"); for (int i = _obj_pool->length() - 1; i >= 0; i--) { assert(_obj_pool->at(i)->as_ObjectValue()->id() != id, "should not be read twice"); } @@ -82,7 +82,7 @@ ScopeValue* DebugInfoReadStream::read_object_value(bool is_auto_box) { ScopeValue* DebugInfoReadStream::get_cached_object() { int id = read_int(); - assert(_obj_pool != NULL, "object pool does not exist"); + assert(_obj_pool != nullptr, "object pool does not exist"); for (int i = _obj_pool->length() - 1; i >= 0; i--) { ObjectValue* ov = _obj_pool->at(i)->as_ObjectValue(); if (ov->id() == id) { @@ -90,7 +90,7 @@ ScopeValue* DebugInfoReadStream::get_cached_object() { } } ShouldNotReachHere(); - return NULL; + return nullptr; } // Serializing scope values @@ -101,7 +101,7 @@ enum { LOCATION_CODE = 0, CONSTANT_INT_CODE = 1, CONSTANT_OOP_CODE = 2, AUTO_BOX_OBJECT_CODE = 7, MARKER_CODE = 8 }; ScopeValue* ScopeValue::read_from(DebugInfoReadStream* stream) { - ScopeValue* result = NULL; + ScopeValue* result = nullptr; switch(stream->read_int()) { case LOCATION_CODE: result = new LocationValue(stream); break; case CONSTANT_INT_CODE: result = new ConstantIntValue(stream); break; @@ -244,7 +244,7 @@ void ConstantOopWriteValue::write_on(DebugInfoWriteStream* stream) { // cannot use ThreadInVMfromNative here since in case of JVMCI compiler, // thread is already in VM state. ThreadInVMfromUnknown tiv; - assert(JNIHandles::resolve(value()) == NULL || + assert(JNIHandles::resolve(value()) == nullptr || Universe::heap()->is_in(JNIHandles::resolve(value())), "Should be in heap"); } @@ -265,7 +265,7 @@ void ConstantOopWriteValue::print_on(outputStream* st) const { ConstantOopReadValue::ConstantOopReadValue(DebugInfoReadStream* stream) { _value = Handle(Thread::current(), stream->read_oop()); - assert(_value() == NULL || + assert(_value() == nullptr || Universe::heap()->is_in(_value()), "Should be in heap"); } @@ -274,10 +274,10 @@ void ConstantOopReadValue::write_on(DebugInfoWriteStream* stream) { } void ConstantOopReadValue::print_on(outputStream* st) const { - if (value()() != NULL) { + if (value()() != nullptr) { value()()->print_value_on(st); } else { - st->print("NULL"); + st->print("nullptr"); } } diff --git a/src/hotspot/share/code/debugInfo.hpp b/src/hotspot/share/code/debugInfo.hpp index 96336772b65..a804af2d233 100644 --- a/src/hotspot/share/code/debugInfo.hpp +++ b/src/hotspot/share/code/debugInfo.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -138,7 +138,7 @@ class ObjectValue: public ScopeValue { ObjectValue(int id) : _id(id) - , _klass(NULL) + , _klass(nullptr) , _field_values() , _value() , _visited(false) {} @@ -301,7 +301,7 @@ class DebugInfoReadStream : public CompressedReadStream { const CompiledMethod* code() const { return _code; } GrowableArray* _obj_pool; public: - DebugInfoReadStream(const CompiledMethod* code, int offset, GrowableArray* obj_pool = NULL) : + DebugInfoReadStream(const CompiledMethod* code, int offset, GrowableArray* obj_pool = nullptr) : CompressedReadStream(code->scopes_data_begin(), offset) { _code = code; _obj_pool = obj_pool; @@ -312,7 +312,7 @@ class DebugInfoReadStream : public CompressedReadStream { Method* read_method() { Method* o = (Method*)(code()->metadata_at(read_int())); // is_metadata() is a faster check than is_metaspace_object() - assert(o == NULL || o->is_metadata(), "meta data only"); + assert(o == nullptr || o->is_metadata(), "meta data only"); return o; } ScopeValue* read_object_value(bool is_auto_box); diff --git a/src/hotspot/share/code/debugInfoRec.cpp b/src/hotspot/share/code/debugInfoRec.cpp index 301345abe24..15353bf2872 100644 --- a/src/hotspot/share/code/debugInfoRec.cpp +++ b/src/hotspot/share/code/debugInfoRec.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,7 +82,7 @@ public: return that; } } - return NULL; + return nullptr; } static int compare(DIR_Chunk* const & a, DIR_Chunk* const & b) { @@ -137,7 +137,7 @@ DebugInformationRecorder::DebugInformationRecorder(OopRecorder* oop_recorder) _oop_recorder = oop_recorder; _all_chunks = new GrowableArray(300); - _next_chunk = _next_chunk_limit = NULL; + _next_chunk = _next_chunk_limit = nullptr; add_new_pc_offset(PcDesc::lower_offset_limit); // sentinel record @@ -196,7 +196,7 @@ void DebugInformationRecorder::add_new_pc_offset(int pc_offset) { int DebugInformationRecorder::serialize_monitor_values(GrowableArray* monitors) { - if (monitors == NULL || monitors->is_empty()) return DebugInformationRecorder::serialized_null; + if (monitors == nullptr || monitors->is_empty()) return DebugInformationRecorder::serialized_null; assert(_recording_state == rs_safepoint, "must be recording a safepoint"); int result = stream()->position(); stream()->write_int(monitors->length()); @@ -217,7 +217,7 @@ int DebugInformationRecorder::serialize_monitor_values(GrowableArray* values) { - if (values == NULL || values->is_empty()) return DebugInformationRecorder::serialized_null; + if (values == nullptr || values->is_empty()) return DebugInformationRecorder::serialized_null; assert(_recording_state == rs_safepoint, "must be recording a safepoint"); int result = stream()->position(); assert(result != serialized_null, "sanity"); @@ -315,17 +315,17 @@ void DebugInformationRecorder::describe_scope(int pc_offset, // serialize scope Metadata* method_enc; - if (method != NULL) { + if (method != nullptr) { method_enc = method->constant_encoding(); } else if (methodH.not_null()) { method_enc = methodH(); } else { - method_enc = NULL; + method_enc = nullptr; } int method_enc_index = oop_recorder()->find_index(method_enc); stream()->write_int(method_enc_index); stream()->write_bci(bci); - assert(method == NULL || + assert(method == nullptr || (method->is_native() && bci == 0) || (!method->is_native() && 0 <= bci && bci < method->code_size()) || bci == -1, "illegal bci"); @@ -352,7 +352,7 @@ void DebugInformationRecorder::describe_scope(int pc_offset, void DebugInformationRecorder::dump_object_pool(GrowableArray* objects) { guarantee( _pcs_length > 0, "safepoint must exist before describing scopes"); PcDesc* last_pd = &_pcs[_pcs_length-1]; - if (objects != NULL) { + if (objects != nullptr) { for (int i = objects->length() - 1; i >= 0; i--) { objects->at(i)->as_ObjectValue()->set_visited(false); } diff --git a/src/hotspot/share/code/debugInfoRec.hpp b/src/hotspot/share/code/debugInfoRec.hpp index 0f8ec1846de..f6d7cf6d278 100644 --- a/src/hotspot/share/code/debugInfoRec.hpp +++ b/src/hotspot/share/code/debugInfoRec.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -109,9 +109,9 @@ class DebugInformationRecorder: public ResourceObj { bool return_oop = false, bool has_ea_local_in_scope = false, bool arg_escape = false, - DebugToken* locals = NULL, - DebugToken* expressions = NULL, - DebugToken* monitors = NULL); + DebugToken* locals = nullptr, + DebugToken* expressions = nullptr, + DebugToken* monitors = nullptr); void dump_object_pool(GrowableArray* objects); diff --git a/src/hotspot/share/code/dependencies.cpp b/src/hotspot/share/code/dependencies.cpp index 6909aa6b2d0..ae370e07941 100644 --- a/src/hotspot/share/code/dependencies.cpp +++ b/src/hotspot/share/code/dependencies.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,11 +67,11 @@ void Dependencies::initialize(ciEnv* env) { #if INCLUDE_JVMCI _using_dep_values = false; #endif - DEBUG_ONLY(_deps[end_marker] = NULL); + DEBUG_ONLY(_deps[end_marker] = nullptr); for (int i = (int)FIRST_TYPE; i < (int)TYPE_LIMIT; i++) { _deps[i] = new(arena) GrowableArray(arena, 10, 0, 0); } - _content_bytes = NULL; + _content_bytes = nullptr; _size_in_bytes = (size_t)-1; assert(TYPE_LIMIT <= (1<(arena, 500, 0, 0); _using_dep_values = true; - DEBUG_ONLY(_dep_values[end_marker] = NULL); + DEBUG_ONLY(_dep_values[end_marker] = nullptr); for (int i = (int)FIRST_TYPE; i < (int)TYPE_LIMIT; i++) { _dep_values[i] = new(arena) GrowableArray(arena, 10, 0, DepValue()); } - _content_bytes = NULL; + _content_bytes = nullptr; _size_in_bytes = (size_t)-1; assert(TYPE_LIMIT <= (1<as_metadata()->as_method()->holder(); default: - return NULL; // let NULL be NULL + return nullptr; // let nullptr be nullptr } } @@ -493,7 +493,7 @@ Klass* Dependencies::ctxk_encoded_as_null(DepType dept, Metadata* x) { assert(x->is_method(), "sanity"); return ((Method*)x)->method_holder(); default: - return NULL; // let NULL be NULL + return nullptr; // let nullptr be nullptr } } @@ -630,10 +630,10 @@ Dependencies::DepType Dependencies::validate_dependencies(CompileTask* task, cha DepType result = end_marker; for (Dependencies::DepStream deps(this); deps.next(); ) { Klass* witness = deps.check_dependency(); - if (witness != NULL) { + if (witness != nullptr) { if (klass_violations == 0) { result = deps.type(); - if (failure_detail != NULL && klass_violations == 0) { + if (failure_detail != nullptr && klass_violations == 0) { // Use a fixed size buffer to prevent the string stream from // resizing in the context of an inner resource mark. char* buffer = NEW_RESOURCE_ARRAY(char, O_BUFLEN); @@ -643,7 +643,7 @@ Dependencies::DepType Dependencies::validate_dependencies(CompileTask* task, cha } } klass_violations++; - if (xtty == NULL) { + if (xtty == nullptr) { // If we're not logging then a single violation is sufficient, // otherwise we want to log all the dependences which were // violated. @@ -657,7 +657,7 @@ Dependencies::DepType Dependencies::validate_dependencies(CompileTask* task, cha // for the sake of the compiler log, print out current dependencies: void Dependencies::log_all_dependencies() { - if (log() == NULL) return; + if (log() == nullptr) return; ResourceMark rm; for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { DepType dept = (DepType)deptv; @@ -684,7 +684,7 @@ void Dependencies::write_dependency_to(CompileLog* log, DepType dept, GrowableArray* args, Klass* witness) { - if (log == NULL) { + if (log == nullptr) { return; } ResourceMark rm; @@ -707,7 +707,7 @@ void Dependencies::write_dependency_to(CompileLog* log, DepType dept, GrowableArray* args, Klass* witness) { - if (log == NULL) { + if (log == nullptr) { return; } ResourceMark rm; @@ -720,7 +720,7 @@ void Dependencies::write_dependency_to(CompileLog* log, argids->push(log->identify(obj->as_metadata())); } } - if (witness != NULL) { + if (witness != nullptr) { log->begin_elem("dependency_failed"); } else { log->begin_elem("dependency"); @@ -739,7 +739,7 @@ void Dependencies::write_dependency_to(CompileLog* log, log->print(" x%d='%d'", j, argids->at(j)); } } - if (witness != NULL) { + if (witness != nullptr) { log->object("witness", witness); log->stamp(); } @@ -750,14 +750,14 @@ void Dependencies::write_dependency_to(xmlStream* xtty, DepType dept, GrowableArray* args, Klass* witness) { - if (xtty == NULL) { + if (xtty == nullptr) { return; } Thread* thread = Thread::current(); HandleMark rm(thread); ttyLocker ttyl; int ctxkj = dep_context_arg(dept); // -1 if no context arg - if (witness != NULL) { + if (witness != nullptr) { xtty->begin_elem("dependency_failed"); } else { xtty->begin_elem("dependency"); @@ -786,7 +786,7 @@ void Dependencies::write_dependency_to(xmlStream* xtty, } } } - if (witness != NULL) { + if (witness != nullptr) { xtty->object("witness", witness); xtty->stamp(); } @@ -798,7 +798,7 @@ void Dependencies::print_dependency(DepType dept, GrowableArray* ar ResourceMark rm; ttyLocker ttyl; // keep the following output all in one block st->print_cr("%s of type %s", - (witness == NULL)? "Dependency": "Failed dependency", + (witness == nullptr)? "Dependency": "Failed dependency", dep_name(dept)); // print arguments int ctxkj = dep_context_arg(dept); // -1 if no context arg @@ -813,7 +813,7 @@ void Dependencies::print_dependency(DepType dept, GrowableArray* ar put_star = !Dependencies::is_concrete_klass((Klass*)arg.metadata_value()); } else if (arg.is_method()) { what = "method "; - put_star = !Dependencies::is_concrete_method((Method*)arg.metadata_value(), NULL); + put_star = !Dependencies::is_concrete_method((Method*)arg.metadata_value(), nullptr); } else if (arg.is_klass()) { what = "class "; } else { @@ -832,7 +832,7 @@ void Dependencies::print_dependency(DepType dept, GrowableArray* ar st->cr(); } - if (witness != NULL) { + if (witness != nullptr) { bool put_star = !Dependencies::is_concrete_klass(witness); st->print_cr(" witness = %s%s", (put_star? "*": ""), @@ -841,7 +841,7 @@ void Dependencies::print_dependency(DepType dept, GrowableArray* ar } void Dependencies::DepStream::log_dependency(Klass* witness) { - if (_deps == NULL && xtty == NULL) return; // fast cutout for runtime + if (_deps == nullptr && xtty == nullptr) return; // fast cutout for runtime ResourceMark rm; const int nargs = argument_count(); GrowableArray* args = new GrowableArray(nargs); @@ -853,8 +853,8 @@ void Dependencies::DepStream::log_dependency(Klass* witness) { } } int argslen = args->length(); - if (_deps != NULL && _deps->log() != NULL) { - if (ciEnv::current() != NULL) { + if (_deps != nullptr && _deps->log() != nullptr) { + if (ciEnv::current() != nullptr) { Dependencies::write_dependency_to(_deps->log(), type(), args, witness); } else { // Treat the CompileLog as an xmlstream instead @@ -880,7 +880,7 @@ void Dependencies::DepStream::print_dependency(Klass* witness, bool verbose, out int argslen = args->length(); Dependencies::print_dependency(type(), args, witness, st); if (verbose) { - if (_code != NULL) { + if (_code != nullptr) { st->print(" code: "); _code->print_value_on(st); st->cr(); @@ -897,13 +897,13 @@ void Dependencies::DepStream::initial_asserts(size_t byte_limit) { assert(must_be_in_vm(), "raw oops here"); _byte_limit = byte_limit; _type = (DepType)(end_marker-1); // defeat "already at end" assert - assert((_code!=NULL) + (_deps!=NULL) == 1, "one or t'other"); + assert((_code!=nullptr) + (_deps!=nullptr) == 1, "one or t'other"); } #endif //ASSERT bool Dependencies::DepStream::next() { assert(_type != end_marker, "already at end"); - if (_bytes.position() == 0 && _code != NULL + if (_bytes.position() == 0 && _code != nullptr && _code->dependencies_size() == 0) { // Method has no dependencies at all. return false; @@ -934,8 +934,8 @@ bool Dependencies::DepStream::next() { } inline Metadata* Dependencies::DepStream::recorded_metadata_at(int i) { - Metadata* o = NULL; - if (_code != NULL) { + Metadata* o = nullptr; + if (_code != nullptr) { o = _code->metadata_at(i); } else { o = _deps->oop_recorder()->metadata_at(i); @@ -944,7 +944,7 @@ inline Metadata* Dependencies::DepStream::recorded_metadata_at(int i) { } inline oop Dependencies::DepStream::recorded_oop_at(int i) { - return (_code != NULL) + return (_code != nullptr) ? _code->oop_at(i) : JNIHandles::resolve(_deps->oop_recorder()->oop_at(i)); } @@ -952,14 +952,14 @@ inline oop Dependencies::DepStream::recorded_oop_at(int i) { Metadata* Dependencies::DepStream::argument(int i) { Metadata* result = recorded_metadata_at(argument_index(i)); - if (result == NULL) { // Explicit context argument can be compressed + if (result == nullptr) { // Explicit context argument can be compressed int ctxkj = dep_context_arg(type()); // -1 if no explicit context arg if (ctxkj >= 0 && i == ctxkj && ctxkj+1 < argument_count()) { result = ctxk_encoded_as_null(type(), argument(ctxkj+1)); } } - assert(result == NULL || result->is_klass() || result->is_method(), "must be"); + assert(result == nullptr || result->is_klass() || result->is_method(), "must be"); return result; } @@ -988,7 +988,7 @@ InstanceKlass* Dependencies::DepStream::context_type() { int ctxkj = dep_context_arg(type()); // -1 if no explicit context arg if (ctxkj >= 0) { Metadata* k = argument(ctxkj); - assert(k != NULL && k->is_klass(), "type check"); + assert(k != nullptr && k->is_klass(), "type check"); return InstanceKlass::cast((Klass*)k); } } @@ -999,14 +999,14 @@ InstanceKlass* Dependencies::DepStream::context_type() { int ctxkj = dep_implicit_context_arg(type()); if (ctxkj >= 0) { Klass* k = argument_oop(ctxkj)->klass(); - assert(k != NULL, "type check"); + assert(k != nullptr, "type check"); return InstanceKlass::cast(k); } } // And some dependencies don't have a context type at all, // e.g. evol_method. - return NULL; + return nullptr; } // ----------------- DependencySignature -------------------------------------- @@ -1058,9 +1058,9 @@ class AbstractClassHierarchyWalker { #endif // ASSERT { for (uint i = 0; i < PARTICIPANT_LIMIT+1; i++) { - _participants[i] = NULL; + _participants[i] = nullptr; } - if (participant != NULL) { + if (participant != nullptr) { add_participant(participant); } } @@ -1109,7 +1109,7 @@ class AbstractClassHierarchyWalker { if (n < _num_participants) { return _participants[n]; } else { - return NULL; + return nullptr; } } @@ -1126,15 +1126,15 @@ class AbstractClassHierarchyWalker { _record_witnesses = add; } - Klass* find_witness(InstanceKlass* context_type, KlassDepChange* changes = NULL); + Klass* find_witness(InstanceKlass* context_type, KlassDepChange* changes = nullptr); static void init(); static void print_statistics(); }; -PerfCounter* AbstractClassHierarchyWalker::_perf_find_witness_anywhere_calls_count = NULL; -PerfCounter* AbstractClassHierarchyWalker::_perf_find_witness_anywhere_steps_count = NULL; -PerfCounter* AbstractClassHierarchyWalker::_perf_find_witness_in_calls_count = NULL; +PerfCounter* AbstractClassHierarchyWalker::_perf_find_witness_anywhere_calls_count = nullptr; +PerfCounter* AbstractClassHierarchyWalker::_perf_find_witness_anywhere_steps_count = nullptr; +PerfCounter* AbstractClassHierarchyWalker::_perf_find_witness_in_calls_count = nullptr; void AbstractClassHierarchyWalker::init() { if (UsePerfData) { @@ -1155,7 +1155,7 @@ Klass* AbstractClassHierarchyWalker::find_witness(InstanceKlass* context_type, K assert_locked_or_safepoint(Compile_lock); assert(_nof_requests++ == 0, "repeated requests are not supported"); - assert(changes == NULL || changes->involves_context(context_type), "irrelevant dependency"); + assert(changes == nullptr || changes->involves_context(context_type), "irrelevant dependency"); // (Note: Interfaces do not have subclasses.) // If it is an interface, search its direct implementors. @@ -1163,7 +1163,7 @@ Klass* AbstractClassHierarchyWalker::find_witness(InstanceKlass* context_type, K if (context_type->is_interface()) { int nof_impls = context_type->nof_implementors(); if (nof_impls == 0) { - return NULL; // no implementors + return nullptr; // no implementors } else if (nof_impls == 1) { // unique implementor assert(context_type != context_type->implementor(), "not unique"); context_type = InstanceKlass::cast(context_type->implementor()); @@ -1179,7 +1179,7 @@ Klass* AbstractClassHierarchyWalker::find_witness(InstanceKlass* context_type, K } assert(!context_type->is_interface(), "no interfaces allowed"); - if (changes != NULL) { + if (changes != nullptr) { if (UsePerfData) { _perf_find_witness_in_calls_count->inc(); } @@ -1201,7 +1201,7 @@ class ConcreteSubtypeFinder : public AbstractClassHierarchyWalker { virtual Klass* find_witness_anywhere(InstanceKlass* context_type); public: - ConcreteSubtypeFinder(Klass* participant = NULL) : AbstractClassHierarchyWalker(participant) {} + ConcreteSubtypeFinder(Klass* participant = nullptr) : AbstractClassHierarchyWalker(participant) {} }; bool ConcreteSubtypeFinder::is_witness(Klass* k) { @@ -1222,14 +1222,14 @@ Klass* ConcreteSubtypeFinder::find_witness_in(KlassDepChange& changes) { for (uint i = 0; i < num_participants(); i++) { if (changes.involves_context(participant(i))) { // new guy is protected from this check by previous participant - return NULL; + return nullptr; } } if (is_witness(new_type)) { return new_type; } // No witness found. The dependency remains unbroken. - return NULL; + return nullptr; } Klass* ConcreteSubtypeFinder::find_witness_anywhere(InstanceKlass* context_type) { @@ -1244,7 +1244,7 @@ Klass* ConcreteSubtypeFinder::find_witness_anywhere(InstanceKlass* context_type) } } // No witness found. The dependency remains unbroken. - return NULL; + return nullptr; } class ConcreteMethodFinder : public AbstractClassHierarchyWalker { @@ -1264,34 +1264,34 @@ class ConcreteMethodFinder : public AbstractClassHierarchyWalker { public: bool witnessed_reabstraction_in_supers(Klass* k); - ConcreteMethodFinder(Method* m, Klass* participant = NULL) : AbstractClassHierarchyWalker(participant) { - assert(m != NULL && m->is_method(), "sanity"); + ConcreteMethodFinder(Method* m, Klass* participant = nullptr) : AbstractClassHierarchyWalker(participant) { + assert(m != nullptr && m->is_method(), "sanity"); _name = m->name(); _signature = m->signature(); for (int i = 0; i < PARTICIPANT_LIMIT+1; i++) { - _found_methods[i] = NULL; + _found_methods[i] = nullptr; } } - // Note: If n==num_participants, returns NULL. + // Note: If n==num_participants, returns nullptr. Method* found_method(uint n) { assert(n <= num_participants(), "oob"); Method* fm = _found_methods[n]; - assert(n == num_participants() || fm != NULL, "proper usage"); - if (fm != NULL && fm->method_holder() != participant(n)) { + assert(n == num_participants() || fm != nullptr, "proper usage"); + if (fm != nullptr && fm->method_holder() != participant(n)) { // Default methods from interfaces can be added to classes. In // that case the holder of the method is not the class but the // interface where it's defined. assert(fm->is_default_method(), "sanity"); - return NULL; + return nullptr; } return fm; } void add_participant(Klass* participant) { AbstractClassHierarchyWalker::add_participant(participant); - _found_methods[num_participants()] = NULL; + _found_methods[num_participants()] = nullptr; } bool record_witness(Klass* witness, Method* m) { @@ -1322,7 +1322,7 @@ bool ConcreteMethodFinder::is_witness(Klass* k) { return record_witness(k, m); // concrete method found } else { // Check for re-abstraction of method - if (!ik->is_interface() && m != NULL && m->is_abstract()) { + if (!ik->is_interface() && m != nullptr && m->is_abstract()) { // Found a matching abstract method 'm' in the class hierarchy. // This is fine iff 'k' is an abstract class and all concrete subtypes // of 'k' override 'm' and are participates of the current search. @@ -1332,7 +1332,7 @@ bool ConcreteMethodFinder::is_witness(Klass* k) { wf.add_participant(p); } Klass* w = wf.find_witness(ik); - if (w != NULL) { + if (w != nullptr) { Method* wm = InstanceKlass::cast(w)->find_instance_method(_name, _signature, Klass::PrivateLookupMode::skip); if (!Dependencies::is_concrete_method(wm, w)) { // Found a concrete subtype 'w' which does not override abstract method 'm'. @@ -1344,9 +1344,9 @@ bool ConcreteMethodFinder::is_witness(Klass* k) { } // Check interface defaults also, if any exist. Array* default_methods = ik->default_methods(); - if (default_methods != NULL) { + if (default_methods != nullptr) { Method* dm = ik->find_method(default_methods, _name, _signature); - if (Dependencies::is_concrete_method(dm, NULL)) { + if (Dependencies::is_concrete_method(dm, nullptr)) { return record_witness(k, dm); // default method found } } @@ -1371,7 +1371,7 @@ Klass* ConcreteMethodFinder::find_witness_in(KlassDepChange& changes) { } } // No witness found. The dependency remains unbroken. - return NULL; + return nullptr; } bool ConcreteMethodFinder::witnessed_reabstraction_in_supers(Klass* k) { @@ -1381,12 +1381,12 @@ bool ConcreteMethodFinder::witnessed_reabstraction_in_supers(Klass* k) { // Looking for a case when an abstract method is inherited into a concrete class. if (Dependencies::is_concrete_klass(k) && !k->is_interface()) { Method* m = InstanceKlass::cast(k)->find_instance_method(_name, _signature, Klass::PrivateLookupMode::skip); - if (m != NULL) { + if (m != nullptr) { return false; // no reabstraction possible: local method found } - for (InstanceKlass* super = k->java_super(); super != NULL; super = super->java_super()) { + for (InstanceKlass* super = k->java_super(); super != nullptr; super = super->java_super()) { m = super->find_instance_method(_name, _signature, Klass::PrivateLookupMode::skip); - if (m != NULL) { // inherited method found + if (m != nullptr) { // inherited method found if (m->is_abstract() || m->is_overpass()) { return record_witness(super, m); // abstract method found } @@ -1410,7 +1410,7 @@ Klass* ConcreteMethodFinder::find_witness_anywhere(InstanceKlass* context_type) } } // No witness found. The dependency remains unbroken. - return NULL; + return nullptr; } // For some method m and some class ctxk (subclass of method holder), @@ -1452,9 +1452,9 @@ class LinkedConcreteMethodFinder : public AbstractClassHierarchyWalker { void initialize(Method* participant) { for (uint i = 0; i < PARTICIPANT_LIMIT+1; i++) { - _found_methods[i] = NULL; + _found_methods[i] = nullptr; } - if (participant != NULL) { + if (participant != nullptr) { add_participant(participant, participant->method_holder()); } } @@ -1472,7 +1472,7 @@ class LinkedConcreteMethodFinder : public AbstractClassHierarchyWalker { // It is prepared based on the results of method resolution: resolved class and resolved method (as specified in JVMS-5.4.3.3). // Optionally, a method which was previously determined as a unique target (uniqm) is added as a participant // to enable dependency spot-checking and speed up the search. - LinkedConcreteMethodFinder(InstanceKlass* resolved_klass, Method* resolved_method, Method* uniqm = NULL) : AbstractClassHierarchyWalker(NULL) { + LinkedConcreteMethodFinder(InstanceKlass* resolved_klass, Method* resolved_method, Method* uniqm = nullptr) : AbstractClassHierarchyWalker(nullptr) { assert(UseVtableBasedCHA, "required"); assert(resolved_klass->is_linked(), "required"); assert(resolved_method->method_holder()->is_linked(), "required"); @@ -1487,10 +1487,10 @@ class LinkedConcreteMethodFinder : public AbstractClassHierarchyWalker { initialize(uniqm); } - // Note: If n==num_participants, returns NULL. + // Note: If n==num_participants, returns nullptr. Method* found_method(uint n) { assert(n <= num_participants(), "oob"); - assert(participant(n) != NULL || n == num_participants(), "proper usage"); + assert(participant(n) != nullptr || n == num_participants(), "proper usage"); return _found_methods[n]; } }; @@ -1503,7 +1503,7 @@ Klass* LinkedConcreteMethodFinder::find_witness_in(KlassDepChange& changes) { if (is_witness(type)) { return type; } - return NULL; // No witness found. The dependency remains unbroken. + return nullptr; // No witness found. The dependency remains unbroken. } Klass* LinkedConcreteMethodFinder::find_witness_anywhere(InstanceKlass* context_type) { @@ -1516,7 +1516,7 @@ Klass* LinkedConcreteMethodFinder::find_witness_anywhere(InstanceKlass* context_ iter.skip_subclasses(); // ignore not yet linked classes } } - return NULL; // No witness found. The dependency remains unbroken. + return nullptr; // No witness found. The dependency remains unbroken. } bool LinkedConcreteMethodFinder::is_witness(Klass* k) { @@ -1536,7 +1536,7 @@ bool LinkedConcreteMethodFinder::is_witness(Klass* k) { } Method* LinkedConcreteMethodFinder::select_method(InstanceKlass* recv_klass) { - Method* selected_method = NULL; + Method* selected_method = nullptr; if (_do_itable_lookup) { assert(_declaring_klass->is_interface(), "sanity"); bool implements_interface; // initialized by method_at_itable_or_null() @@ -1546,7 +1546,7 @@ Method* LinkedConcreteMethodFinder::select_method(InstanceKlass* recv_klass) { } else { selected_method = recv_klass->method_at_vtable(_vtable_index); } - return selected_method; // NULL when corresponding slot is empty (AbstractMethodError case) + return selected_method; // nullptr when corresponding slot is empty (AbstractMethodError case) } int LinkedConcreteMethodFinder::compute_vtable_index(InstanceKlass* resolved_klass, Method* resolved_method, @@ -1597,7 +1597,7 @@ bool Dependencies::verify_method_context(InstanceKlass* ctxk, Method* m) { return true; // Must punt the assertion to true. } Method* lm = ctxk->lookup_method(m->name(), m->signature()); - if (lm == NULL && ctxk->is_instance_klass()) { + if (lm == nullptr && ctxk->is_instance_klass()) { // It might be an interface method lm = InstanceKlass::cast(ctxk)->lookup_method_in_ordered_interfaces(m->name(), m->signature()); @@ -1606,7 +1606,7 @@ bool Dependencies::verify_method_context(InstanceKlass* ctxk, Method* m) { // Method m is inherited into ctxk. return true; } - if (lm != NULL) { + if (lm != nullptr) { if (!(lm->is_public() || lm->is_protected())) { // Method is [package-]private, so the override story is complex. return true; // Must punt the assertion to true. @@ -1633,7 +1633,7 @@ bool Dependencies::verify_method_context(InstanceKlass* ctxk, Method* m) { tty->print_cr("Dependency method not found in the associated context:"); tty->print_cr(" context = %s", ctxk->external_name()); tty->print( " method = "); m->print_short_name(tty); tty->cr(); - if (lm != NULL) { + if (lm != nullptr) { tty->print( " found = "); lm->print_short_name(tty); tty->cr(); } return false; @@ -1650,8 +1650,8 @@ bool Dependencies::is_concrete_klass(Klass* k) { } bool Dependencies::is_concrete_method(Method* m, Klass* k) { - // NULL is not a concrete method. - if (m == NULL) { + // nullptr is not a concrete method. + if (m == nullptr) { return false; } // Statics are irrelevant to virtual call sites. @@ -1663,10 +1663,10 @@ bool Dependencies::is_concrete_method(Method* m, Klass* k) { return false; } // Overpass (error) methods are not concrete if k is abstract. - if (m->is_overpass() && k != NULL) { + if (m->is_overpass() && k != nullptr) { return !k->is_abstract(); } - // Note "true" is conservative answer: overpass clause is false if k == NULL, + // Note "true" is conservative answer: overpass clause is false if k == nullptr, // implies return true if answer depends on overpass clause. return true; } @@ -1678,7 +1678,7 @@ Klass* Dependencies::find_finalizable_subclass(InstanceKlass* ik) { return sub; } } - return NULL; // not found + return nullptr; // not found } bool Dependencies::is_concrete_klass(ciInstanceKlass* k) { @@ -1705,7 +1705,7 @@ Klass* Dependencies::check_evol_method(Method* m) { || m->number_of_breakpoints() > 0) { return m->method_holder(); } else { - return NULL; + return nullptr; } } @@ -1720,16 +1720,16 @@ Klass* Dependencies::check_leaf_type(InstanceKlass* ctxk) { assert(must_be_in_vm(), "raw oops here"); assert_locked_or_safepoint(Compile_lock); Klass* sub = ctxk->subklass(); - if (sub != NULL) { + if (sub != nullptr) { return sub; } else if (ctxk->nof_implementors() != 0) { // if it is an interface, it must be unimplemented // (if it is not an interface, nof_implementors is always zero) InstanceKlass* impl = ctxk->implementor(); - assert(impl != NULL, "must be set"); + assert(impl != nullptr, "must be set"); return impl; } else { - return NULL; + return nullptr; } } @@ -1746,18 +1746,18 @@ Klass* Dependencies::check_abstract_with_unique_concrete_subtype(InstanceKlass* } -// Find the unique concrete proper subtype of ctxk, or NULL if there +// Find the unique concrete proper subtype of ctxk, or nullptr if there // is more than one concrete proper subtype. If there are no concrete // proper subtypes, return ctxk itself, whether it is concrete or not. // The returned subtype is allowed to have have further concrete subtypes. -// That is, return CC1 for CX > CC1 > CC2, but NULL for CX > { CC1, CC2 }. +// That is, return CC1 for CX > CC1 > CC2, but nullptr for CX > { CC1, CC2 }. Klass* Dependencies::find_unique_concrete_subtype(InstanceKlass* ctxk) { ConcreteSubtypeFinder wf(ctxk); // Ignore ctxk when walking. wf.record_witnesses(1); // Record one other witness when walking. Klass* wit = wf.find_witness(ctxk); - if (wit != NULL) return NULL; // Too many witnesses. + if (wit != nullptr) return nullptr; // Too many witnesses. Klass* conck = wf.participant(0); - if (conck == NULL) { + if (conck == nullptr) { return ctxk; // Return ctxk as a flag for "no subtypes". } else { #ifndef PRODUCT @@ -1766,7 +1766,7 @@ Klass* Dependencies::find_unique_concrete_subtype(InstanceKlass* ctxk) { // Turn off dependency tracing while actually testing deps. FlagSetting fs(TraceDependencies, false); if (!Dependencies::is_concrete_klass(ctxk)) { - guarantee(NULL == (void *) + guarantee(nullptr == (void *) check_abstract_with_unique_concrete_subtype(ctxk, conck), "verify dep."); } @@ -1790,7 +1790,7 @@ Klass* Dependencies::find_unique_concrete_subtype(InstanceKlass* ctxk) { // | // C (C.m uniqm) uniqm is in subtype of ctxk. bool Dependencies::is_concrete_root_method(Method* uniqm, InstanceKlass* ctxk) { - if (uniqm == NULL) { + if (uniqm == nullptr) { return false; // match Dependencies::is_concrete_method() behavior } // Theoretically, the "direction" of subtype check matters here. @@ -1810,24 +1810,24 @@ bool Dependencies::is_concrete_root_method(Method* uniqm, InstanceKlass* ctxk) { return ctxk->is_subclass_of(holder); } -// If a class (or interface) has a unique concrete method uniqm, return NULL. +// If a class (or interface) has a unique concrete method uniqm, return nullptr. // Otherwise, return a class that contains an interfering method. Klass* Dependencies::check_unique_concrete_method(InstanceKlass* ctxk, Method* uniqm, NewKlassDepChange* changes) { ConcreteMethodFinder wf(uniqm, uniqm->method_holder()); Klass* k = wf.find_witness(ctxk, changes); - if (k != NULL) { + if (k != nullptr) { return k; } - if (!Dependencies::is_concrete_root_method(uniqm, ctxk) || changes != NULL) { + if (!Dependencies::is_concrete_root_method(uniqm, ctxk) || changes != nullptr) { Klass* conck = find_witness_AME(ctxk, uniqm, changes); - if (conck != NULL) { + if (conck != nullptr) { // Found a concrete subtype 'conck' which does not override abstract root method. return conck; } } - return NULL; + return nullptr; } Klass* Dependencies::check_unique_implementor(InstanceKlass* ctxk, Klass* uniqk, NewKlassDepChange* changes) { @@ -1835,7 +1835,7 @@ Klass* Dependencies::check_unique_implementor(InstanceKlass* ctxk, Klass* uniqk, assert(ctxk->nof_implementors() > 0, "no implementors"); if (ctxk->nof_implementors() == 1) { assert(ctxk->implementor() == uniqk, "sanity"); - return NULL; + return nullptr; } return ctxk; // no unique implementor } @@ -1846,8 +1846,8 @@ Klass* Dependencies::check_unique_implementor(InstanceKlass* ctxk, Klass* uniqk, // Checks whether abstract/overpass method is inherited into/declared in newly added concrete class. // 2) Compile time analysis for abstract/overpass(abstract klass) root_m. The non uniqm subtrees are checked for concrete classes. Klass* Dependencies::find_witness_AME(InstanceKlass* ctxk, Method* m, KlassDepChange* changes) { - if (m != NULL) { - if (changes != NULL) { + if (m != nullptr) { + if (changes != nullptr) { // Spot checking version. ConcreteMethodFinder wf(m); Klass* new_type = changes->as_new_klass_change()->new_type(); @@ -1858,7 +1858,7 @@ Klass* Dependencies::find_witness_AME(InstanceKlass* ctxk, Method* m, KlassDepCh // Note: It is required that uniqm->method_holder() is the participant (see ClassHierarchyWalker::found_method()). ConcreteSubtypeFinder wf(m->method_holder()); Klass* conck = wf.find_witness(ctxk); - if (conck != NULL) { + if (conck != nullptr) { Method* cm = InstanceKlass::cast(conck)->find_instance_method(m->name(), m->signature(), Klass::PrivateLookupMode::skip); if (!Dependencies::is_concrete_method(cm, conck)) { return conck; @@ -1866,14 +1866,14 @@ Klass* Dependencies::find_witness_AME(InstanceKlass* ctxk, Method* m, KlassDepCh } } } - return NULL; + return nullptr; } // This function is used by find_unique_concrete_method(non vtable based) // to check whether subtype method overrides the base method. static bool overrides(Method* sub_m, Method* base_m) { - assert(base_m != NULL, "base method should be non null"); - if (sub_m == NULL) { + assert(base_m != nullptr, "base method should be non null"); + if (sub_m == nullptr) { return false; } /** @@ -1895,53 +1895,53 @@ static bool overrides(Method* sub_m, Method* base_m) { // Include m itself in the set, unless it is abstract. // If this set has exactly one element, return that element. Method* Dependencies::find_unique_concrete_method(InstanceKlass* ctxk, Method* m, Klass** participant) { - // Return NULL if m is marked old; must have been a redefined method. + // Return nullptr if m is marked old; must have been a redefined method. if (m->is_old()) { - return NULL; + return nullptr; } if (m->is_default_method()) { - return NULL; // not supported + return nullptr; // not supported } assert(verify_method_context(ctxk, m), "proper context"); ConcreteMethodFinder wf(m); wf.record_witnesses(1); Klass* wit = wf.find_witness(ctxk); - if (wit != NULL) return NULL; // Too many witnesses. - Method* fm = wf.found_method(0); // Will be NULL if num_parts == 0. - if (participant != NULL) { + if (wit != nullptr) return nullptr; // Too many witnesses. + Method* fm = wf.found_method(0); // Will be nullptr if num_parts == 0. + if (participant != nullptr) { (*participant) = wf.participant(0); } - if (!Dependencies::is_concrete_method(fm, NULL)) { - fm = NULL; // ignore abstract methods + if (!Dependencies::is_concrete_method(fm, nullptr)) { + fm = nullptr; // ignore abstract methods } if (Dependencies::is_concrete_method(m, ctxk)) { - if (fm == NULL) { + if (fm == nullptr) { // It turns out that m was always the only implementation. fm = m; } else if (fm != m) { // Two conflicting implementations after all. // (This can happen if m is inherited into ctxk and fm overrides it.) - return NULL; + return nullptr; } - } else if (Dependencies::find_witness_AME(ctxk, fm) != NULL) { + } else if (Dependencies::find_witness_AME(ctxk, fm) != nullptr) { // Found a concrete subtype which does not override abstract root method. - return NULL; + return nullptr; } else if (!overrides(fm, m)) { // Found method doesn't override abstract root method. - return NULL; + return nullptr; } assert(Dependencies::is_concrete_root_method(fm, ctxk) == Dependencies::is_concrete_method(m, ctxk), "mismatch"); #ifndef PRODUCT // Make sure the dependency mechanism will pass this discovery: - if (VerifyDependencies && fm != NULL) { - guarantee(NULL == (void *)check_unique_concrete_method(ctxk, fm), + if (VerifyDependencies && fm != nullptr) { + guarantee(nullptr == (void *)check_unique_concrete_method(ctxk, fm), "verify dep."); } #endif //PRODUCT return fm; } -// If a class (or interface) has a unique concrete method uniqm, return NULL. +// If a class (or interface) has a unique concrete method uniqm, return nullptr. // Otherwise, return a class that contains an interfering method. Klass* Dependencies::check_unique_concrete_method(InstanceKlass* ctxk, Method* uniqm, @@ -1957,7 +1957,7 @@ Klass* Dependencies::check_unique_concrete_method(InstanceKlass* ctxk, !resolved_method->method_holder()->is_linked() || resolved_method->can_be_statically_bound()) { // Dependency is redundant, but benign. Just keep it to avoid unnecessary recompilation. - return NULL; // no vtable index available + return nullptr; // no vtable index available } LinkedConcreteMethodFinder mf(InstanceKlass::cast(resolved_klass), resolved_method, uniqm); @@ -1971,9 +1971,9 @@ Klass* Dependencies::check_unique_concrete_method(InstanceKlass* ctxk, // Not yet linked subclasses of ctxk are ignored since they don't have any instances yet. // Additionally, resolved_klass and resolved_method complete the description of the call site being analyzed. Method* Dependencies::find_unique_concrete_method(InstanceKlass* ctxk, Method* m, Klass* resolved_klass, Method* resolved_method) { - // Return NULL if m is marked old; must have been a redefined method. + // Return nullptr if m is marked old; must have been a redefined method. if (m->is_old()) { - return NULL; + return nullptr; } if (!InstanceKlass::cast(resolved_klass)->is_linked() || !resolved_method->method_holder()->is_linked() || @@ -1984,48 +1984,48 @@ Method* Dependencies::find_unique_concrete_method(InstanceKlass* ctxk, Method* m assert(Dependencies::verify_method_context(ctxk, m), "proper context"); wf.record_witnesses(1); Klass* wit = wf.find_witness(ctxk); - if (wit != NULL) { - return NULL; // Too many witnesses. + if (wit != nullptr) { + return nullptr; // Too many witnesses. } - // p == NULL when no participants are found (wf.num_participants() == 0). - // fm == NULL case has 2 meanings: - // * when p == NULL: no method found; - // * when p != NULL: AbstractMethodError-throwing method found. + // p == nullptr when no participants are found (wf.num_participants() == 0). + // fm == nullptr case has 2 meanings: + // * when p == nullptr: no method found; + // * when p != nullptr: AbstractMethodError-throwing method found. // Also, found method should always be accompanied by a participant class. Klass* p = wf.participant(0); Method* fm = wf.found_method(0); - assert(fm == NULL || p != NULL, "no participant"); - // Normalize all error-throwing cases to NULL. + assert(fm == nullptr || p != nullptr, "no participant"); + // Normalize all error-throwing cases to nullptr. if (fm == Universe::throw_illegal_access_error() || fm == Universe::throw_no_such_method_error() || !Dependencies::is_concrete_method(fm, p)) { - fm = NULL; // error-throwing method + fm = nullptr; // error-throwing method } if (Dependencies::is_concrete_method(m, ctxk)) { - if (p == NULL) { + if (p == nullptr) { // It turns out that m was always the only implementation. - assert(fm == NULL, "sanity"); + assert(fm == nullptr, "sanity"); fm = m; } } #ifndef PRODUCT // Make sure the dependency mechanism will pass this discovery: - if (VerifyDependencies && fm != NULL) { - guarantee(NULL == check_unique_concrete_method(ctxk, fm, resolved_klass, resolved_method), + if (VerifyDependencies && fm != nullptr) { + guarantee(nullptr == check_unique_concrete_method(ctxk, fm, resolved_klass, resolved_method), "verify dep."); } #endif // PRODUCT - assert(fm == NULL || !fm->is_abstract(), "sanity"); + assert(fm == nullptr || !fm->is_abstract(), "sanity"); // Old CHA conservatively reports concrete methods in abstract classes // irrespective of whether they have concrete subclasses or not. // Also, abstract root method case is not fully supported. #ifdef ASSERT - Klass* uniqp = NULL; + Klass* uniqp = nullptr; Method* uniqm = Dependencies::find_unique_concrete_method(ctxk, m, &uniqp); - assert(uniqm == NULL || uniqm == fm || + assert(uniqm == nullptr || uniqm == fm || m->is_abstract() || uniqm->method_holder()->is_abstract() || - (fm == NULL && uniqm != NULL && uniqp != NULL && !InstanceKlass::cast(uniqp)->is_linked()), + (fm == nullptr && uniqm != nullptr && uniqp != nullptr && !InstanceKlass::cast(uniqp)->is_linked()), "sanity"); #endif // ASSERT return fm; @@ -2033,18 +2033,18 @@ Method* Dependencies::find_unique_concrete_method(InstanceKlass* ctxk, Method* m Klass* Dependencies::check_has_no_finalizable_subclasses(InstanceKlass* ctxk, NewKlassDepChange* changes) { InstanceKlass* search_at = ctxk; - if (changes != NULL) { + if (changes != nullptr) { search_at = changes->new_type(); // just look at the new bit } return find_finalizable_subclass(search_at); } Klass* Dependencies::check_call_site_target_value(oop call_site, oop method_handle, CallSiteDepChange* changes) { - assert(call_site != NULL, "sanity"); - assert(method_handle != NULL, "sanity"); + assert(call_site != nullptr, "sanity"); + assert(method_handle != nullptr, "sanity"); assert(call_site->is_a(vmClasses::CallSite_klass()), "sanity"); - if (changes == NULL) { + if (changes == nullptr) { // Validate all CallSites if (java_lang_invoke_CallSite::target(call_site) != method_handle) return call_site->klass(); // assertion failed @@ -2055,11 +2055,11 @@ Klass* Dependencies::check_call_site_target_value(oop call_site, oop method_hand return call_site->klass(); // assertion failed } } - return NULL; // assertion still valid + return nullptr; // assertion still valid } void Dependencies::DepStream::trace_and_log_witness(Klass* witness) { - if (witness != NULL) { + if (witness != nullptr) { if (TraceDependencies) { print_dependency(witness, /*verbose=*/ true); } @@ -2072,7 +2072,7 @@ Klass* Dependencies::DepStream::check_new_klass_dependency(NewKlassDepChange* ch assert_locked_or_safepoint(Compile_lock); Dependencies::check_valid_dependency_type(type()); - Klass* witness = NULL; + Klass* witness = nullptr; switch (type()) { case evol_method: witness = check_evol_method(method_argument(0)); @@ -2096,7 +2096,7 @@ Klass* Dependencies::DepStream::check_new_klass_dependency(NewKlassDepChange* ch witness = check_has_no_finalizable_subclasses(context_type(), changes); break; default: - witness = NULL; + witness = nullptr; break; } trace_and_log_witness(witness); @@ -2108,13 +2108,13 @@ Klass* Dependencies::DepStream::check_klass_init_dependency(KlassInitDepChange* Dependencies::check_valid_dependency_type(type()); // No new types added. Only unique_concrete_method_4 is sensitive to class initialization changes. - Klass* witness = NULL; + Klass* witness = nullptr; switch (type()) { case unique_concrete_method_4: witness = check_unique_concrete_method(context_type(), method_argument(1), type_argument(2), method_argument(3), changes); break; default: - witness = NULL; + witness = nullptr; break; } trace_and_log_witness(witness); @@ -2125,16 +2125,16 @@ Klass* Dependencies::DepStream::check_klass_dependency(KlassDepChange* changes) assert_locked_or_safepoint(Compile_lock); Dependencies::check_valid_dependency_type(type()); - if (changes != NULL) { + if (changes != nullptr) { if (UseVtableBasedCHA && changes->is_klass_init_change()) { return check_klass_init_dependency(changes->as_klass_init_change()); } else { return check_new_klass_dependency(changes->as_new_klass_change()); } } else { - Klass* witness = check_new_klass_dependency(NULL); + Klass* witness = check_new_klass_dependency(nullptr); // check_klass_init_dependency duplicates check_new_klass_dependency checks when class hierarchy change info is absent. - assert(witness != NULL || check_klass_init_dependency(NULL) == NULL, "missed dependency"); + assert(witness != nullptr || check_klass_init_dependency(nullptr) == nullptr, "missed dependency"); return witness; } } @@ -2143,13 +2143,13 @@ Klass* Dependencies::DepStream::check_call_site_dependency(CallSiteDepChange* ch assert_locked_or_safepoint(Compile_lock); Dependencies::check_valid_dependency_type(type()); - Klass* witness = NULL; + Klass* witness = nullptr; switch (type()) { case call_site_target_value: witness = check_call_site_target_value(argument_oop(0), argument_oop(1), changes); break; default: - witness = NULL; + witness = nullptr; break; } trace_and_log_witness(witness); @@ -2167,7 +2167,7 @@ Klass* Dependencies::DepStream::spot_check_dependency_at(DepChange& changes) { return check_call_site_dependency(changes.as_call_site_change()); // irrelevant dependency; skip it - return NULL; + return nullptr; } @@ -2203,10 +2203,10 @@ void DepChange::print() { } void DepChange::ContextStream::start() { - Klass* type = (_changes.is_klass_change() ? _changes.as_klass_change()->type() : (Klass*) NULL); - _change_type = (type == NULL ? NO_CHANGE : Start_Klass); + Klass* type = (_changes.is_klass_change() ? _changes.as_klass_change()->type() : (Klass*) nullptr); + _change_type = (type == nullptr ? NO_CHANGE : Start_Klass); _klass = type; - _ti_base = NULL; + _ti_base = nullptr; _ti_index = 0; _ti_limit = 0; } @@ -2225,12 +2225,12 @@ bool DepChange::ContextStream::next() { // 6598190: brackets workaround Sun Studio C++ compiler bug 6629277 { _klass = _klass->super(); - if (_klass != NULL) { + if (_klass != nullptr) { return true; } } // else set up _ti_limit and fall through: - _ti_limit = (_ti_base == NULL) ? 0 : _ti_base->length(); + _ti_limit = (_ti_base == nullptr) ? 0 : _ti_base->length(); _change_type = Change_new_impl; case Change_new_impl: if (_ti_index < _ti_limit) { @@ -2270,7 +2270,7 @@ KlassDepChange::~KlassDepChange() { } bool KlassDepChange::involves_context(Klass* k) { - if (k == NULL || !k->is_instance_klass()) { + if (k == nullptr || !k->is_instance_klass()) { return false; } InstanceKlass* ik = InstanceKlass::cast(k); @@ -2297,7 +2297,7 @@ void AbstractClassHierarchyWalker::print_statistics() { deps_find_witness_steps, (double)deps_find_witness_steps / deps_find_witness_calls, deps_find_witness_singles); - if (xtty != NULL) { + if (xtty != nullptr) { xtty->elem("deps_find_witness calls='" JLONG_FORMAT "' steps='" JLONG_FORMAT "' singles='" JLONG_FORMAT "'", deps_find_witness_calls, deps_find_witness_steps, diff --git a/src/hotspot/share/code/dependencies.hpp b/src/hotspot/share/code/dependencies.hpp index 43c3214a57a..c74ac522f81 100644 --- a/src/hotspot/share/code/dependencies.hpp +++ b/src/hotspot/share/code/dependencies.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -203,17 +203,17 @@ class Dependencies: public ResourceObj { public: DepValue() : _id(0) {} - DepValue(OopRecorder* rec, Metadata* metadata, DepValue* candidate = NULL) { - assert(candidate == NULL || candidate->is_metadata(), "oops"); - if (candidate != NULL && candidate->as_metadata(rec) == metadata) { + DepValue(OopRecorder* rec, Metadata* metadata, DepValue* candidate = nullptr) { + assert(candidate == nullptr || candidate->is_metadata(), "oops"); + if (candidate != nullptr && candidate->as_metadata(rec) == metadata) { _id = candidate->_id; } else { _id = rec->find_index(metadata) + 1; } } - DepValue(OopRecorder* rec, jobject obj, DepValue* candidate = NULL) { - assert(candidate == NULL || candidate->is_object(), "oops"); - if (candidate != NULL && candidate->as_object(rec) == obj) { + DepValue(OopRecorder* rec, jobject obj, DepValue* candidate = nullptr) { + assert(candidate == nullptr || candidate->is_object(), "oops"); + if (candidate != nullptr && candidate->as_object(rec) == obj) { _id = candidate->_id; } else { _id = -(rec->find_index(obj) + 1); @@ -233,13 +233,13 @@ class Dependencies: public ResourceObj { Metadata* as_metadata(OopRecorder* rec) const { assert(is_metadata(), "oops"); return rec->metadata_at(index()); } Klass* as_klass(OopRecorder* rec) const { Metadata* m = as_metadata(rec); - assert(m != NULL, "as_metadata returned NULL"); + assert(m != nullptr, "as_metadata returned nullptr"); assert(m->is_klass(), "oops"); return (Klass*) m; } Method* as_method(OopRecorder* rec) const { Metadata* m = as_metadata(rec); - assert(m != NULL, "as_metadata returned NULL"); + assert(m != nullptr, "as_metadata returned nullptr"); assert(m->is_method(), "oops"); return (Method*) m; } @@ -266,7 +266,7 @@ class Dependencies: public ResourceObj { bool note_dep_seen(int dept, ciBaseObject* x) { assert(dept < BitsPerInt, "oob"); int x_id = x->ident(); - assert(_dep_seen != NULL, "deps must be writable"); + assert(_dep_seen != nullptr, "deps must be writable"); int seen = _dep_seen->at_grow(x_id, 0); _dep_seen->at_put(x_id, seen | (1<at_grow(x_id, 0); _dep_seen->at_put(x_id, seen | (1<* ciargs = new GrowableArray(dep_args(dept)); - assert (x0 != NULL, "no log x0"); + assert (x0 != nullptr, "no log x0"); ciargs->push(x0); - if (x1 != NULL) { + if (x1 != nullptr) { ciargs->push(x1); } - if (x2 != NULL) { + if (x2 != nullptr) { ciargs->push(x2); } - if (x3 != NULL) { + if (x3 != nullptr) { ciargs->push(x3); } assert(ciargs->length() == dep_args(dept), ""); @@ -510,11 +510,11 @@ class Dependencies: public ResourceObj { bool _valid; void* _value; public: - DepArgument() : _is_oop(false), _valid(false), _value(NULL) {} + DepArgument() : _is_oop(false), _valid(false), _value(nullptr) {} DepArgument(oop v): _is_oop(true), _valid(true), _value(v) {} DepArgument(Metadata* v): _is_oop(false), _valid(true), _value(v) {} - bool is_null() const { return _value == NULL; } + bool is_null() const { return _value == nullptr; } bool is_oop() const { return _is_oop; } bool is_metadata() const { return !_is_oop; } bool is_klass() const { return is_metadata() && metadata_value()->is_klass(); } @@ -526,7 +526,7 @@ class Dependencies: public ResourceObj { static void print_dependency(DepType dept, GrowableArray* args, - Klass* witness = NULL, outputStream* st = tty); + Klass* witness = nullptr, outputStream* st = tty); private: // helper for encoding common context types as zero: @@ -537,15 +537,15 @@ class Dependencies: public ResourceObj { static void write_dependency_to(CompileLog* log, DepType dept, GrowableArray* args, - Klass* witness = NULL); + Klass* witness = nullptr); static void write_dependency_to(CompileLog* log, DepType dept, GrowableArray* args, - Klass* witness = NULL); + Klass* witness = nullptr); static void write_dependency_to(xmlStream* xtty, DepType dept, GrowableArray* args, - Klass* witness = NULL); + Klass* witness = nullptr); public: // Use this to iterate over an nmethod's dependency set. // Works on new and old dependency sets. @@ -585,7 +585,7 @@ class Dependencies: public ResourceObj { public: DepStream(Dependencies* deps) - : _code(NULL), + : _code(nullptr), _deps(deps), _bytes(deps->content_bytes()) { @@ -593,7 +593,7 @@ class Dependencies: public ResourceObj { } DepStream(nmethod* code) : _code(code), - _deps(NULL), + _deps(nullptr), _bytes(code->dependencies_begin()) { initial_asserts(code->dependencies_size()); @@ -627,9 +627,9 @@ class Dependencies: public ResourceObj { // The point of the whole exercise: Is this dep still OK? Klass* check_dependency() { - Klass* result = check_klass_dependency(NULL); - if (result != NULL) return result; - return check_call_site_dependency(NULL); + Klass* result = check_klass_dependency(nullptr); + if (result != nullptr) return result; + return check_call_site_dependency(nullptr); } // A lighter version: Checks only around recent changes in a class @@ -637,10 +637,10 @@ class Dependencies: public ResourceObj { Klass* spot_check_dependency_at(DepChange& changes); // Log the current dependency to xtty or compilation log. - void log_dependency(Klass* witness = NULL); + void log_dependency(Klass* witness = nullptr); // Print the current dependency to tty. - void print_dependency(Klass* witness = NULL, bool verbose = false, outputStream* st = tty); + void print_dependency(Klass* witness = nullptr, bool verbose = false, outputStream* st = tty); }; friend class Dependencies::DepStream; diff --git a/src/hotspot/share/code/dependencyContext.cpp b/src/hotspot/share/code/dependencyContext.cpp index 2526bd36d91..87dec8b6d77 100644 --- a/src/hotspot/share/code/dependencyContext.cpp +++ b/src/hotspot/share/code/dependencyContext.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,11 +33,11 @@ #include "runtime/perfData.hpp" #include "utilities/exceptions.hpp" -PerfCounter* DependencyContext::_perf_total_buckets_allocated_count = NULL; -PerfCounter* DependencyContext::_perf_total_buckets_deallocated_count = NULL; -PerfCounter* DependencyContext::_perf_total_buckets_stale_count = NULL; -PerfCounter* DependencyContext::_perf_total_buckets_stale_acc_count = NULL; -nmethodBucket* volatile DependencyContext::_purge_list = NULL; +PerfCounter* DependencyContext::_perf_total_buckets_allocated_count = nullptr; +PerfCounter* DependencyContext::_perf_total_buckets_deallocated_count = nullptr; +PerfCounter* DependencyContext::_perf_total_buckets_stale_count = nullptr; +PerfCounter* DependencyContext::_perf_total_buckets_stale_acc_count = nullptr; +nmethodBucket* volatile DependencyContext::_purge_list = nullptr; volatile uint64_t DependencyContext::_cleaning_epoch = 0; uint64_t DependencyContext::_cleaning_epoch_monotonic = 0; @@ -66,7 +66,7 @@ void DependencyContext::init() { // int DependencyContext::mark_dependent_nmethods(DepChange& changes) { int found = 0; - for (nmethodBucket* b = dependencies_not_unloading(); b != NULL; b = b->next_not_unloading()) { + for (nmethodBucket* b = dependencies_not_unloading(); b != nullptr; b = b->next_not_unloading()) { nmethod* nm = b->get_nmethod(); if (b->count() > 0) { if (nm->is_marked_for_deoptimization()) { @@ -97,13 +97,13 @@ int DependencyContext::mark_dependent_nmethods(DepChange& changes) { // void DependencyContext::add_dependent_nmethod(nmethod* nm) { assert_lock_strong(CodeCache_lock); - for (nmethodBucket* b = dependencies_not_unloading(); b != NULL; b = b->next_not_unloading()) { + for (nmethodBucket* b = dependencies_not_unloading(); b != nullptr; b = b->next_not_unloading()) { if (nm == b->get_nmethod()) { b->increment(); return; } } - nmethodBucket* new_head = new nmethodBucket(nm, NULL); + nmethodBucket* new_head = new nmethodBucket(nm, nullptr); for (;;) { nmethodBucket* head = Atomic::load(_dependency_context_addr); new_head->set_next(head); @@ -146,7 +146,7 @@ void DependencyContext::release(nmethodBucket* b) { // void DependencyContext::purge_dependency_contexts() { int removed = 0; - for (nmethodBucket* b = _purge_list; b != NULL;) { + for (nmethodBucket* b = _purge_list; b != nullptr;) { nmethodBucket* next = b->purge_list_next(); removed++; delete b; @@ -155,7 +155,7 @@ void DependencyContext::purge_dependency_contexts() { if (UsePerfData && removed > 0) { _perf_total_buckets_deallocated_count->inc(removed); } - _purge_list = NULL; + _purge_list = nullptr; } // @@ -169,7 +169,7 @@ void DependencyContext::clean_unloading_dependents() { // Walk the nmethodBuckets and move dead entries on the purge list, which will // be deleted during ClassLoaderDataGraph::purge(). nmethodBucket* b = dependencies_not_unloading(); - while (b != NULL) { + while (b != nullptr) { nmethodBucket* next = b->next_not_unloading(); b = next; } @@ -185,15 +185,15 @@ nmethodBucket* DependencyContext::release_and_get_next_not_unloading(nmethodBuck // Invalidate all dependencies in the context void DependencyContext::remove_all_dependents() { nmethodBucket* b = dependencies_not_unloading(); - set_dependencies(NULL); + set_dependencies(nullptr); assert(b == nullptr, "All dependents should be unloading"); } int DependencyContext::remove_and_mark_for_deoptimization_all_dependents() { nmethodBucket* b = dependencies_not_unloading(); - set_dependencies(NULL); + set_dependencies(nullptr); int marked = 0; - while (b != NULL) { + while (b != nullptr) { nmethod* nm = b->get_nmethod(); if (b->count() > 0) { // Also count already (concurrently) marked nmethods to make sure @@ -209,7 +209,7 @@ int DependencyContext::remove_and_mark_for_deoptimization_all_dependents() { #ifndef PRODUCT void DependencyContext::print_dependent_nmethods(bool verbose) { int idx = 0; - for (nmethodBucket* b = dependencies_not_unloading(); b != NULL; b = b->next_not_unloading()) { + for (nmethodBucket* b = dependencies_not_unloading(); b != nullptr; b = b->next_not_unloading()) { nmethod* nm = b->get_nmethod(); tty->print("[%d] count=%d { ", idx++, b->count()); if (!verbose) { @@ -225,7 +225,7 @@ void DependencyContext::print_dependent_nmethods(bool verbose) { #endif //PRODUCT bool DependencyContext::is_dependent_nmethod(nmethod* nm) { - for (nmethodBucket* b = dependencies_not_unloading(); b != NULL; b = b->next_not_unloading()) { + for (nmethodBucket* b = dependencies_not_unloading(); b != nullptr; b = b->next_not_unloading()) { if (nm == b->get_nmethod()) { #ifdef ASSERT int count = b->count(); @@ -260,7 +260,7 @@ nmethodBucket* DependencyContext::dependencies_not_unloading() { for (;;) { // Need acquire because the read value could come from a concurrent insert. nmethodBucket* head = Atomic::load_acquire(_dependency_context_addr); - if (head == NULL || !head->get_nmethod()->is_unloading()) { + if (head == nullptr || !head->get_nmethod()->is_unloading()) { return head; } nmethodBucket* head_next = head->next(); @@ -314,7 +314,7 @@ nmethodBucket* nmethodBucket::next_not_unloading() { // Do not need acquire because the loaded entry can never be // concurrently inserted. nmethodBucket* next = Atomic::load(&_next); - if (next == NULL || !next->get_nmethod()->is_unloading()) { + if (next == nullptr || !next->get_nmethod()->is_unloading()) { return next; } nmethodBucket* next_next = Atomic::load(&next->_next); diff --git a/src/hotspot/share/code/dependencyContext.hpp b/src/hotspot/share/code/dependencyContext.hpp index 9dcf28d796a..e9cb7824e01 100644 --- a/src/hotspot/share/code/dependencyContext.hpp +++ b/src/hotspot/share/code/dependencyContext.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ class nmethodBucket: public CHeapObj { public: nmethodBucket(nmethod* nmethod, nmethodBucket* next) : - _nmethod(nmethod), _count(1), _next(next), _purge_list_next(NULL) {} + _nmethod(nmethod), _count(1), _next(next), _purge_list_next(nullptr) {} int count() { return _count; } int increment() { _count += 1; return _count; } diff --git a/src/hotspot/share/code/exceptionHandlerTable.cpp b/src/hotspot/share/code/exceptionHandlerTable.cpp index 5299cfb1a54..8bcf5a43953 100644 --- a/src/hotspot/share/code/exceptionHandlerTable.cpp +++ b/src/hotspot/share/code/exceptionHandlerTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ HandlerTableEntry* ExceptionHandlerTable::subtable_for(int catch_pco) const { i += t->len() + 1; // +1 for header } } - return NULL; + return nullptr; } @@ -78,16 +78,16 @@ void ExceptionHandlerTable::add_subtable( GrowableArray* scope_depths_from_top_scope, GrowableArray* handler_pcos ) { - assert(subtable_for(catch_pco) == NULL, "catch handlers for this catch_pco added twice"); + assert(subtable_for(catch_pco) == nullptr, "catch handlers for this catch_pco added twice"); assert(handler_bcis->length() == handler_pcos->length(), "bci & pc table have different length"); - assert(scope_depths_from_top_scope == NULL || handler_bcis->length() == scope_depths_from_top_scope->length(), "bci & scope_depths table have different length"); + assert(scope_depths_from_top_scope == nullptr || handler_bcis->length() == scope_depths_from_top_scope->length(), "bci & scope_depths table have different length"); if (handler_bcis->length() > 0) { // add subtable header add_entry(HandlerTableEntry(handler_bcis->length(), catch_pco, 0)); // add individual entries for (int i = 0; i < handler_bcis->length(); i++) { intptr_t scope_depth = 0; - if (scope_depths_from_top_scope != NULL) { + if (scope_depths_from_top_scope != nullptr) { scope_depth = scope_depths_from_top_scope->at(i); } add_entry(HandlerTableEntry(handler_bcis->at(i), handler_pcos->at(i), scope_depth)); @@ -109,20 +109,20 @@ void ExceptionHandlerTable::copy_bytes_to(address addr) { HandlerTableEntry* ExceptionHandlerTable::entry_for(int catch_pco, int handler_bci, int scope_depth) const { HandlerTableEntry* t = subtable_for(catch_pco); - if (t != NULL) { + if (t != nullptr) { int l = t->len(); while (l-- > 0) { t++; if (t->bci() == handler_bci && t->scope_depth() == scope_depth) return t; } } - return NULL; + return nullptr; } void ExceptionHandlerTable::print_subtable(HandlerTableEntry* t, address base) const { int l = t->len(); - bool have_base_addr = (base != NULL); + bool have_base_addr = (base != nullptr); if (have_base_addr) { tty->print_cr("catch_pco = %d (pc=" INTPTR_FORMAT ", %d entries)", t->pco(), p2i(base + t->pco()), l); } else { @@ -154,7 +154,7 @@ void ExceptionHandlerTable::print(address base) const { void ExceptionHandlerTable::print_subtable_for(int catch_pco) const { HandlerTableEntry* subtable = subtable_for(catch_pco); - if( subtable != NULL ) { print_subtable( subtable ); } + if( subtable != nullptr ) { print_subtable( subtable ); } } // ---------------------------------------------------------------------------- @@ -218,7 +218,7 @@ void ImplicitExceptionTable::print(address base) const { ImplicitExceptionTable::ImplicitExceptionTable(const CompiledMethod* nm) { if (nm->nul_chk_table_size() == 0) { _len = 0; - _data = NULL; + _data = nullptr; } else { // the first word is the length if non-zero, so read it out and // skip to the next word to get the table. diff --git a/src/hotspot/share/code/exceptionHandlerTable.hpp b/src/hotspot/share/code/exceptionHandlerTable.hpp index d563e9492c5..d30d602b33c 100644 --- a/src/hotspot/share/code/exceptionHandlerTable.hpp +++ b/src/hotspot/share/code/exceptionHandlerTable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -123,8 +123,8 @@ class ExceptionHandlerTable { HandlerTableEntry* entry_for(int catch_pco, int handler_bci, int scope_depth) const; // debugging - void print_subtable(HandlerTableEntry* t, address base = NULL) const; - void print(address base = NULL) const; + void print_subtable(HandlerTableEntry* t, address base = nullptr) const; + void print(address base = nullptr) const; void print_subtable_for(int catch_pco) const; }; diff --git a/src/hotspot/share/code/icBuffer.cpp b/src/hotspot/share/code/icBuffer.cpp index 8db25297f01..f9a3d345a3f 100644 --- a/src/hotspot/share/code/icBuffer.cpp +++ b/src/hotspot/share/code/icBuffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,9 +42,9 @@ DEF_STUB_INTERFACE(ICStub); -StubQueue* InlineCacheBuffer::_buffer = NULL; +StubQueue* InlineCacheBuffer::_buffer = nullptr; -CompiledICHolder* InlineCacheBuffer::_pending_released = NULL; +CompiledICHolder* InlineCacheBuffer::_pending_released = nullptr; int InlineCacheBuffer::_pending_count = 0; #ifdef ASSERT @@ -53,30 +53,30 @@ ICRefillVerifier::ICRefillVerifier() _refill_remembered(false) { Thread* thread = Thread::current(); - assert(thread->missed_ic_stub_refill_verifier() == NULL, "nesting not supported"); + assert(thread->missed_ic_stub_refill_verifier() == nullptr, "nesting not supported"); thread->set_missed_ic_stub_refill_verifier(this); } ICRefillVerifier::~ICRefillVerifier() { assert(!_refill_requested || _refill_remembered, "Forgot to refill IC stubs after failed IC transition"); - Thread::current()->set_missed_ic_stub_refill_verifier(NULL); + Thread::current()->set_missed_ic_stub_refill_verifier(nullptr); } ICRefillVerifierMark::ICRefillVerifierMark(ICRefillVerifier* verifier) { Thread* thread = Thread::current(); - assert(thread->missed_ic_stub_refill_verifier() == NULL, "nesting not supported"); + assert(thread->missed_ic_stub_refill_verifier() == nullptr, "nesting not supported"); thread->set_missed_ic_stub_refill_verifier(verifier); } ICRefillVerifierMark::~ICRefillVerifierMark() { - Thread::current()->set_missed_ic_stub_refill_verifier(NULL); + Thread::current()->set_missed_ic_stub_refill_verifier(nullptr); } static ICRefillVerifier* current_ic_refill_verifier() { Thread* current = Thread::current(); ICRefillVerifier* verifier = current->missed_ic_stub_refill_verifier(); - assert(verifier != NULL, "need a verifier for safety"); + assert(verifier != nullptr, "need a verifier for safety"); return verifier; } #endif @@ -85,7 +85,7 @@ void ICStub::finalize() { if (!is_empty()) { ResourceMark rm; CompiledIC *ic = CompiledIC_at(CodeCache::find_compiled(ic_site()), ic_site()); - assert(CodeCache::find_compiled(ic->instruction_address()) != NULL, "inline cache in non-compiled?"); + assert(CodeCache::find_compiled(ic->instruction_address()) != nullptr, "inline cache in non-compiled?"); assert(this == ICStub_from_destination_address(ic->stub_address()), "wrong owner of ic buffer"); ic->set_ic_destination_and_value(destination(), cached_value()); @@ -119,7 +119,7 @@ void ICStub::clear() { if (CompiledIC::is_icholder_entry(destination())) { InlineCacheBuffer::queue_for_release((CompiledICHolder*)cached_value()); } - _ic_site = NULL; + _ic_site = nullptr; } @@ -139,9 +139,9 @@ void ICStub::print() { void InlineCacheBuffer::initialize() { - if (_buffer != NULL) return; // already initialized + if (_buffer != nullptr) return; // already initialized _buffer = new StubQueue(new ICStubInterface, 10*K, InlineCacheBuffer_lock, "InlineCacheBuffer"); - assert (_buffer != NULL, "cannot allocate InlineCacheBuffer"); + assert (_buffer != nullptr, "cannot allocate InlineCacheBuffer"); } @@ -196,7 +196,7 @@ bool InlineCacheBuffer::create_transition_stub(CompiledIC *ic, void* cached_valu // allocate and initialize new "out-of-line" inline-cache ICStub* ic_stub = new_ic_stub(); - if (ic_stub == NULL) { + if (ic_stub == nullptr) { #ifdef ASSERT ICRefillVerifier* verifier = current_ic_refill_verifier(); verifier->request_refill(); @@ -234,8 +234,8 @@ void* InlineCacheBuffer::cached_value_for(CompiledIC *ic) { void InlineCacheBuffer::release_pending_icholders() { assert(SafepointSynchronize::is_at_safepoint(), "should only be called during a safepoint"); CompiledICHolder* holder = _pending_released; - _pending_released = NULL; - while (holder != NULL) { + _pending_released = nullptr; + while (holder != nullptr) { CompiledICHolder* next = holder->next(); delete holder; holder = next; diff --git a/src/hotspot/share/code/icBuffer.hpp b/src/hotspot/share/code/icBuffer.hpp index c4425393a3d..135e11928f9 100644 --- a/src/hotspot/share/code/icBuffer.hpp +++ b/src/hotspot/share/code/icBuffer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ class ICStub: public Stub { protected: friend class ICStubInterface; // This will be called only by ICStubInterface - void initialize(int size) { _size = size; _ic_site = NULL; } + void initialize(int size) { _size = size; _ic_site = nullptr; } void finalize(); // called when a method is removed // General info @@ -77,7 +77,7 @@ class ICStub: public Stub { // Call site info address ic_site() const { return _ic_site; } void clear(); - bool is_empty() const { return _ic_site == NULL; } + bool is_empty() const { return _ic_site == nullptr; } // stub info address destination() const; // destination of jump instruction diff --git a/src/hotspot/share/code/nmethod.cpp b/src/hotspot/share/code/nmethod.cpp index 508764f42d7..d6d50199642 100644 --- a/src/hotspot/share/code/nmethod.cpp +++ b/src/hotspot/share/code/nmethod.cpp @@ -92,7 +92,7 @@ #define DTRACE_METHOD_UNLOAD_PROBE(method) \ { \ Method* m = (method); \ - if (m != NULL) { \ + if (m != nullptr) { \ Symbol* klass_name = m->klass_name(); \ Symbol* name = m->name(); \ Symbol* signature = m->signature(); \ @@ -268,27 +268,27 @@ static void note_java_nmethod(nmethod* nm) { ExceptionCache::ExceptionCache(Handle exception, address pc, address handler) { - assert(pc != NULL, "Must be non null"); + assert(pc != nullptr, "Must be non null"); assert(exception.not_null(), "Must be non null"); - assert(handler != NULL, "Must be non null"); + assert(handler != nullptr, "Must be non null"); _count = 0; _exception_type = exception->klass(); - _next = NULL; - _purge_list_next = NULL; + _next = nullptr; + _purge_list_next = nullptr; add_address_and_handler(pc,handler); } address ExceptionCache::match(Handle exception, address pc) { - assert(pc != NULL,"Must be non null"); + assert(pc != nullptr,"Must be non null"); assert(exception.not_null(),"Must be non null"); if (exception->klass() == exception_type()) { return (test_address(pc)); } - return NULL; + return nullptr; } @@ -308,7 +308,7 @@ address ExceptionCache::test_address(address addr) { return handler_at(i); } } - return NULL; + return nullptr; } @@ -346,8 +346,8 @@ static inline bool match_desc(PcDesc* pc, int pc_offset, bool approximate) { } void PcDescCache::reset_to(PcDesc* initial_pc_desc) { - if (initial_pc_desc == NULL) { - _pc_descs[0] = NULL; // native method; no PcDescs at all + if (initial_pc_desc == nullptr) { + _pc_descs[0] = nullptr; // native method; no PcDescs at all return; } NOT_PRODUCT(++pc_nmethod_stats.pc_desc_resets); @@ -373,7 +373,7 @@ PcDesc* PcDescCache::find_pc_desc(int pc_offset, bool approximate) { // Step one: Check the most recently added value. res = _pc_descs[0]; - if (res == NULL) return NULL; // native method; no PcDescs at all + if (res == nullptr) return nullptr; // native method; no PcDescs at all if (match_desc(res, pc_offset, approximate)) { NOT_PRODUCT(++pc_nmethod_stats.pc_desc_repeats); return res; @@ -390,7 +390,7 @@ PcDesc* PcDescCache::find_pc_desc(int pc_offset, bool approximate) { } // Report failure. - return NULL; + return nullptr; } void PcDescCache::add_pc_desc(PcDesc* pc_desc) { @@ -429,13 +429,13 @@ int nmethod::total_size() const { const char* nmethod::compile_kind() const { if (is_osr_method()) return "osr"; - if (method() != NULL && is_native_method()) { + if (method() != nullptr && is_native_method()) { if (method()->is_continuation_native_intrinsic()) { return "cnt"; } return "c2n"; } - return NULL; + return nullptr; } // Fill in default values for various flag fields @@ -444,8 +444,8 @@ void nmethod::init_defaults() { _has_flushed_dependencies = 0; _load_reported = false; // jvmti state - _oops_do_mark_link = NULL; - _osr_link = NULL; + _oops_do_mark_link = nullptr; + _osr_link = nullptr; #if INCLUDE_RTM_OPT _rtm_state = NoRTM; #endif @@ -499,7 +499,7 @@ nmethod* nmethod::new_native_nmethod(const methodHandle& method, int exception_handler) { code_buffer->finalize_oop_references(method); // create nmethod - nmethod* nm = NULL; + nmethod* nm = nullptr; int native_nmethod_size = CodeBlob::allocation_size(code_buffer, sizeof(nmethod)); { MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); @@ -522,10 +522,10 @@ nmethod* nmethod::new_native_nmethod(const methodHandle& method, basic_lock_sp_offset, oop_maps); DEBUG_ONLY( if (allow_NonNMethod_space) assert_no_oops_or_metadata(nm); ) - NOT_PRODUCT(if (nm != NULL) native_nmethod_stats.note_native_nmethod(nm)); + NOT_PRODUCT(if (nm != nullptr) native_nmethod_stats.note_native_nmethod(nm)); } - if (nm != NULL) { + if (nm != nullptr) { // verify nmethod debug_only(nm->verify();) // might block @@ -559,7 +559,7 @@ nmethod* nmethod::new_nmethod(const methodHandle& method, assert(debug_info->oop_recorder() == code_buffer->oop_recorder(), "shared OR"); code_buffer->finalize_oop_references(method); // create nmethod - nmethod* nm = NULL; + nmethod* nm = nullptr; #if INCLUDE_JVMCI int jvmci_data_size = !compiler->is_jvmci() ? 0 : JVMCINMethodData::compute_size(nmethod_mirror_name); #endif @@ -592,7 +592,7 @@ nmethod* nmethod::new_nmethod(const methodHandle& method, #endif ); - if (nm != NULL) { + if (nm != nullptr) { #if INCLUDE_JVMCI if (compiler->is_jvmci()) { // Initialize the JVMCINMethodData object inlined into nm @@ -614,18 +614,18 @@ nmethod* nmethod::new_nmethod(const methodHandle& method, MethodHandles::add_dependent_nmethod(call_site, nm); } else { Klass* klass = deps.context_type(); - if (klass == NULL) { + if (klass == nullptr) { continue; // ignore things like evol_method } // record this nmethod as dependent on this klass InstanceKlass::cast(klass)->add_dependent_nmethod(nm); } } - NOT_PRODUCT(if (nm != NULL) note_java_nmethod(nm)); + NOT_PRODUCT(if (nm != nullptr) note_java_nmethod(nm)); } } // Do verification and logging outside CodeCache_lock. - if (nm != NULL) { + if (nm != nullptr) { // Safepoints in nmethod::verify aren't allowed because nm hasn't been installed yet. DEBUG_ONLY(nm->verify();) nm->log_new_nmethod(); @@ -646,7 +646,7 @@ nmethod::nmethod( ByteSize basic_lock_sp_offset, OopMapSet* oop_maps ) : CompiledMethod(method, "native nmethod", type, nmethod_size, sizeof(nmethod), code_buffer, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false, true), - _unlinked_next(NULL), + _unlinked_next(nullptr), _native_receiver_sp_offset(basic_lock_owner_sp_offset), _native_basic_lock_sp_offset(basic_lock_sp_offset), _is_unloading_state(0) @@ -688,9 +688,9 @@ nmethod::nmethod( _compile_id = compile_id; _entry_point = code_begin() + offsets->value(CodeOffsets::Entry); _verified_entry_point = code_begin() + offsets->value(CodeOffsets::Verified_Entry); - _osr_entry_point = NULL; - _exception_cache = NULL; - _pc_desc_container.reset_to(NULL); + _osr_entry_point = nullptr; + _exception_cache = nullptr; + _pc_desc_container.reset_to(nullptr); _exception_offset = code_offset() + offsets->value(CodeOffsets::Exceptions); @@ -716,7 +716,7 @@ nmethod::nmethod( // This output goes directly to the tty, not the compiler log. // To enable tools to match it up with the compilation activity, // be sure to tag this tty output with the compile ID. - if (xtty != NULL) { + if (xtty != nullptr) { xtty->begin_head("print_native_nmethod"); xtty->method(_method); xtty->stamp(); @@ -730,7 +730,7 @@ nmethod::nmethod( tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); #if defined(SUPPORT_DATA_STRUCTS) if (AbstractDisassembler::show_structs()) { - if (oop_maps != NULL) { + if (oop_maps != nullptr) { tty->print("oop maps:"); // oop_maps->print_on(tty) outputs a cr() at the beginning oop_maps->print_on(tty); tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); @@ -748,7 +748,7 @@ nmethod::nmethod( } } #endif - if (xtty != NULL) { + if (xtty != nullptr) { xtty->tail("print_native_nmethod"); } } @@ -790,7 +790,7 @@ nmethod::nmethod( #endif ) : CompiledMethod(method, "nmethod", type, nmethod_size, sizeof(nmethod), code_buffer, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false, true), - _unlinked_next(NULL), + _unlinked_next(nullptr), _native_receiver_sp_offset(in_ByteSize(-1)), _native_basic_lock_sp_offset(in_ByteSize(-1)), _is_unloading_state(0) @@ -827,12 +827,12 @@ nmethod::nmethod( if (offsets->value(CodeOffsets::Deopt) != -1) { _deopt_handler_begin = (address) this + code_offset() + offsets->value(CodeOffsets::Deopt); } else { - _deopt_handler_begin = NULL; + _deopt_handler_begin = nullptr; } if (offsets->value(CodeOffsets::DeoptMH) != -1) { _deopt_mh_handler_begin = (address) this + code_offset() + offsets->value(CodeOffsets::DeoptMH); } else { - _deopt_mh_handler_begin = NULL; + _deopt_mh_handler_begin = nullptr; } } else #endif @@ -846,7 +846,7 @@ nmethod::nmethod( if (offsets->value(CodeOffsets::DeoptMH) != -1) { _deopt_mh_handler_begin = (address) this + _stub_offset + offsets->value(CodeOffsets::DeoptMH); } else { - _deopt_mh_handler_begin = NULL; + _deopt_mh_handler_begin = nullptr; } } if (offsets->value(CodeOffsets::UnwindHandler) != -1) { @@ -873,7 +873,7 @@ nmethod::nmethod( _entry_point = code_begin() + offsets->value(CodeOffsets::Entry); _verified_entry_point = code_begin() + offsets->value(CodeOffsets::Verified_Entry); _osr_entry_point = code_begin() + offsets->value(CodeOffsets::OSR_Entry); - _exception_cache = NULL; + _exception_cache = nullptr; _scopes_data_begin = (address) this + scopes_data_offset; _pc_desc_container.reset_to(scopes_pcs_begin()); @@ -916,15 +916,15 @@ nmethod::nmethod( void nmethod::log_identity(xmlStream* log) const { log->print(" compile_id='%d'", compile_id()); const char* nm_kind = compile_kind(); - if (nm_kind != NULL) log->print(" compile_kind='%s'", nm_kind); + if (nm_kind != nullptr) log->print(" compile_kind='%s'", nm_kind); log->print(" compiler='%s'", compiler_name()); if (TieredCompilation) { log->print(" level='%d'", comp_level()); } #if INCLUDE_JVMCI - if (jvmci_nmethod_data() != NULL) { + if (jvmci_nmethod_data() != nullptr) { const char* jvmci_name = jvmci_nmethod_data()->name(); - if (jvmci_name != NULL) { + if (jvmci_name != nullptr) { log->print(" jvmci_mirror_name='"); log->text("%s", jvmci_name); log->print("'"); @@ -941,7 +941,7 @@ void nmethod::log_identity(xmlStream* log) const { void nmethod::log_new_nmethod() const { - if (LogCompilation && xtty != NULL) { + if (LogCompilation && xtty != nullptr) { ttyLocker ttyl; xtty->begin_elem("nmethod"); log_identity(xtty); @@ -971,7 +971,7 @@ void nmethod::log_new_nmethod() const { // Print out more verbose output usually for a newly created nmethod. void nmethod::print_on(outputStream* st, const char* msg) const { - if (st != NULL) { + if (st != nullptr) { ttyLocker ttyl; if (WizardMode) { CompileTask::print(st, this, msg, /*short_form:*/ true); @@ -991,7 +991,7 @@ void nmethod::maybe_print_nmethod(const DirectiveSet* directive) { void nmethod::print_nmethod(bool printmethod) { ttyLocker ttyl; // keep the following output all in one block - if (xtty != NULL) { + if (xtty != nullptr) { xtty->begin_head("print_nmethod"); log_identity(xtty); xtty->stamp(); @@ -1021,7 +1021,7 @@ void nmethod::print_nmethod(bool printmethod) { tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); print_pcs(); tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); - if (oop_maps() != NULL) { + if (oop_maps() != nullptr) { tty->print("oop maps:"); // oop_maps()->print_on(tty) outputs a cr() at the beginning oop_maps()->print_on(tty); tty->print_cr("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); @@ -1063,7 +1063,7 @@ void nmethod::print_nmethod(bool printmethod) { } #endif - if (xtty != NULL) { + if (xtty != nullptr) { xtty->tail("print_nmethod"); } } @@ -1071,7 +1071,7 @@ void nmethod::print_nmethod(bool printmethod) { // Promote one word from an assembly-time handle to a live embedded oop. inline void nmethod::initialize_immediate_oop(oop* dest, jobject handle) { - if (handle == NULL || + if (handle == nullptr || // As a special case, IC oops are initialized to 1 or -1. handle == (jobject) Universe::non_oop_word()) { *(void**)dest = handle; @@ -1095,7 +1095,7 @@ void nmethod::copy_values(GrowableArray* array) { // The code and relocations have already been initialized by the // CodeBlob constructor, so it is valid even at this early point to // iterate over relocations and patch the code. - fix_oop_relocations(NULL, NULL, /*initialize_immediates=*/ true); + fix_oop_relocations(nullptr, nullptr, /*initialize_immediates=*/ true); } void nmethod::copy_values(GrowableArray* array) { @@ -1163,7 +1163,7 @@ void nmethod::make_deoptimized() { return; } - assert(method() == NULL || can_be_deoptimized(), ""); + assert(method() == nullptr || can_be_deoptimized(), ""); CompiledICLocker ml(this); assert(CompiledICLocker::is_safe(this), "mt unsafe call"); @@ -1178,7 +1178,7 @@ void nmethod::make_deoptimized() { CompiledIC *ic = CompiledIC_at(&iter); address pc = ic->end_of_call(); NativePostCallNop* nop = nativePostCallNop_at(pc); - if (nop != NULL) { + if (nop != nullptr) { nop->make_deopt(); } assert(NativeDeoptInstruction::is_deopt_at(pc), "check"); @@ -1189,7 +1189,7 @@ void nmethod::make_deoptimized() { address pc = csc->end_of_call(); NativePostCallNop* nop = nativePostCallNop_at(pc); //tty->print_cr(" - static pc %p", pc); - if (nop != NULL) { + if (nop != nullptr) { nop->make_deopt(); } // We can't assert here, there are some calls to stubs / runtime @@ -1216,9 +1216,9 @@ void nmethod::verify_clean_inline_caches() { case relocInfo::opt_virtual_call_type: { CompiledIC *ic = CompiledIC_at(&iter); CodeBlob *cb = CodeCache::find_blob(ic->ic_destination()); - assert(cb != NULL, "destination not in CodeBlob?"); + assert(cb != nullptr, "destination not in CodeBlob?"); nmethod* nm = cb->as_nmethod_or_null(); - if( nm != NULL ) { + if( nm != nullptr ) { // Verify that inline caches pointing to bad nmethods are clean if (!nm->is_in_use() || (nm->method()->code() != nm)) { assert(ic->is_clean(), "IC should be clean"); @@ -1229,9 +1229,9 @@ void nmethod::verify_clean_inline_caches() { case relocInfo::static_call_type: { CompiledStaticCall *csc = compiledStaticCall_at(iter.reloc()); CodeBlob *cb = CodeCache::find_blob(csc->destination()); - assert(cb != NULL, "destination not in CodeBlob?"); + assert(cb != nullptr, "destination not in CodeBlob?"); nmethod* nm = cb->as_nmethod_or_null(); - if( nm != NULL ) { + if( nm != nullptr ) { // Verify that inline caches pointing to bad nmethods are clean if (!nm->is_in_use() || (nm->method()->code() != nm)) { assert(csc->is_clean(), "IC should be clean"); @@ -1259,9 +1259,9 @@ void nmethod::inc_decompile_count() { if (!is_compiled_by_c2() && !is_compiled_by_jvmci()) return; // Could be gated by ProfileTraps, but do not bother... Method* m = method(); - if (m == NULL) return; + if (m == nullptr) return; MethodData* mdo = m->method_data(); - if (mdo == NULL) return; + if (mdo == nullptr) return; // There is a benign race here. See comments in methodData.hpp. mdo->inc_decompile_count(); } @@ -1281,14 +1281,14 @@ bool nmethod::try_transition(int new_state_int) { void nmethod::invalidate_osr_method() { assert(_entry_bci != InvocationEntryBci, "wrong kind of nmethod"); // Remove from list of active nmethods - if (method() != NULL) { + if (method() != nullptr) { method()->method_holder()->remove_osr_nmethod(this); } } void nmethod::log_state_change() const { if (LogCompilation) { - if (xtty != NULL) { + if (xtty != nullptr) { ttyLocker ttyl; // keep the following output all in one block xtty->begin_elem("make_not_entrant thread='" UINTX_FORMAT "'", os::current_thread_id()); @@ -1305,7 +1305,7 @@ void nmethod::log_state_change() const { } void nmethod::unlink_from_method() { - if (method() != NULL) { + if (method() != nullptr) { method()->unlink_code(this); } } @@ -1331,7 +1331,7 @@ bool nmethod::make_not_entrant() { { // Enter critical section. Does not block for safepoint. - MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock, Mutex::_no_safepoint_check_flag); + MutexLocker ml(CompiledMethod_lock->owned_by_self() ? nullptr : CompiledMethod_lock, Mutex::_no_safepoint_check_flag); if (Atomic::load(&_state) == not_entrant) { // another thread already performed this transition so nothing @@ -1379,13 +1379,13 @@ bool nmethod::make_not_entrant() { #if INCLUDE_JVMCI // Invalidate can't occur while holding the Patching lock JVMCINMethodData* nmethod_data = jvmci_nmethod_data(); - if (nmethod_data != NULL) { + if (nmethod_data != nullptr) { nmethod_data->invalidate_nmethod_mirror(this); } #endif #ifdef ASSERT - if (is_osr_method() && method() != NULL) { + if (is_osr_method() && method() != nullptr) { // Make sure osr nmethod is invalidated, i.e. not on the list bool found = method()->method_holder()->remove_osr_nmethod(this); assert(!found, "osr nmethod should have been invalidated"); @@ -1397,7 +1397,7 @@ bool nmethod::make_not_entrant() { // For concurrent GCs, there must be a handshake between unlink and flush void nmethod::unlink() { - if (_unlinked_next != NULL) { + if (_unlinked_next != nullptr) { // Already unlinked. It can be invoked twice because concurrent code cache // unloading might need to restart when inline cache cleaning fails due to // running out of ICStubs, which can only be refilled at safepoints @@ -1420,7 +1420,7 @@ void nmethod::unlink() { #if INCLUDE_JVMCI // Clear the link between this nmethod and a HotSpotNmethod mirror JVMCINMethodData* nmethod_data = jvmci_nmethod_data(); - if (nmethod_data != NULL) { + if (nmethod_data != nullptr) { nmethod_data->invalidate_nmethod_mirror(this); } #endif @@ -1448,7 +1448,7 @@ void nmethod::flush() { // Note that we do not need to grab the nmethod lock for this, it // better be thread safe if we're disposing of it! ExceptionCache* ec = exception_cache(); - while(ec != NULL) { + while(ec != nullptr) { ExceptionCache* next = ec->next(); delete ec; ec = next; @@ -1463,14 +1463,14 @@ void nmethod::flush() { oop nmethod::oop_at(int index) const { if (index == 0) { - return NULL; + return nullptr; } return NMethodAccess::oop_load(oop_addr_at(index)); } oop nmethod::oop_at_phantom(int index) const { if (index == 0) { - return NULL; + return nullptr; } return NMethodAccess::oop_load(oop_addr_at(index)); } @@ -1489,7 +1489,7 @@ void nmethod::flush_dependencies() { MethodHandles::clean_dependency_context(call_site); } else { Klass* klass = deps.context_type(); - if (klass == NULL) { + if (klass == nullptr) { continue; // ignore things like evol_method } // During GC liveness of dependee determines class that needs to be updated. @@ -1509,7 +1509,7 @@ void nmethod::post_compiled_method(CompileTask* task) { // JVMTI -- compiled method notification (must be done outside lock) post_compiled_method_load_event(); - if (CompilationLog::log() != NULL) { + if (CompilationLog::log() != nullptr) { CompilationLog::log()->log_nmethod(JavaThread::current(), this); } @@ -1543,7 +1543,7 @@ void nmethod::post_compiled_method_load_event(JvmtiThreadState* state) { // If a JavaThread hasn't been passed in, let the Service thread // (which is a real Java thread) post the event JvmtiDeferredEvent event = JvmtiDeferredEvent::compiled_method_load_event(this); - if (state == NULL) { + if (state == nullptr) { // Execute any barrier code for this nmethod as if it's called, since // keeping it alive looks like stack walking. run_nmethod_entry_barrier(); @@ -1556,7 +1556,7 @@ void nmethod::post_compiled_method_load_event(JvmtiThreadState* state) { } void nmethod::post_compiled_method_unload() { - assert(_method != NULL, "just checking"); + assert(_method != nullptr, "just checking"); DTRACE_METHOD_UNLOAD_PROBE(method()); // If a JVMTI agent has enabled the CompiledMethodUnload event then @@ -1585,7 +1585,7 @@ void nmethod::metadata_do(MetadataClosure* f) { assert(1 == (r->metadata_is_immediate()) + (r->metadata_addr() >= metadata_begin() && r->metadata_addr() < metadata_end()), "metadata must be found in exactly one place"); - if (r->metadata_is_immediate() && r->metadata_value() != NULL) { + if (r->metadata_is_immediate() && r->metadata_value() != nullptr) { Metadata* md = r->metadata_value(); if (md != _method) f->do_metadata(md); } @@ -1599,7 +1599,7 @@ void nmethod::metadata_do(MetadataClosure* f) { f->do_metadata(cichk->holder_klass()); } else { Metadata* ic_oop = ic->cached_metadata(); - if (ic_oop != NULL) { + if (ic_oop != nullptr) { f->do_metadata(ic_oop); } } @@ -1609,13 +1609,13 @@ void nmethod::metadata_do(MetadataClosure* f) { // Visit the metadata section for (Metadata** p = metadata_begin(); p < metadata_end(); p++) { - if (*p == Universe::non_oop_word() || *p == NULL) continue; // skip non-oops + if (*p == Universe::non_oop_word() || *p == nullptr) continue; // skip non-oops Metadata* md = *p; f->do_metadata(md); } // Visit metadata not embedded in the other places. - if (_method != NULL) f->do_metadata(_method); + if (_method != nullptr) f->do_metadata(_method); } // Heuristic for nuking nmethods even though their oops are live. @@ -1742,7 +1742,7 @@ void nmethod::do_unloading(bool unloading_occurred) { guarantee(unload_nmethod_caches(unloading_occurred), "Should not need transition stubs"); BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod(); - if (bs_nm != NULL) { + if (bs_nm != nullptr) { bs_nm->disarm(this); } } @@ -1761,7 +1761,7 @@ void nmethod::oops_do(OopClosure* f, bool allow_dead) { assert(1 == (r->oop_is_immediate()) + (r->oop_addr() >= oops_begin() && r->oop_addr() < oops_end()), "oop must be found in exactly one place"); - if (r->oop_is_immediate() && r->oop_value() != NULL) { + if (r->oop_is_immediate() && r->oop_value() != nullptr) { f->do_oop(r->oop_addr()); } } @@ -1803,7 +1803,7 @@ void nmethod::oops_do_log_change(const char* state) { bool nmethod::oops_do_try_claim() { if (oops_do_try_claim_weak_request()) { nmethod* result = oops_do_try_add_to_list_as_weak_done(); - assert(result == NULL, "adding to global list as weak done must always succeed."); + assert(result == nullptr, "adding to global list as weak done must always succeed."); return true; } return false; @@ -1812,7 +1812,7 @@ bool nmethod::oops_do_try_claim() { bool nmethod::oops_do_try_claim_weak_request() { assert(SafepointSynchronize::is_at_safepoint(), "only at safepoint"); - if ((_oops_do_mark_link == NULL) && + if ((_oops_do_mark_link == nullptr) && (Atomic::replace_if_null(&_oops_do_mark_link, mark_link(this, claim_weak_request_tag)))) { oops_do_log_change("oops_do, mark weak request"); return true; @@ -1827,8 +1827,8 @@ void nmethod::oops_do_set_strong_done(nmethod* old_head) { nmethod::oops_do_mark_link* nmethod::oops_do_try_claim_strong_done() { assert(SafepointSynchronize::is_at_safepoint(), "only at safepoint"); - oops_do_mark_link* old_next = Atomic::cmpxchg(&_oops_do_mark_link, mark_link(NULL, claim_weak_request_tag), mark_link(this, claim_strong_done_tag)); - if (old_next == NULL) { + oops_do_mark_link* old_next = Atomic::cmpxchg(&_oops_do_mark_link, mark_link(nullptr, claim_weak_request_tag), mark_link(this, claim_strong_done_tag)); + if (old_next == nullptr) { oops_do_log_change("oops_do, mark strong done"); } return old_next; @@ -1866,13 +1866,13 @@ nmethod* nmethod::oops_do_try_add_to_list_as_weak_done() { nmethod* old_head = Atomic::xchg(&_oops_do_mark_nmethods, this); // Self-loop if needed. - if (old_head == NULL) { + if (old_head == nullptr) { old_head = this; } // Try to install end of list and weak done tag. if (Atomic::cmpxchg(&_oops_do_mark_link, mark_link(this, claim_weak_request_tag), mark_link(old_head, claim_weak_done_tag)) == mark_link(this, claim_weak_request_tag)) { oops_do_log_change("oops_do, mark weak done"); - return NULL; + return nullptr; } else { return old_head; } @@ -1883,7 +1883,7 @@ void nmethod::oops_do_add_to_list_as_strong_done() { nmethod* old_head = Atomic::xchg(&_oops_do_mark_nmethods, this); // Self-loop if needed. - if (old_head == NULL) { + if (old_head == nullptr) { old_head = this; } assert(_oops_do_mark_link == mark_link(this, claim_strong_done_tag), "must be but is nmethod " PTR_FORMAT " state %u", @@ -1902,7 +1902,7 @@ void nmethod::oops_do_process_weak(OopsDoProcessor* p) { p->do_regular_processing(this); nmethod* old_head = oops_do_try_add_to_list_as_weak_done(); - if (old_head == NULL) { + if (old_head == nullptr) { return; } oops_do_log_change("oops_do, mark weak done fail"); @@ -1919,7 +1919,7 @@ void nmethod::oops_do_process_weak(OopsDoProcessor* p) { void nmethod::oops_do_process_strong(OopsDoProcessor* p) { oops_do_mark_link* next_raw = oops_do_try_claim_strong_done(); - if (next_raw == NULL) { + if (next_raw == nullptr) { p->do_regular_processing(this); oops_do_add_to_list_as_strong_done(); return; @@ -1952,20 +1952,20 @@ void nmethod::oops_do_marking_prologue() { assert_at_safepoint(); log_trace(gc, nmethod)("oops_do_marking_prologue"); - assert(_oops_do_mark_nmethods == NULL, "must be empty"); + assert(_oops_do_mark_nmethods == nullptr, "must be empty"); } void nmethod::oops_do_marking_epilogue() { assert_at_safepoint(); nmethod* next = _oops_do_mark_nmethods; - _oops_do_mark_nmethods = NULL; - if (next != NULL) { + _oops_do_mark_nmethods = nullptr; + if (next != nullptr) { nmethod* cur; do { cur = next; next = extract_nmethod(cur->_oops_do_mark_link); - cur->_oops_do_mark_link = NULL; + cur->_oops_do_mark_link = nullptr; DEBUG_ONLY(cur->verify_oop_relocations()); LogTarget(Trace, gc, nmethod) lt; @@ -2008,7 +2008,7 @@ void nmethod::copy_scopes_pcs(PcDesc* pcs, int count) { break; } } - assert(has_method_handle_invokes() == (_deopt_mh_handler_begin != NULL), "must have deopt mh handler"); + assert(has_method_handle_invokes() == (_deopt_mh_handler_begin != nullptr), "must have deopt mh handler"); int size = count * sizeof(PcDesc); assert(scopes_pcs_size() >= size, "oob"); @@ -2039,11 +2039,11 @@ static PcDesc* linear_search(const PcDescSearch& search, int pc_offset, bool app PcDesc* lower = search.scopes_pcs_begin(); PcDesc* upper = search.scopes_pcs_end(); lower += 1; // exclude initial sentinel - PcDesc* res = NULL; + PcDesc* res = nullptr; for (PcDesc* p = lower; p < upper; p++) { NOT_PRODUCT(--pc_nmethod_stats.pc_desc_tests); // don't count this call to match_desc if (match_desc(p, pc_offset, approximate)) { - if (res == NULL) + if (res == nullptr) res = p; else res = (PcDesc*) badAddress; @@ -2059,14 +2059,14 @@ PcDesc* PcDescContainer::find_pc_desc_internal(address pc, bool approximate, con address base_address = search.code_begin(); if ((pc < base_address) || (pc - base_address) >= (ptrdiff_t) PcDesc::upper_offset_limit) { - return NULL; // PC is wildly out of range + return nullptr; // PC is wildly out of range } int pc_offset = (int) (pc - base_address); // Check the PcDesc cache if it contains the desired PcDesc // (This as an almost 100% hit rate.) PcDesc* res = _pc_desc_cache.find_pc_desc(pc_offset, approximate); - if (res != NULL) { + if (res != nullptr) { assert(res == linear_search(search, pc_offset, approximate), "cache ok"); return res; } @@ -2078,7 +2078,7 @@ PcDesc* PcDescContainer::find_pc_desc_internal(address pc, bool approximate, con PcDesc* lower = search.scopes_pcs_begin(); PcDesc* upper = search.scopes_pcs_end(); upper -= 1; // exclude final sentinel - if (lower >= upper) return NULL; // native method; no PcDescs at all + if (lower >= upper) return nullptr; // native method; no PcDescs at all #define assert_LU_OK \ /* invariant on lower..upper during the following search: */ \ @@ -2131,8 +2131,8 @@ PcDesc* PcDescContainer::find_pc_desc_internal(address pc, bool approximate, con _pc_desc_cache.add_pc_desc(upper); return upper; } else { - assert(NULL == linear_search(search, pc_offset, approximate), "search ok"); - return NULL; + assert(nullptr == linear_search(search, pc_offset, approximate), "search ok"); + return nullptr; } } @@ -2165,7 +2165,7 @@ void nmethod::check_all_dependencies(DepChange& changes) { // Determine if dependency is already checked. table->put(...) returns // 'true' if the dependency is added (i.e., was not in the hashtable). if (table->put(*current_sig, 1)) { - if (deps.check_dependency() != NULL) { + if (deps.check_dependency() != nullptr) { // Dependency checking failed. Print out information about the failed // dependency and finally fail with an assert. We can fail here, since // dependency checking is never done in a product build. @@ -2188,7 +2188,7 @@ bool nmethod::check_dependency_on(DepChange& changes) { bool found_check = false; // set true if we are upset for (Dependencies::DepStream deps(this); deps.next(); ) { // Evaluate only relevant dependencies. - if (deps.spot_check_dependency_at(changes) != NULL) { + if (deps.spot_check_dependency_at(changes) != nullptr) { found_check = true; NOT_DEBUG(break); } @@ -2284,7 +2284,7 @@ void nmethod::verify() { for (uint i = 0; i < implicit_table.len(); i++) { int exec_offset = (int) implicit_table.get_exec_offset(i); if (implicit_table.get_exec_offset(i) == implicit_table.get_cont_offset(i)) { - assert(pc_desc_at(code_begin() + exec_offset) != NULL, "missing PcDesc"); + assert(pc_desc_at(code_begin() + exec_offset) != nullptr, "missing PcDesc"); bool found = false; for (int i = 0, imax = oms->count(); i < imax; i++) { if (oms->pair_at(i)->pc_offset() == exec_offset) { @@ -2304,7 +2304,7 @@ void nmethod::verify() { assert(voc.ok(), "embedded oops must be OK"); Universe::heap()->verify_nmethod(this); - assert(_oops_do_mark_link == NULL, "_oops_do_mark_link for %s should be NULL but is " PTR_FORMAT, + assert(_oops_do_mark_link == nullptr, "_oops_do_mark_link for %s should be nullptr but is " PTR_FORMAT, nm->method()->external_name(), p2i(_oops_do_mark_link)); verify_scopes(); @@ -2329,7 +2329,7 @@ void nmethod::verify_interrupt_point(address call_site) { HandleMark hm(Thread::current()); PcDesc* pd = pc_desc_at(nativeCall_at(call_site)->return_address()); - assert(pd != NULL, "PcDesc must exist"); + assert(pd != nullptr, "PcDesc must exist"); for (ScopeDesc* sd = new ScopeDesc(this, pd); !sd->is_top(); sd = sd->sender()) { sd->verify(); @@ -2343,7 +2343,7 @@ void nmethod::verify_scopes() { // and verify the debug information is valid. RelocIterator iter((nmethod*)this); while (iter.next()) { - address stub = NULL; + address stub = nullptr; switch (iter.type()) { case relocInfo::virtual_call_type: verify_interrupt_point(iter.addr()); @@ -2367,7 +2367,7 @@ void nmethod::verify_scopes() { default: break; } - assert(stub == NULL || stub_contains(stub), "static call stub outside stub section"); + assert(stub == nullptr || stub_contains(stub), "static call stub outside stub section"); } } @@ -2395,7 +2395,7 @@ void nmethod::print(outputStream* st) const { st->print("(n/a) "); } - print_on(st, NULL); + print_on(st, nullptr); if (WizardMode) { st->print("((nmethod*) " INTPTR_FORMAT ") ", p2i(this)); @@ -2480,7 +2480,7 @@ void nmethod::print_dependencies() { for (Dependencies::DepStream deps(this); deps.next(); ) { deps.print_dependency(); Klass* ctxk = deps.context_type(); - if (ctxk != NULL) { + if (ctxk != nullptr) { if (ctxk->is_instance_klass() && InstanceKlass::cast(ctxk)->is_dependent_nmethod(this)) { tty->print_cr(" [nmethod<=klass]%s", ctxk->external_name()); } @@ -2505,8 +2505,8 @@ void nmethod::print_oops(outputStream* st) { st->print_cr("NON_OOP"); continue; // skip non-oops } - if (*p == NULL) { - st->print_cr("NULL-oop"); + if (*p == nullptr) { + st->print_cr("nullptr-oop"); continue; // skip non-oops } (*p)->print_value_on(st); @@ -2548,7 +2548,7 @@ void nmethod::print_scopes_on(outputStream* st) { continue; ScopeDesc* sd = scope_desc_at(p->real_pc(this)); - while (sd != NULL) { + while (sd != nullptr) { sd->print_on(st, p); // print output ends with a newline sd = sd->sender(); } @@ -2593,7 +2593,7 @@ void nmethod::print_recorded_oop(int log_n, int i) { void* value; if (i == 0) { - value = NULL; + value = nullptr; } else { // Be careful around non-oop words. Don't create an oop // with that value, or it will assert in verification code. @@ -2610,7 +2610,7 @@ void nmethod::print_recorded_oop(int log_n, int i) { tty->print("non-oop word"); } else { if (value == 0) { - tty->print("NULL-oop"); + tty->print("nullptr-oop"); } else { oop_at(i)->print_value_on(tty); } @@ -2644,8 +2644,8 @@ void nmethod::print_recorded_metadata() { tty->print("#%*d: " INTPTR_FORMAT " ", log_n, i, p2i(m)); if (m == (Metadata*)Universe::non_oop_word()) { tty->print("non-metadata word"); - } else if (m == NULL) { - tty->print("NULL-oop"); + } else if (m == nullptr) { + tty->print("nullptr-oop"); } else { Metadata::print_value_on_maybe_null(tty, m); } @@ -2774,7 +2774,7 @@ void nmethod::decode2(outputStream* ost) const { unsigned char* end = this->code_end(); unsigned char* pss = p; // start of a code section (used for offsets) - if ((start == NULL) || (end == NULL)) { + if ((start == nullptr) || (end == nullptr)) { st->print_cr("PrintAssembly not possible due to uninitialized section pointers"); return; } @@ -2787,11 +2787,11 @@ void nmethod::decode2(outputStream* ost) const { //---< Open the output (Marker for post-mortem disassembler) >--- st->print_cr("[MachCode]"); - const char* header = NULL; + const char* header = nullptr; address p0 = p; while (p < end) { address pp = p; - while ((p < end) && (header == NULL)) { + while ((p < end) && (header == nullptr)) { header = nmethod_section_label(p); pp = p; p += Assembler::instr_len(p); @@ -2800,11 +2800,11 @@ void nmethod::decode2(outputStream* ost) const { AbstractDisassembler::decode_range_abstract(p0, pp, start, end, st, Assembler::instr_maxlen()); p0 = pp; p = pp; - header = NULL; - } else if (header != NULL) { + header = nullptr; + } else if (header != nullptr) { st->bol(); st->print_cr("%s", header); - header = NULL; + header = nullptr; } } //---< Close the output (Marker for post-mortem disassembler) >--- @@ -2821,7 +2821,7 @@ void nmethod::decode2(outputStream* ost) const { //---< Open the output (Marker for post-mortem disassembler) >--- st->print_cr("[MachCode]"); - while ((p < end) && (p != NULL)) { + while ((p < end) && (p != nullptr)) { const int instruction_size_in_bytes = Assembler::instr_len(p); //---< Block comments for nmethod. Interrupts instruction stream, if any. >--- @@ -2901,7 +2901,7 @@ const char* nmethod::reloc_string_for(u_char* begin, u_char* end) { oop_Relocation* r = iter.oop_reloc(); oop obj = r->oop_value(); st.print("oop("); - if (obj == NULL) st.print("NULL"); + if (obj == nullptr) st.print("nullptr"); else obj->print_value_on(&st); st.print(")"); return st.as_string(); @@ -2911,7 +2911,7 @@ const char* nmethod::reloc_string_for(u_char* begin, u_char* end) { metadata_Relocation* r = iter.metadata_reloc(); Metadata* obj = r->metadata_value(); st.print("metadata("); - if (obj == NULL) st.print("NULL"); + if (obj == nullptr) st.print("nullptr"); else obj->print_value_on(&st); st.print(")"); return st.as_string(); @@ -2923,7 +2923,7 @@ const char* nmethod::reloc_string_for(u_char* begin, u_char* end) { CallRelocation* r = (CallRelocation*)iter.reloc(); address dest = r->destination(); CodeBlob* cb = CodeCache::find_blob(dest); - if (cb != NULL) { + if (cb != nullptr) { st.print(" %s", cb->name()); } else { ResourceMark rm; @@ -2944,7 +2944,7 @@ const char* nmethod::reloc_string_for(u_char* begin, u_char* end) { st.print_raw("virtual_call"); virtual_call_Relocation* r = iter.virtual_call_reloc(); Method* m = r->method_value(); - if (m != NULL) { + if (m != nullptr) { assert(m->is_method(), ""); m->print_short_name(&st); } @@ -2955,7 +2955,7 @@ const char* nmethod::reloc_string_for(u_char* begin, u_char* end) { st.print_raw("optimized virtual_call"); opt_virtual_call_Relocation* r = iter.opt_virtual_call_reloc(); Method* m = r->method_value(); - if (m != NULL) { + if (m != nullptr) { assert(m->is_method(), ""); m->print_short_name(&st); } @@ -2966,7 +2966,7 @@ const char* nmethod::reloc_string_for(u_char* begin, u_char* end) { st.print_raw("static_call"); static_call_Relocation* r = iter.static_call_reloc(); Method* m = r->method_value(); - if (m != NULL) { + if (m != nullptr) { assert(m->is_method(), ""); m->print_short_name(&st); } @@ -2985,20 +2985,20 @@ const char* nmethod::reloc_string_for(u_char* begin, u_char* end) { break; } } - return have_one ? "other" : NULL; + return have_one ? "other" : nullptr; } // Return the last scope in (begin..end] ScopeDesc* nmethod::scope_desc_in(address begin, address end) { PcDesc* p = pc_desc_near(begin+1); - if (p != NULL && p->real_pc(this) <= end) { + if (p != nullptr && p->real_pc(this) <= end) { return new ScopeDesc(this, p); } - return NULL; + return nullptr; } const char* nmethod::nmethod_section_label(address pos) const { - const char* label = NULL; + const char* label = nullptr; if (pos == code_begin()) label = "[Instructions begin]"; if (pos == entry_point()) label = "[Entry Point]"; if (pos == verified_entry_point()) label = "[Verified Entry Point]"; @@ -3007,14 +3007,14 @@ const char* nmethod::nmethod_section_label(address pos) const { // Check stub_code before checking exception_handler or deopt_handler. if (pos == this->stub_begin()) label = "[Stub Code]"; if (JVMCI_ONLY(_exception_offset >= 0 &&) pos == exception_begin()) label = "[Exception Handler]"; - if (JVMCI_ONLY(_deopt_handler_begin != NULL &&) pos == deopt_handler_begin()) label = "[Deopt Handler Code]"; + if (JVMCI_ONLY(_deopt_handler_begin != nullptr &&) pos == deopt_handler_begin()) label = "[Deopt Handler Code]"; return label; } void nmethod::print_nmethod_labels(outputStream* stream, address block_begin, bool print_section_labels) const { if (print_section_labels) { const char* label = nmethod_section_label(block_begin); - if (label != NULL) { + if (label != nullptr) { stream->bol(); stream->print_cr("%s", label); } @@ -3022,12 +3022,12 @@ void nmethod::print_nmethod_labels(outputStream* stream, address block_begin, bo if (block_begin == entry_point()) { Method* m = method(); - if (m != NULL) { + if (m != nullptr) { stream->print(" # "); m->print_value_on(stream); stream->cr(); } - if (m != NULL && !is_osr_method()) { + if (m != nullptr && !is_osr_method()) { ResourceMark rm; int sizeargs = m->size_of_parameters(); BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, sizeargs); @@ -3117,11 +3117,11 @@ void nmethod::print_nmethod_labels(outputStream* stream, address block_begin, bo bool nmethod::has_code_comment(address begin, address end) { // scopes? ScopeDesc* sd = scope_desc_in(begin, end); - if (sd != NULL) return true; + if (sd != nullptr) return true; // relocations? const char* str = reloc_string_for(begin, end); - if (str != NULL) return true; + if (str != nullptr) return true; // implicit exceptions? int cont_offset = ImplicitExceptionTable(this).continuation_offset(begin - code_begin()); @@ -3152,7 +3152,7 @@ void nmethod::print_code_comment_on(outputStream* st, int column, address begin, // instruction. address base = code_begin(); ImmutableOopMapSet* oms = oop_maps(); - if (oms != NULL) { + if (oms != nullptr) { for (int i = 0, imax = oms->count(); i < imax; i++) { const ImmutableOopMapPair* pair = oms->pair_at(i); const ImmutableOopMap* om = pair->get_from(oms); @@ -3181,7 +3181,7 @@ void nmethod::print_code_comment_on(outputStream* st, int column, address begin, // Print any debug info present at this pc. ScopeDesc* sd = scope_desc_in(begin, end); - if (sd != NULL) { + if (sd != nullptr) { st->move_to(column, 6, 0); if (sd->bci() == SynchronizationEntryBCI) { st->print(";*synchronization entry"); @@ -3196,8 +3196,8 @@ void nmethod::print_code_comment_on(outputStream* st, int column, address begin, } else if (sd->bci() == InvalidFrameStateBci) { st->print(";* invalid frame state"); } else { - if (sd->method() == NULL) { - st->print("method is NULL"); + if (sd->method() == nullptr) { + st->print("method is nullptr"); } else if (sd->method()->is_native()) { st->print("method is native"); } else { @@ -3211,7 +3211,7 @@ void nmethod::print_code_comment_on(outputStream* st, int column, address begin, { Bytecode_invoke invoke(methodHandle(thread, sd->method()), sd->bci()); st->print(" "); - if (invoke.name() != NULL) + if (invoke.name() != nullptr) invoke.name()->print_symbol_on(st); else st->print(""); @@ -3224,7 +3224,7 @@ void nmethod::print_code_comment_on(outputStream* st, int column, address begin, { Bytecode_field field(methodHandle(thread, sd->method()), sd->bci()); st->print(" "); - if (field.name() != NULL) + if (field.name() != nullptr) field.name()->print_symbol_on(st); else st->print(""); @@ -3237,14 +3237,14 @@ void nmethod::print_code_comment_on(outputStream* st, int column, address begin, } // Print all scopes - for (;sd != NULL; sd = sd->sender()) { + for (;sd != nullptr; sd = sd->sender()) { st->move_to(column, 6, 0); st->print("; -"); if (sd->should_reexecute()) { st->print(" (reexecute)"); } - if (sd->method() == NULL) { - st->print("method is NULL"); + if (sd->method() == nullptr) { + st->print("method is nullptr"); } else { sd->method()->print_short_name(st); } @@ -3262,8 +3262,8 @@ void nmethod::print_code_comment_on(outputStream* st, int column, address begin, // Prevent memory leak: allocating without ResourceMark. ResourceMark rm; const char* str = reloc_string_for(begin, end); - if (str != NULL) { - if (sd != NULL) st->cr(); + if (str != nullptr) { + if (sd != nullptr) st->cr(); st->move_to(column, 6, 0); st->print("; {%s}", str); } @@ -3309,7 +3309,7 @@ public: virtual void verify_resolve_call(address dest) const { CodeBlob* db = CodeCache::find_blob(dest); - assert(db != NULL && !db->is_adapter_blob(), "must use stub!"); + assert(db != nullptr && !db->is_adapter_blob(), "must use stub!"); } virtual bool is_call_to_interpreted(address dest) const { @@ -3345,7 +3345,7 @@ address nmethod::call_instruction_address(address pc) const { NativeCall *ncall = nativeCall_before(pc); return ncall->instruction_address(); } - return NULL; + return nullptr; } CompiledStaticCall* nmethod::compiledStaticCall_at(Relocation* call_site) const { @@ -3363,7 +3363,7 @@ CompiledStaticCall* nmethod::compiledStaticCall_before(address return_addr) cons #if defined(SUPPORT_DATA_STRUCTS) void nmethod::print_value_on(outputStream* st) const { st->print("nmethod"); - print_on(st, NULL); + print_on(st, nullptr); } #endif @@ -3391,7 +3391,7 @@ void nmethod::print_calls(outputStream* st) { void nmethod::print_statistics() { ttyLocker ttyl; - if (xtty != NULL) xtty->head("statistics type='nmethod'"); + if (xtty != nullptr) xtty->head("statistics type='nmethod'"); native_nmethod_stats.print_native_nmethod_stats(); #ifdef COMPILER1 c1_java_nmethod_stats.print_nmethod_stats("C1"); @@ -3408,7 +3408,7 @@ void nmethod::print_statistics() { pc_nmethod_stats.print_pc_stats(); #endif Dependencies::print_statistics(); - if (xtty != NULL) xtty->tail("statistics"); + if (xtty != nullptr) xtty->tail("statistics"); } #endif // !PRODUCT @@ -3417,16 +3417,16 @@ void nmethod::print_statistics() { void nmethod::update_speculation(JavaThread* thread) { jlong speculation = thread->pending_failed_speculation(); if (speculation != 0) { - guarantee(jvmci_nmethod_data() != NULL, "failed speculation in nmethod without failed speculation list"); + guarantee(jvmci_nmethod_data() != nullptr, "failed speculation in nmethod without failed speculation list"); jvmci_nmethod_data()->add_failed_speculation(this, speculation); thread->set_pending_failed_speculation(0); } } const char* nmethod::jvmci_name() { - if (jvmci_nmethod_data() != NULL) { + if (jvmci_nmethod_data() != nullptr) { return jvmci_nmethod_data()->name(); } - return NULL; + return nullptr; } #endif diff --git a/src/hotspot/share/code/nmethod.hpp b/src/hotspot/share/code/nmethod.hpp index 9a425db9183..b73e4e1a26d 100644 --- a/src/hotspot/share/code/nmethod.hpp +++ b/src/hotspot/share/code/nmethod.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -101,7 +101,7 @@ class nmethod : public CompiledMethod { // // _oops_do_mark_link special values: // - // _oops_do_mark_link == NULL: the nmethod has not been visited at all yet, i.e. + // _oops_do_mark_link == nullptr: the nmethod has not been visited at all yet, i.e. // is Unclaimed. // // For other values, its lowest two bits indicate the following states of the nmethod: @@ -173,7 +173,7 @@ class nmethod : public CompiledMethod { // Attempt Unclaimed -> N|SD transition. Returns the current link. oops_do_mark_link* oops_do_try_claim_strong_done(); - // Attempt N|WR -> X|WD transition. Returns NULL if successful, X otherwise. + // Attempt N|WR -> X|WD transition. Returns nullptr if successful, X otherwise. nmethod* oops_do_try_add_to_list_as_weak_done(); // Attempt X|WD -> N|SR transition. Returns the current link. @@ -343,11 +343,11 @@ class nmethod : public CompiledMethod { AbstractCompiler* compiler, CompLevel comp_level #if INCLUDE_JVMCI - , char* speculations = NULL, + , char* speculations = nullptr, int speculations_len = 0, int nmethod_mirror_index = -1, - const char* nmethod_mirror_name = NULL, - FailedSpeculation** failed_speculations = NULL + const char* nmethod_mirror_name = nullptr, + FailedSpeculation** failed_speculations = nullptr #endif ); @@ -380,7 +380,7 @@ class nmethod : public CompiledMethod { address stub_begin () const { return header_begin() + _stub_offset ; } address stub_end () const { return header_begin() + _oops_offset ; } address exception_begin () const { return header_begin() + _exception_offset ; } - address unwind_handler_begin () const { return _unwind_handler_offset != -1 ? (header_begin() + _unwind_handler_offset) : NULL; } + address unwind_handler_begin () const { return _unwind_handler_offset != -1 ? (header_begin() + _unwind_handler_offset) : nullptr; } oop* oops_begin () const { return (oop*) (header_begin() + _oops_offset) ; } oop* oops_end () const { return (oop*) (header_begin() + _metadata_offset) ; } @@ -491,7 +491,7 @@ class nmethod : public CompiledMethod { // Support for meta data in scopes and relocs: // Note: index 0 is reserved for null. - Metadata* metadata_at(int index) const { return index == 0 ? NULL: *metadata_addr_at(index); } + Metadata* metadata_at(int index) const { return index == 0 ? nullptr: *metadata_addr_at(index); } Metadata** metadata_addr_at(int index) const { // for GC // relocation indexes are biased by 1 (because 0 is reserved) assert(index > 0 && index <= metadata_count(), "must be a valid non-zero index"); @@ -508,7 +508,7 @@ private: public: void fix_oop_relocations(address begin, address end) { fix_oop_relocations(begin, end, false); } - void fix_oop_relocations() { fix_oop_relocations(NULL, NULL, false); } + void fix_oop_relocations() { fix_oop_relocations(nullptr, nullptr, false); } // On-stack replacement support int osr_entry_bci() const { assert(is_osr_method(), "wrong kind of nmethod"); return _entry_bci; } @@ -542,10 +542,10 @@ public: void update_speculation(JavaThread* thread); // Gets the data specific to a JVMCI compiled method. - // This returns a non-NULL value iff this nmethod was + // This returns a non-nullptr value iff this nmethod was // compiled by the JVMCI compiler. JVMCINMethodData* jvmci_nmethod_data() const { - return jvmci_data_size() == 0 ? NULL : (JVMCINMethodData*) jvmci_data_begin(); + return jvmci_data_size() == 0 ? nullptr : (JVMCINMethodData*) jvmci_data_begin(); } #endif @@ -601,7 +601,7 @@ public: void post_compiled_method(CompileTask* task); // jvmti support: - void post_compiled_method_load_event(JvmtiThreadState* state = NULL); + void post_compiled_method_load_event(JvmtiThreadState* state = nullptr); // verify operations void verify(); diff --git a/src/hotspot/share/code/oopRecorder.cpp b/src/hotspot/share/code/oopRecorder.cpp index ace40c2c701..bfcb4bad475 100644 --- a/src/hotspot/share/code/oopRecorder.cpp +++ b/src/hotspot/share/code/oopRecorder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,8 +41,8 @@ template int ValueRecorder::_missed_indexes = 0; template ValueRecorder::ValueRecorder(Arena* arena) { - _handles = NULL; - _indexes = NULL; + _handles = nullptr; + _indexes = nullptr; _arena = arena; _complete = false; } @@ -54,7 +54,7 @@ template template ValueRecorder::IndexCache::IndexCac template int ValueRecorder::size() { _complete = true; - if (_handles == NULL) return 0; + if (_handles == nullptr) return 0; return _handles->length() * sizeof(T); } @@ -65,8 +65,8 @@ template void ValueRecorder::copy_values_to(nmethod* nm) { } template void ValueRecorder::maybe_initialize() { - if (_handles == NULL) { - if (_arena != NULL) { + if (_handles == nullptr) { + if (_arena != nullptr) { _handles = new(_arena) GrowableArray(_arena, 10, 0, 0); _no_finds = new(_arena) GrowableArray( _arena, 10, 0, 0); } else { @@ -78,8 +78,8 @@ template void ValueRecorder::maybe_initialize() { template T ValueRecorder::at(int index) { - // there is always a NULL virtually present as first object - if (index == null_index) return NULL; + // there is always a nullptr virtually present as first object + if (index == null_index) return nullptr; return _handles->at(index - first_index); } @@ -95,10 +95,10 @@ template int ValueRecorder::add_handle(T h, bool make_findable) { assert(!(make_findable && !is_real(h)), "nulls are not findable"); if (make_findable) { // This index may be returned from find_index(). - if (_indexes != NULL) { + if (_indexes != nullptr) { int* cloc = _indexes->cache_location(h); _indexes->set_cache_location_index(cloc, index); - } else if (index == index_cache_threshold && _arena != NULL) { + } else if (index == index_cache_threshold && _arena != nullptr) { _indexes = new(_arena) IndexCache(); for (int i = 0; i < _handles->length(); i++) { // Load the cache with pre-existing elements. @@ -111,7 +111,7 @@ template int ValueRecorder::add_handle(T h, bool make_findable) { } else if (is_real(h)) { // Remember that this index is not to be returned from find_index(). // This case is rare, because most or all uses of allocate_index pass - // an argument of NULL or Universe::non_oop_word. + // an argument of nullptr or Universe::non_oop_word. // Thus, the expected length of _no_finds is zero. _no_finds->append(index); } @@ -124,10 +124,10 @@ template int ValueRecorder::maybe_find_index(T h) { debug_only(_find_index_calls++); assert(!_complete, "cannot allocate more elements after size query"); maybe_initialize(); - if (h == NULL) return null_index; + if (h == nullptr) return null_index; assert(is_real(h), "must be valid"); - int* cloc = (_indexes == NULL)? NULL: _indexes->cache_location(h); - if (cloc != NULL) { + int* cloc = (_indexes == nullptr)? nullptr: _indexes->cache_location(h); + if (cloc != nullptr) { int cindex = _indexes->cache_location_index(cloc); if (cindex == 0) { return -1; // We know this handle is completely new. @@ -147,7 +147,7 @@ template int ValueRecorder::maybe_find_index(T h) { if (_handles->at(i) == h) { int findex = i + first_index; if (_no_finds->contains(findex)) continue; // oops; skip this one - if (cloc != NULL) { + if (cloc != nullptr) { _indexes->set_cache_location_index(cloc, findex); } debug_only(_missed_indexes++); @@ -188,7 +188,7 @@ int ObjectLookup::sort_oop_by_address(oop const& a, ObjectEntry const& b) { } int ObjectLookup::find_index(jobject handle, OopRecorder* oop_recorder) { - if (handle == NULL) { + if (handle == nullptr) { return 0; } oop object = JNIHandles::resolve(handle); @@ -208,6 +208,6 @@ OopRecorder::OopRecorder(Arena* arena, bool deduplicate): _oops(arena), _metadat if (deduplicate) { _object_lookup = new ObjectLookup(); } else { - _object_lookup = NULL; + _object_lookup = nullptr; } } diff --git a/src/hotspot/share/code/oopRecorder.hpp b/src/hotspot/share/code/oopRecorder.hpp index 06b466ec1f7..41d2c0da591 100644 --- a/src/hotspot/share/code/oopRecorder.hpp +++ b/src/hotspot/share/code/oopRecorder.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,9 +38,9 @@ template class ValueRecorder : public StackObj { // The zero index is reserved for a constant (shareable) null. // Indexes may not be negative. - // Use the given arena to manage storage, if not NULL. + // Use the given arena to manage storage, if not nullptr. // By default, uses the current ResourceArea. - ValueRecorder(Arena* arena = NULL); + ValueRecorder(Arena* arena = nullptr); // Generate a new index on which nmethod::oop_addr_at will work. // allocate_index and find_index never return the same index, @@ -70,18 +70,18 @@ template class ValueRecorder : public StackObj { T at(int index); int count() { - if (_handles == NULL) return 0; - // there is always a NULL virtually present as first object + if (_handles == nullptr) return 0; + // there is always a nullptr virtually present as first object return _handles->length() + first_index; } - // Helper function; returns false for NULL or Universe::non_oop_word(). + // Helper function; returns false for nullptr or Universe::non_oop_word(). inline bool is_real(T h); // copy the generated table to nmethod void copy_values_to(nmethod* nm); - bool is_unused() { return _handles == NULL && !_complete; } + bool is_unused() { return _handles == nullptr && !_complete; } #ifdef ASSERT bool is_complete() { return _complete; } #endif @@ -132,7 +132,7 @@ template class ValueRecorder : public StackObj { enum { null_index = 0, first_index = 1, index_cache_threshold = 20 }; - GrowableArray* _handles; // ordered list (first is always NULL) + GrowableArray* _handles; // ordered list (first is always nullptr) GrowableArray* _no_finds; // all unfindable indexes; usually empty IndexCache* _indexes; // map: handle -> its probable index Arena* _arena; @@ -154,7 +154,7 @@ class ObjectLookup : public ResourceObj { public: ObjectEntry(jobject value, int index) : _value(value), _index(index) {} - ObjectEntry() : _value(NULL), _index(0) {} + ObjectEntry() : _value(nullptr), _index(0) {} oop oop_value() const; int index() { return _index; } }; @@ -181,13 +181,13 @@ class OopRecorder : public ResourceObj { ValueRecorder _metadata; ObjectLookup* _object_lookup; public: - OopRecorder(Arena* arena = NULL, bool deduplicate = false); + OopRecorder(Arena* arena = nullptr, bool deduplicate = false); int allocate_oop_index(jobject h) { return _oops.allocate_index(h); } virtual int find_index(jobject h) { - return _object_lookup != NULL ? _object_lookup->find_index(h, this) : _oops.find_index(h); + return _object_lookup != nullptr ? _object_lookup->find_index(h, this) : _oops.find_index(h); } jobject oop_at(int index) { return _oops.at(index); diff --git a/src/hotspot/share/code/oopRecorder.inline.hpp b/src/hotspot/share/code/oopRecorder.inline.hpp index 0e05c91fea1..2002389b828 100644 --- a/src/hotspot/share/code/oopRecorder.inline.hpp +++ b/src/hotspot/share/code/oopRecorder.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ template bool ValueRecorder::is_real(T h) { - return h != NULL && h != (T)Universe::non_oop_word(); + return h != nullptr && h != (T)Universe::non_oop_word(); } bool OopRecorder::is_real(jobject h) { diff --git a/src/hotspot/share/code/pcDesc.cpp b/src/hotspot/share/code/pcDesc.cpp index e765ab1a69f..c6ee8c69521 100644 --- a/src/hotspot/share/code/pcDesc.cpp +++ b/src/hotspot/share/code/pcDesc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ void PcDesc::print_on(outputStream* st, CompiledMethod* code) { } for (ScopeDesc* sd = code->scope_desc_at(real_pc(code)); - sd != NULL; + sd != nullptr; sd = sd->sender()) { sd->print_on(st); } diff --git a/src/hotspot/share/code/relocInfo.cpp b/src/hotspot/share/code/relocInfo.cpp index 97f3ebd6055..2048964da65 100644 --- a/src/hotspot/share/code/relocInfo.cpp +++ b/src/hotspot/share/code/relocInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -119,12 +119,12 @@ void relocInfo::change_reloc_info_for_address(RelocIterator *itr, address pc, re void RelocIterator::initialize(CompiledMethod* nm, address begin, address limit) { initialize_misc(); - if (nm == NULL && begin != NULL) { + if (nm == nullptr && begin != nullptr) { // allow nmethod to be deduced from beginning address CodeBlob* cb = CodeCache::find_blob(begin); - nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; + nm = (cb != nullptr) ? cb->as_compiled_method_or_null() : nullptr; } - guarantee(nm != NULL, "must be able to deduce nmethod from other arguments"); + guarantee(nm != nullptr, "must be able to deduce nmethod from other arguments"); _code = nm; _current = nm->relocation_begin() - 1; @@ -141,8 +141,8 @@ void RelocIterator::initialize(CompiledMethod* nm, address begin, address limit) _section_end [CodeBuffer::SECT_STUBS ] = nm->stub_end() ; assert(!has_current(), "just checking"); - assert(begin == NULL || begin >= nm->code_begin(), "in bounds"); - assert(limit == NULL || limit <= nm->code_end(), "in bounds"); + assert(begin == nullptr || begin >= nm->code_begin(), "in bounds"); + assert(limit == nullptr || limit <= nm->code_end(), "in bounds"); set_limits(begin, limit); } @@ -153,7 +153,7 @@ RelocIterator::RelocIterator(CodeSection* cs, address begin, address limit) { _current = cs->locs_start()-1; _end = cs->locs_end(); _addr = cs->start(); - _code = NULL; // Not cb->blob(); + _code = nullptr; // Not cb->blob(); CodeBuffer* cb = cs->outer(); assert((int) SECT_LIMIT == CodeBuffer::SECT_LIMIT, "my copy must be equal"); @@ -165,8 +165,8 @@ RelocIterator::RelocIterator(CodeSection* cs, address begin, address limit) { assert(!has_current(), "just checking"); - assert(begin == NULL || begin >= cs->start(), "in bounds"); - assert(limit == NULL || limit <= cs->end(), "in bounds"); + assert(begin == nullptr || begin >= cs->start(), "in bounds"); + assert(limit == nullptr || limit <= cs->end(), "in bounds"); set_limits(begin, limit); } @@ -180,7 +180,7 @@ void RelocIterator::set_limits(address begin, address limit) { _limit = limit; // the limit affects this next stuff: - if (begin != NULL) { + if (begin != nullptr) { relocInfo* backup; address backup_addr; while (true) { @@ -221,8 +221,8 @@ void RelocIterator::advance_over_prefix() { void RelocIterator::initialize_misc() { set_has_current(false); for (int i = (int) CodeBuffer::SECT_FIRST; i < (int) CodeBuffer::SECT_LIMIT; i++) { - _section_start[i] = NULL; // these will be lazily computed, if needed - _section_end [i] = NULL; + _section_start[i] = nullptr; // these will be lazily computed, if needed + _section_end [i] = nullptr; } } @@ -304,7 +304,7 @@ RelocationHolder RelocationHolder::plus(int offset) const { // some relocations can compute their own values address Relocation::value() { ShouldNotReachHere(); - return NULL; + return nullptr; } @@ -361,7 +361,7 @@ address Relocation::new_addr_for(address olda, int sect = CodeBuffer::SECT_NONE; // Look for olda in the source buffer, and all previous incarnations // if the source buffer has been expanded. - for (; src != NULL; src = src->before_expand()) { + for (; src != nullptr; src = src->before_expand()) { sect = src->section_index_of(olda); if (sect != CodeBuffer::SECT_NONE) break; } @@ -373,7 +373,7 @@ address Relocation::new_addr_for(address olda, void Relocation::normalize_address(address& addr, const CodeSection* dest, bool allow_other_sections) { address addr0 = addr; - if (addr0 == NULL || dest->allocates2(addr0)) return; + if (addr0 == nullptr || dest->allocates2(addr0)) return; CodeBuffer* cb = dest->outer(); addr = new_addr_for(addr0, cb, cb); assert(allow_other_sections || dest->contains2(addr), @@ -436,7 +436,7 @@ void virtual_call_Relocation::unpack_data() { jint x0 = 0; unpack_2_ints(x0, _method_index); address point = addr(); - _cached_value = x0==0? NULL: address_from_scaled_offset(x0, point); + _cached_value = x0==0? nullptr: address_from_scaled_offset(x0, point); } void runtime_call_w_cp_Relocation::pack_data_to(CodeSection * dest) { @@ -508,7 +508,7 @@ void internal_word_Relocation::pack_data_to(CodeSection* dest) { // Check whether my target address is valid within this section. // If not, strengthen the relocation type to point to another section. int sindex = _section; - if (sindex == CodeBuffer::SECT_NONE && _target != NULL + if (sindex == CodeBuffer::SECT_NONE && _target != nullptr && (!dest->allocates(_target) || _target == dest->locs_point())) { sindex = dest->outer()->section_index_of(_target); guarantee(sindex != CodeBuffer::SECT_NONE, "must belong somewhere"); @@ -524,12 +524,12 @@ void internal_word_Relocation::pack_data_to(CodeSection* dest) { if (sindex == CodeBuffer::SECT_NONE) { assert(type() == relocInfo::internal_word_type, "must be base class"); - guarantee(_target == NULL || dest->allocates2(_target), "must be within the given code section"); + guarantee(_target == nullptr || dest->allocates2(_target), "must be within the given code section"); jint x0 = scaled_offset_null_special(_target, dest->locs_point()); - assert(!(x0 == 0 && _target != NULL), "correct encoding of null target"); + assert(!(x0 == 0 && _target != nullptr), "correct encoding of null target"); p = pack_1_int_to(p, x0); } else { - assert(_target != NULL, "sanity"); + assert(_target != nullptr, "sanity"); CodeSection* sect = dest->outer()->code_section(sindex); guarantee(sect->allocates2(_target), "must be in correct section"); address base = sect->start(); @@ -545,7 +545,7 @@ void internal_word_Relocation::pack_data_to(CodeSection* dest) { void internal_word_Relocation::unpack_data() { jint x0 = unpack_1_int(); - _target = x0==0? NULL: address_from_scaled_offset(x0, addr()); + _target = x0==0? nullptr: address_from_scaled_offset(x0, addr()); _section = CodeBuffer::SECT_NONE; } @@ -576,7 +576,7 @@ oop* oop_Relocation::oop_addr() { oop oop_Relocation::oop_value() { // clean inline caches store a special pseudo-null if (Universe::contains_non_oop_word(oop_addr())) { - return NULL; + return nullptr; } return *oop_addr(); } @@ -613,7 +613,7 @@ Metadata** metadata_Relocation::metadata_addr() { Metadata* metadata_Relocation::metadata_value() { Metadata* v = *metadata_addr(); // clean inline caches store a special pseudo-null - if (v == (Metadata*)Universe::non_oop_word()) v = NULL; + if (v == (Metadata*)Universe::non_oop_word()) v = nullptr; return v; } @@ -626,16 +626,16 @@ void metadata_Relocation::fix_metadata_relocation() { } address virtual_call_Relocation::cached_value() { - assert(_cached_value != NULL && _cached_value < addr(), "must precede ic_call"); + assert(_cached_value != nullptr && _cached_value < addr(), "must precede ic_call"); return _cached_value; } Method* virtual_call_Relocation::method_value() { CompiledMethod* cm = code(); - if (cm == NULL) return (Method*)NULL; + if (cm == nullptr) return (Method*)nullptr; Metadata* m = cm->metadata_at(_method_index); - assert(m != NULL || _method_index == 0, "should be non-null for non-zero index"); - assert(m == NULL || m->is_method(), "not a method"); + assert(m != nullptr || _method_index == 0, "should be non-null for non-zero index"); + assert(m == nullptr || m->is_method(), "not a method"); return (Method*)m; } @@ -660,10 +660,10 @@ void opt_virtual_call_Relocation::unpack_data() { Method* opt_virtual_call_Relocation::method_value() { CompiledMethod* cm = code(); - if (cm == NULL) return (Method*)NULL; + if (cm == nullptr) return (Method*)nullptr; Metadata* m = cm->metadata_at(_method_index); - assert(m != NULL || _method_index == 0, "should be non-null for non-zero index"); - assert(m == NULL || m->is_method(), "not a method"); + assert(m != nullptr || _method_index == 0, "should be non-null for non-zero index"); + assert(m == nullptr || m->is_method(), "not a method"); return (Method*)m; } @@ -693,15 +693,15 @@ address opt_virtual_call_Relocation::static_stub() { } } } - return NULL; + return nullptr; } Method* static_call_Relocation::method_value() { CompiledMethod* cm = code(); - if (cm == NULL) return (Method*)NULL; + if (cm == nullptr) return (Method*)nullptr; Metadata* m = cm->metadata_at(_method_index); - assert(m != NULL || _method_index == 0, "should be non-null for non-zero index"); - assert(m == NULL || m->is_method(), "not a method"); + assert(m != nullptr || _method_index == 0, "should be non-null for non-zero index"); + assert(m == nullptr || m->is_method(), "not a method"); return (Method*)m; } @@ -734,16 +734,16 @@ address static_call_Relocation::static_stub() { } } } - return NULL; + return nullptr; } // Finds the trampoline address for a call. If no trampoline stub is -// found NULL is returned which can be handled by the caller. +// found nullptr is returned which can be handled by the caller. address trampoline_stub_Relocation::get_trampoline_for(address call, nmethod* code) { // There are no relocations available when the code gets relocated // because of CodeBuffer expansion. if (code->relocation_size() == 0) - return NULL; + return nullptr; RelocIterator iter(code, call); while (iter.next()) { @@ -754,7 +754,7 @@ address trampoline_stub_Relocation::get_trampoline_for(address call, nmethod* co } } - return NULL; + return nullptr; } bool static_stub_Relocation::clear_inline_cache() { @@ -766,12 +766,12 @@ bool static_stub_Relocation::clear_inline_cache() { void external_word_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { - if (_target != NULL) { + if (_target != nullptr) { // Probably this reference is absolute, not relative, so the following is // probably a no-op. set_value(_target); } - // If target is NULL, this is an absolute embedded reference to an external + // If target is nullptr, this is an absolute embedded reference to an external // location, which means there is nothing to fix here. In either case, the // resulting target should be an "external" address. postcond(src->section_index_of(target()) == CodeBuffer::SECT_NONE); @@ -781,7 +781,7 @@ void external_word_Relocation::fix_relocation_after_move(const CodeBuffer* src, address external_word_Relocation::target() { address target = _target; - if (target == NULL) { + if (target == nullptr) { target = pd_get_address_from_code(); } return target; @@ -790,7 +790,7 @@ address external_word_Relocation::target() { void internal_word_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { address target = _target; - if (target == NULL) { + if (target == nullptr) { target = new_addr_for(this->target(), src, dest); } set_value(target); @@ -799,7 +799,7 @@ void internal_word_Relocation::fix_relocation_after_move(const CodeBuffer* src, address internal_word_Relocation::target() { address target = _target; - if (target == NULL) { + if (target == nullptr) { if (addr_in_const()) { target = *(address*)addr(); } else { @@ -856,10 +856,10 @@ void RelocIterator::print_current() { case relocInfo::oop_type: { oop_Relocation* r = oop_reloc(); - oop* oop_addr = NULL; - oop raw_oop = NULL; - oop oop_value = NULL; - if (code() != NULL || r->oop_is_immediate()) { + oop* oop_addr = nullptr; + oop raw_oop = nullptr; + oop oop_value = nullptr; + if (code() != nullptr || r->oop_is_immediate()) { oop_addr = r->oop_addr(); raw_oop = *oop_addr; oop_value = r->oop_value(); @@ -868,7 +868,7 @@ void RelocIterator::print_current() { p2i(oop_addr), p2i(raw_oop), r->offset()); // Do not print the oop by default--we want this routine to // work even during GC or other inconvenient times. - if (WizardMode && oop_value != NULL) { + if (WizardMode && oop_value != nullptr) { tty->print("oop_value=" INTPTR_FORMAT ": ", p2i(oop_value)); if (oopDesc::is_oop(oop_value)) { oop_value->print_value_on(tty); @@ -879,17 +879,17 @@ void RelocIterator::print_current() { case relocInfo::metadata_type: { metadata_Relocation* r = metadata_reloc(); - Metadata** metadata_addr = NULL; - Metadata* raw_metadata = NULL; - Metadata* metadata_value = NULL; - if (code() != NULL || r->metadata_is_immediate()) { + Metadata** metadata_addr = nullptr; + Metadata* raw_metadata = nullptr; + Metadata* metadata_value = nullptr; + if (code() != nullptr || r->metadata_is_immediate()) { metadata_addr = r->metadata_addr(); raw_metadata = *metadata_addr; metadata_value = r->metadata_value(); } tty->print(" | [metadata_addr=" INTPTR_FORMAT " *=" INTPTR_FORMAT " offset=%d]", p2i(metadata_addr), p2i(raw_metadata), r->offset()); - if (metadata_value != NULL) { + if (metadata_value != nullptr) { tty->print("metadata_value=" INTPTR_FORMAT ": ", p2i(metadata_value)); metadata_value->print_value_on(tty); } diff --git a/src/hotspot/share/code/relocInfo.hpp b/src/hotspot/share/code/relocInfo.hpp index 56a10731dcd..f4041c4415a 100644 --- a/src/hotspot/share/code/relocInfo.hpp +++ b/src/hotspot/share/code/relocInfo.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -580,7 +580,7 @@ class RelocIterator : public StackObj { void set_has_current(bool b) { _datalen = !b ? -1 : 0; - debug_only(_data = NULL); + debug_only(_data = nullptr); } void set_current(relocInfo& ri) { _current = &ri; @@ -604,8 +604,8 @@ class RelocIterator : public StackObj { public: // constructor - RelocIterator(CompiledMethod* nm, address begin = NULL, address limit = NULL); - RelocIterator(CodeSection* cb, address begin = NULL, address limit = NULL); + RelocIterator(CompiledMethod* nm, address begin = nullptr, address limit = nullptr); + RelocIterator(CodeSection* cb, address begin = nullptr, address limit = nullptr); // get next reloc info, return !eos bool next() { @@ -624,7 +624,7 @@ class RelocIterator : public StackObj { _addr += _current->addr_offset(); - if (_limit != NULL && _addr >= _limit) { + if (_limit != nullptr && _addr >= _limit) { set_has_current(false); return false; } @@ -689,16 +689,16 @@ class Relocation { protected: RelocIterator* binding() const { - assert(_binding != NULL, "must be bound"); + assert(_binding != nullptr, "must be bound"); return _binding; } void set_binding(RelocIterator* b) { - assert(_binding == NULL, "must be unbound"); + assert(_binding == nullptr, "must be unbound"); _binding = b; - assert(_binding != NULL, "must now be bound"); + assert(_binding != nullptr, "must now be bound"); } - explicit Relocation(relocInfo::relocType rtype) : _binding(NULL), _rtype(rtype) { } + explicit Relocation(relocInfo::relocType rtype) : _binding(nullptr), _rtype(rtype) { } // Helper for copy_into functions for derived classes. // Forwards operation to RelocationHolder::copy_into_impl so that @@ -788,7 +788,7 @@ class Relocation { // platform-dependent utilities for decoding and patching instructions void pd_set_data_value (address x, intptr_t off, bool verify_only = false); // a set or mem-ref void pd_verify_data_value (address x, intptr_t off) { pd_set_data_value(x, off, true); } - address pd_call_destination (address orig_addr = NULL); + address pd_call_destination (address orig_addr = nullptr); void pd_set_call_destination (address x); // this extracts the address of an address in the code stream instead of the reloc data @@ -805,9 +805,9 @@ class Relocation { return offset; } static jint scaled_offset_null_special(address x, address base) { - // Some relocations treat offset=0 as meaning NULL. + // Some relocations treat offset=0 as meaning nullptr. // Handle this extra convention carefully. - if (x == NULL) return 0; + if (x == nullptr) return 0; assert(x != base, "offset must not be zero"); return scaled_offset(x, base); } @@ -1020,7 +1020,7 @@ class oop_Relocation : public DataRelocation { oop* oop_addr(); // addr or &pool[jint_data] oop oop_value(); // *oop_addr - // Note: oop_value transparently converts Universe::non_oop_word to NULL. + // Note: oop_value transparently converts Universe::non_oop_word to nullptr. }; @@ -1074,7 +1074,7 @@ class metadata_Relocation : public DataRelocation { Metadata** metadata_addr(); // addr or &pool[jint_data] Metadata* metadata_value(); // *metadata_addr - // Note: metadata_value transparently converts Universe::non_metadata_word to NULL. + // Note: metadata_value transparently converts Universe::non_metadata_word to nullptr. }; @@ -1098,7 +1098,7 @@ class virtual_call_Relocation : public CallRelocation { : CallRelocation(relocInfo::virtual_call_type), _cached_value(cached_value), _method_index(method_index) { - assert(cached_value != NULL, "first oop address must be specified"); + assert(cached_value != nullptr, "first oop address must be specified"); } friend class RelocationHolder; @@ -1296,7 +1296,7 @@ class trampoline_stub_Relocation : public Relocation { class external_word_Relocation : public DataRelocation { public: static RelocationHolder spec(address target) { - assert(target != NULL, "must not be null"); + assert(target != nullptr, "must not be null"); return RelocationHolder::construct(target); } @@ -1311,8 +1311,8 @@ class external_word_Relocation : public DataRelocation { // Some address looking values aren't safe to treat as relocations // and should just be treated as constants. static bool can_be_relocated(address target) { - assert(target == NULL || (uintptr_t)target >= (uintptr_t)OSInfo::vm_page_size(), INTPTR_FORMAT, (intptr_t)target); - return target != NULL; + assert(target == nullptr || (uintptr_t)target >= (uintptr_t)OSInfo::vm_page_size(), INTPTR_FORMAT, (intptr_t)target); + return target != nullptr; } private: @@ -1328,13 +1328,13 @@ class external_word_Relocation : public DataRelocation { // data is packed as a well-known address in "1_int" format: [a] or [Aa] // The function runtime_address_to_index is used to turn full addresses // to short indexes, if they are pre-registered by the stub mechanism. - // If the "a" value is 0 (i.e., _target is NULL), the address is stored + // If the "a" value is 0 (i.e., _target is nullptr), the address is stored // in the code stream. See external_word_Relocation::target(). void pack_data_to(CodeSection* dest) override; void unpack_data() override; void fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) override; - address target(); // if _target==NULL, fetch addr from code stream + address target(); // if _target==nullptr, fetch addr from code stream address value() override { return target(); } }; @@ -1342,7 +1342,7 @@ class internal_word_Relocation : public DataRelocation { public: static RelocationHolder spec(address target) { - assert(target != NULL, "must not be null"); + assert(target != nullptr, "must not be null"); return RelocationHolder::construct(target); } @@ -1371,14 +1371,14 @@ class internal_word_Relocation : public DataRelocation { public: // data is packed as a scaled offset in "1_int" format: [o] or [Oo] - // If the "o" value is 0 (i.e., _target is NULL), the offset is stored + // If the "o" value is 0 (i.e., _target is nullptr), the offset is stored // in the code stream. See internal_word_Relocation::target(). // If _section is not -1, it is appended to the low bits of the offset. void pack_data_to(CodeSection* dest) override; void unpack_data() override; void fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) override; - address target(); // if _target==NULL, fetch addr from code stream + address target(); // if _target==nullptr, fetch addr from code stream int section() { return _section; } address value() override { return target(); } }; @@ -1393,7 +1393,7 @@ class section_word_Relocation : public internal_word_Relocation { section_word_Relocation(address target, int section) : internal_word_Relocation(target, section, relocInfo::section_word_type) { - assert(target != NULL, "must not be null"); + assert(target != nullptr, "must not be null"); assert(section >= 0 && section < RelocIterator::SECT_LIMIT, "must be a valid section"); } diff --git a/src/hotspot/share/code/scopeDesc.cpp b/src/hotspot/share/code/scopeDesc.cpp index c7daa6d8626..850eb6ccafd 100644 --- a/src/hotspot/share/code/scopeDesc.cpp +++ b/src/hotspot/share/code/scopeDesc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -94,7 +94,7 @@ void ScopeDesc::decode_body() { GrowableArray* ScopeDesc::decode_scope_values(int decode_offset) { - if (decode_offset == DebugInformationRecorder::serialized_null) return NULL; + if (decode_offset == DebugInformationRecorder::serialized_null) return nullptr; DebugInfoReadStream* stream = stream_at(decode_offset); int length = stream->read_int(); GrowableArray* result = new GrowableArray (length); @@ -105,7 +105,7 @@ GrowableArray* ScopeDesc::decode_scope_values(int decode_offset) { } GrowableArray* ScopeDesc::decode_object_values(int decode_offset) { - if (decode_offset == DebugInformationRecorder::serialized_null) return NULL; + if (decode_offset == DebugInformationRecorder::serialized_null) return nullptr; GrowableArray* result = new GrowableArray(); DebugInfoReadStream* stream = new DebugInfoReadStream(_code, decode_offset, result); int length = stream->read_int(); @@ -120,7 +120,7 @@ GrowableArray* ScopeDesc::decode_object_values(int decode_offset) { GrowableArray* ScopeDesc::decode_monitor_values(int decode_offset) { - if (decode_offset == DebugInformationRecorder::serialized_null) return NULL; + if (decode_offset == DebugInformationRecorder::serialized_null) return nullptr; DebugInfoReadStream* stream = stream_at(decode_offset); int length = stream->read_int(); GrowableArray* result = new GrowableArray (length); @@ -155,7 +155,7 @@ bool ScopeDesc::is_top() const { } ScopeDesc* ScopeDesc::sender() const { - if (is_top()) return NULL; + if (is_top()) return nullptr; return new ScopeDesc(this); } @@ -178,12 +178,12 @@ void ScopeDesc::print_value_on(outputStream* st) const { } void ScopeDesc::print_on(outputStream* st) const { - print_on(st, NULL); + print_on(st, nullptr); } void ScopeDesc::print_on(outputStream* st, PcDesc* pd) const { // header - if (pd != NULL) { + if (pd != nullptr) { st->print_cr("ScopeDesc(pc=" PTR_FORMAT " offset=%x):", p2i(pd->real_pc(_code)), pd->pc_offset()); } @@ -201,7 +201,7 @@ void ScopeDesc::print_on(outputStream* st, PcDesc* pd) const { } // locals { GrowableArray* l = ((ScopeDesc*) this)->locals(); - if (l != NULL) { + if (l != nullptr) { st->print_cr(" Locals"); for (int index = 0; index < l->length(); index++) { st->print(" - l%d: ", index); @@ -212,7 +212,7 @@ void ScopeDesc::print_on(outputStream* st, PcDesc* pd) const { } // expressions { GrowableArray* l = ((ScopeDesc*) this)->expressions(); - if (l != NULL) { + if (l != nullptr) { st->print_cr(" Expression stack"); for (int index = 0; index < l->length(); index++) { st->print(" - @%d: ", index); @@ -223,7 +223,7 @@ void ScopeDesc::print_on(outputStream* st, PcDesc* pd) const { } // monitors { GrowableArray* l = ((ScopeDesc*) this)->monitors(); - if (l != NULL) { + if (l != nullptr) { st->print_cr(" Monitor stack"); for (int index = 0; index < l->length(); index++) { st->print(" - @%d: ", index); @@ -234,7 +234,7 @@ void ScopeDesc::print_on(outputStream* st, PcDesc* pd) const { } #if COMPILER2_OR_JVMCI - if (NOT_JVMCI(DoEscapeAnalysis &&) is_top() && _objects != NULL) { + if (NOT_JVMCI(DoEscapeAnalysis &&) is_top() && _objects != nullptr) { st->print_cr(" Objects"); for (int i = 0; i < _objects->length(); i++) { ObjectValue* sv = (ObjectValue*) _objects->at(i); @@ -257,7 +257,7 @@ void ScopeDesc::verify() { // check if we have any illegal elements on the expression stack { GrowableArray* l = expressions(); - if (l != NULL) { + if (l != nullptr) { for (int index = 0; index < l->length(); index++) { //guarantee(!l->at(index)->is_illegal(), "expression element cannot be illegal"); } diff --git a/src/hotspot/share/code/scopeDesc.hpp b/src/hotspot/share/code/scopeDesc.hpp index c550b7e3457..7e12276a950 100644 --- a/src/hotspot/share/code/scopeDesc.hpp +++ b/src/hotspot/share/code/scopeDesc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ class SimpleScopeDesc : public StackObj { public: SimpleScopeDesc(CompiledMethod* code, address pc) { PcDesc* pc_desc = code->pc_desc_at(pc); - assert(pc_desc != NULL, "Must be able to find matching PcDesc"); + assert(pc_desc != nullptr, "Must be able to find matching PcDesc"); // save this here so we only have to look up the PcDesc once DebugInfoReadStream buffer(code, pc_desc->scope_decode_offset()); int ignore_sender = buffer.read_int(); @@ -82,7 +82,7 @@ class ScopeDesc : public ResourceObj { GrowableArray* monitors(); GrowableArray* objects(); - // Stack walking, returns NULL if this is the outer most scope. + // Stack walking, returns nullptr if this is the outer most scope. ScopeDesc* sender() const; // Returns where the scope was decoded @@ -90,7 +90,7 @@ class ScopeDesc : public ResourceObj { int sender_decode_offset() const { return _sender_decode_offset; } - // Tells whether sender() returns NULL + // Tells whether sender() returns nullptr bool is_top() const; private: diff --git a/src/hotspot/share/code/stubs.cpp b/src/hotspot/share/code/stubs.cpp index f01648eea87..55e0207c87d 100644 --- a/src/hotspot/share/code/stubs.cpp +++ b/src/hotspot/share/code/stubs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,7 +68,7 @@ StubQueue::StubQueue(StubInterface* stub_interface, int buffer_size, Mutex* lock, const char* name) : _mutex(lock) { intptr_t size = align_up(buffer_size, 2*BytesPerWord); BufferBlob* blob = BufferBlob::create(name, size); - if( blob == NULL) { + if( blob == nullptr) { vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "CodeCache: no room for %s", name); } _stub_interface = stub_interface; @@ -99,17 +99,17 @@ void StubQueue::deallocate_unused_tail() { Stub* StubQueue::stub_containing(address pc) const { if (contains(pc)) { - for (Stub* s = first(); s != NULL; s = next(s)) { + for (Stub* s = first(); s != nullptr; s = next(s)) { if (stub_contains(s, pc)) return s; } } - return NULL; + return nullptr; } Stub* StubQueue::request_committed(int code_size) { Stub* s = request(code_size); - if (s != NULL) commit(code_size); + if (s != nullptr) commit(code_size); return s; } @@ -122,7 +122,7 @@ int StubQueue::compute_stub_size(Stub* stub, int code_size) { Stub* StubQueue::request(int requested_code_size) { assert(requested_code_size > 0, "requested_code_size must be > 0"); - if (_mutex != NULL) _mutex->lock_without_safepoint_check(); + if (_mutex != nullptr) _mutex->lock_without_safepoint_check(); Stub* s = current_stub(); int requested_size = compute_stub_size(s, requested_code_size); if (requested_size <= available_space()) { @@ -153,8 +153,8 @@ Stub* StubQueue::request(int requested_code_size) { return s; } // Not enough space left - if (_mutex != NULL) _mutex->unlock(); - return NULL; + if (_mutex != nullptr) _mutex->unlock(); + return nullptr; } @@ -166,7 +166,7 @@ void StubQueue::commit(int committed_code_size) { stub_initialize(s, committed_size); _queue_end += committed_size; _number_of_stubs++; - if (_mutex != NULL) _mutex->unlock(); + if (_mutex != nullptr) _mutex->unlock(); debug_only(stub_verify(s);) } @@ -209,7 +209,7 @@ void StubQueue::remove_all(){ void StubQueue::verify() { // verify only if initialized - if (_stub_buffer == NULL) return; + if (_stub_buffer == nullptr) return; MutexLocker lock(_mutex, Mutex::_no_safepoint_check_flag); // verify index boundaries guarantee(0 <= _buffer_size, "buffer size must be positive"); @@ -227,7 +227,7 @@ void StubQueue::verify() { } // verify contents int n = 0; - for (Stub* s = first(); s != NULL; s = next(s)) { + for (Stub* s = first(); s != nullptr; s = next(s)) { stub_verify(s); n++; } @@ -238,7 +238,7 @@ void StubQueue::verify() { void StubQueue::print() { MutexLocker lock(_mutex, Mutex::_no_safepoint_check_flag); - for (Stub* s = first(); s != NULL; s = next(s)) { + for (Stub* s = first(); s != nullptr; s = next(s)) { stub_print(s); } } diff --git a/src/hotspot/share/code/stubs.hpp b/src/hotspot/share/code/stubs.hpp index 76b0b7c2205..bf5b7b8eb12 100644 --- a/src/hotspot/share/code/stubs.hpp +++ b/src/hotspot/share/code/stubs.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,8 +68,8 @@ class Stub { int size() const { ShouldNotCallThis(); return 0; } // must return the size provided by initialize // Code info - address code_begin() const { ShouldNotCallThis(); return NULL; } // points to the first byte of the code - address code_end() const { ShouldNotCallThis(); return NULL; } // points to the first byte after the code + address code_begin() const { ShouldNotCallThis(); return nullptr; } // points to the first byte of the code + address code_end() const { ShouldNotCallThis(); return nullptr; } // points to the first byte after the code // Debugging void verify() { ShouldNotCallThis(); } // verifies the Stub @@ -201,11 +201,11 @@ class StubQueue: public CHeapObj { void deallocate_unused_tail(); // deallocate the unused tail of the underlying CodeBlob // only used from TemplateInterpreter::initialize() // Iteration - Stub* first() const { return number_of_stubs() > 0 ? stub_at(_queue_begin) : NULL; } + Stub* first() const { return number_of_stubs() > 0 ? stub_at(_queue_begin) : nullptr; } Stub* next(Stub* s) const { int i = index_of(s) + stub_size(s); // Only wrap around in the non-contiguous case (see stubss.cpp) if (i == _buffer_limit && _queue_end < _buffer_limit) i = 0; - return (i == _queue_end) ? NULL : stub_at(i); + return (i == _queue_end) ? nullptr : stub_at(i); } // Debugging/printing diff --git a/src/hotspot/share/code/vmreg.cpp b/src/hotspot/share/code/vmreg.cpp index 77c6e235fd6..9b8e4ba599d 100644 --- a/src/hotspot/share/code/vmreg.cpp +++ b/src/hotspot/share/code/vmreg.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ const char *VMRegImpl::regName[ConcreteRegisterImpl::number_of_registers]; void VMRegImpl::print_on(outputStream* st) const { if (is_reg()) { - assert(VMRegImpl::regName[value()], "VMRegImpl::regName[" INTPTR_FORMAT "] returns NULL", value()); + assert(VMRegImpl::regName[value()], "VMRegImpl::regName[" INTPTR_FORMAT "] returns nullptr", value()); st->print("%s",VMRegImpl::regName[value()]); } else if (is_stack()) { int stk = reg2stack(); diff --git a/src/hotspot/share/code/vtableStubs.cpp b/src/hotspot/share/code/vtableStubs.cpp index d490adb3eef..42a8a63a38f 100644 --- a/src/hotspot/share/code/vtableStubs.cpp +++ b/src/hotspot/share/code/vtableStubs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,8 +47,8 @@ // ----------------------------------------------------------------------------------------- // Implementation of VtableStub -address VtableStub::_chunk = NULL; -address VtableStub::_chunk_end = NULL; +address VtableStub::_chunk = nullptr; +address VtableStub::_chunk_end = nullptr; VMReg VtableStub::_receiver_location = VMRegImpl::Bad(); @@ -59,14 +59,14 @@ void* VtableStub::operator new(size_t size, int code_size) throw() { const int real_size = align_up(code_size + (int)sizeof(VtableStub), wordSize); // malloc them in chunks to minimize header overhead const int chunk_factor = 32; - if (_chunk == NULL || _chunk + real_size > _chunk_end) { + if (_chunk == nullptr || _chunk + real_size > _chunk_end) { const int bytes = chunk_factor * real_size + pd_code_alignment(); // There is a dependency on the name of the blob in src/share/vm/prims/jvmtiCodeBlobEvents.cpp // If changing the name, update the other file accordingly. VtableBlob* blob = VtableBlob::create("vtable chunks", bytes); - if (blob == NULL) { - return NULL; + if (blob == nullptr) { + return nullptr; } _chunk = blob->content_begin(); _chunk_end = _chunk + bytes; @@ -132,7 +132,7 @@ void VtableStubs::initialize() { assert(_number_of_vtable_stubs == 0, "potential performance bug: VtableStubs initialized more than once"); assert(is_power_of_2(int(N)), "N must be a power of 2"); for (int i = 0; i < N; i++) { - _table[i] = NULL; + _table[i] = nullptr; } } } @@ -216,7 +216,7 @@ address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) { { MutexLocker ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag); s = lookup(is_vtable_stub, vtable_index); - if (s == NULL) { + if (s == nullptr) { if (is_vtable_stub) { s = create_vtable_stub(vtable_index); } else { @@ -224,8 +224,8 @@ address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) { } // Creation of vtable or itable can fail if there is not enough free space in the code cache. - if (s == NULL) { - return NULL; + if (s == nullptr) { + return nullptr; } enter(is_vtable_stub, vtable_index, s); @@ -279,14 +279,14 @@ VtableStub* VtableStubs::entry_point(address pc) { VtableStub* stub = (VtableStub*)(pc - VtableStub::entry_offset()); uint hash = VtableStubs::hash(stub->is_vtable_stub(), stub->index()); VtableStub* s; - for (s = _table[hash]; s != NULL && s != stub; s = s->next()) {} - return (s == stub) ? s : NULL; + for (s = _table[hash]; s != nullptr && s != stub; s = s->next()) {} + return (s == stub) ? s : nullptr; } bool VtableStubs::contains(address pc) { // simple solution for now - we may want to use // a faster way if this function is called often - return stub_containing(pc) != NULL; + return stub_containing(pc) != nullptr; } @@ -295,11 +295,11 @@ VtableStub* VtableStubs::stub_containing(address pc) { // happens with an atomic store into it (we don't care about // consistency with the _number_of_vtable_stubs counter). for (int i = 0; i < N; i++) { - for (VtableStub* s = _table[i]; s != NULL; s = s->next()) { + for (VtableStub* s = _table[i]; s != nullptr; s = s->next()) { if (s->contains(pc)) return s; } } - return NULL; + return nullptr; } void vtableStubs_init() { @@ -308,7 +308,7 @@ void vtableStubs_init() { void VtableStubs::vtable_stub_do(void f(VtableStub*)) { for (int i = 0; i < N; i++) { - for (VtableStub* s = _table[i]; s != NULL; s = s->next()) { + for (VtableStub* s = _table[i]; s != nullptr; s = s->next()) { f(s); } } diff --git a/src/hotspot/share/code/vtableStubs.hpp b/src/hotspot/share/code/vtableStubs.hpp index 9498ad7d329..bd037e62cce 100644 --- a/src/hotspot/share/code/vtableStubs.hpp +++ b/src/hotspot/share/code/vtableStubs.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -106,7 +106,7 @@ class VtableStubs : AllStatic { static VtableStub* entry_point(address pc); // vtable stub entry point for a pc static bool contains(address pc); // is pc within any stub? - static VtableStub* stub_containing(address pc); // stub containing pc or NULL + static VtableStub* stub_containing(address pc); // stub containing pc or nullptr static int number_of_vtable_stubs() { return _number_of_vtable_stubs; } static void initialize(); static void vtable_stub_do(void f(VtableStub*)); // iterates over all vtable stubs @@ -131,7 +131,7 @@ class VtableStub { void* operator new(size_t size, int code_size) throw(); VtableStub(bool is_vtable_stub, int index) - : _next(NULL), _index(index), _ame_offset(-1), _npe_offset(-1), + : _next(nullptr), _index(index), _ame_offset(-1), _npe_offset(-1), _is_vtable_stub(is_vtable_stub) {} VtableStub* next() const { return _next; } int index() const { return _index; }