From f52d35c84b7333809156d201c866793854143888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Sj=C3=B6len?= Date: Fri, 27 Jan 2023 15:43:34 +0000 Subject: [PATCH] 8300240: Replace NULL with nullptr in share/ci/ Reviewed-by: kvn, coleenp --- src/hotspot/share/ci/bcEscapeAnalyzer.cpp | 26 +- src/hotspot/share/ci/bcEscapeAnalyzer.hpp | 4 +- src/hotspot/share/ci/ciArray.cpp | 4 +- src/hotspot/share/ci/ciCallProfile.hpp | 4 +- src/hotspot/share/ci/ciConstantPoolCache.cpp | 4 +- src/hotspot/share/ci/ciEnv.cpp | 236 +++++++++--------- src/hotspot/share/ci/ciEnv.hpp | 40 ++-- src/hotspot/share/ci/ciExceptionHandler.cpp | 6 +- src/hotspot/share/ci/ciExceptionHandler.hpp | 4 +- src/hotspot/share/ci/ciField.cpp | 24 +- src/hotspot/share/ci/ciField.hpp | 6 +- src/hotspot/share/ci/ciInstance.cpp | 16 +- src/hotspot/share/ci/ciInstance.hpp | 4 +- src/hotspot/share/ci/ciInstanceKlass.cpp | 104 ++++---- src/hotspot/share/ci/ciInstanceKlass.hpp | 14 +- src/hotspot/share/ci/ciKlass.cpp | 6 +- src/hotspot/share/ci/ciKlass.hpp | 12 +- src/hotspot/share/ci/ciMetadata.hpp | 6 +- src/hotspot/share/ci/ciMethod.cpp | 140 +++++------ src/hotspot/share/ci/ciMethod.hpp | 16 +- src/hotspot/share/ci/ciMethodBlocks.cpp | 16 +- src/hotspot/share/ci/ciMethodData.cpp | 98 ++++---- src/hotspot/share/ci/ciMethodData.hpp | 44 ++-- src/hotspot/share/ci/ciObjArray.cpp | 4 +- src/hotspot/share/ci/ciObjArrayKlass.cpp | 14 +- src/hotspot/share/ci/ciObject.cpp | 30 +-- src/hotspot/share/ci/ciObject.hpp | 6 +- src/hotspot/share/ci/ciObjectFactory.cpp | 70 +++--- src/hotspot/share/ci/ciReplay.cpp | 238 +++++++++---------- src/hotspot/share/ci/ciSignature.cpp | 8 +- src/hotspot/share/ci/ciStreams.hpp | 28 +-- src/hotspot/share/ci/ciSymbol.cpp | 4 +- src/hotspot/share/ci/ciType.cpp | 4 +- src/hotspot/share/ci/ciTypeFlow.cpp | 218 ++++++++--------- src/hotspot/share/ci/ciTypeFlow.hpp | 36 +-- src/hotspot/share/ci/ciUtilities.cpp | 4 +- 36 files changed, 749 insertions(+), 749 deletions(-) diff --git a/src/hotspot/share/ci/bcEscapeAnalyzer.cpp b/src/hotspot/share/ci/bcEscapeAnalyzer.cpp index 7fd8b5c04f3..f53e9a1bb27 100644 --- a/src/hotspot/share/ci/bcEscapeAnalyzer.cpp +++ b/src/hotspot/share/ci/bcEscapeAnalyzer.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 @@ -200,7 +200,7 @@ void BCEscapeAnalyzer::set_modified(ArgumentMap vars, int offs, int size) { } bool BCEscapeAnalyzer::is_recursive_call(ciMethod* callee) { - for (BCEscapeAnalyzer* scope = this; scope != NULL; scope = scope->_parent) { + for (BCEscapeAnalyzer* scope = this; scope != nullptr; scope = scope->_parent) { if (scope->method() == callee) { return true; } @@ -296,7 +296,7 @@ void BCEscapeAnalyzer::invoke(StateInfo &state, Bytecodes::Code code, ciMethod* } // determine actual method (use CHA if necessary) - ciMethod* inline_target = NULL; + ciMethod* inline_target = nullptr; if (target->is_loaded() && klass->is_loaded() && (klass->is_initialized() || (klass->is_interface() && target->holder()->is_initialized()))) { if (code == Bytecodes::_invokestatic @@ -308,7 +308,7 @@ void BCEscapeAnalyzer::invoke(StateInfo &state, Bytecodes::Code code, ciMethod* } } - if (inline_target != NULL && !is_recursive_call(inline_target)) { + if (inline_target != nullptr && !is_recursive_call(inline_target)) { // analyze callee BCEscapeAnalyzer analyzer(inline_target, this); @@ -891,10 +891,10 @@ void BCEscapeAnalyzer::iterate_one_block(ciBlock *blk, StateInfo &state, Growabl case Bytecodes::_invokedynamic: case Bytecodes::_invokeinterface: { bool ignored_will_link; - ciSignature* declared_signature = NULL; + ciSignature* declared_signature = nullptr; ciMethod* target = s.get_method(ignored_will_link, &declared_signature); ciKlass* holder = s.get_declared_method_holder(); - assert(declared_signature != NULL, "cannot be null"); + assert(declared_signature != nullptr, "cannot be null"); // If the current bytecode has an attached appendix argument, // push an unknown object to represent that argument. (Analysis // of dynamic call sites, especially invokehandle calls, needs @@ -1105,8 +1105,8 @@ void BCEscapeAnalyzer::iterate_blocks(Arena *arena) { blockstates[i]._stack_height = 0; blockstates[i]._max_stack = stkSize; } - GrowableArray worklist(arena, numblocks / 4, 0, NULL); - GrowableArray successors(arena, 4, 0, NULL); + GrowableArray worklist(arena, numblocks / 4, 0, nullptr); + GrowableArray successors(arena, 4, 0, nullptr); _methodBlocks->clear_processed(); @@ -1439,9 +1439,9 @@ void BCEscapeAnalyzer::dump() { BCEscapeAnalyzer::BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent) : _arena(CURRENT_ENV->arena()) - , _conservative(method == NULL || !EstimateArgEscape) + , _conservative(method == nullptr || !EstimateArgEscape) , _method(method) - , _methodData(method ? method->method_data() : NULL) + , _methodData(method ? method->method_data() : nullptr) , _arg_size(method ? method->arg_size() : 0) , _arg_local(_arena) , _arg_stack(_arena) @@ -1450,9 +1450,9 @@ BCEscapeAnalyzer::BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent) , _return_allocated(false) , _allocated_escapes(false) , _unknown_modified(false) - , _dependencies(_arena, 4, 0, NULL) + , _dependencies(_arena, 4, 0, nullptr) , _parent(parent) - , _level(parent == NULL ? 0 : parent->level() + 1) { + , _level(parent == nullptr ? 0 : parent->level() + 1) { if (!_conservative) { _arg_local.clear(); _arg_stack.clear(); @@ -1461,7 +1461,7 @@ BCEscapeAnalyzer::BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent) _arg_modified = (uint *) arena->Amalloc(_arg_size * sizeof(uint)); Copy::zero_to_bytes(_arg_modified, _arg_size * sizeof(uint)); - if (methodData() == NULL) + if (methodData() == nullptr) return; if (methodData()->has_escape_info()) { TRACE_BCEA(2, tty->print_cr("[EA] Reading previous results for %s.%s", diff --git a/src/hotspot/share/ci/bcEscapeAnalyzer.hpp b/src/hotspot/share/ci/bcEscapeAnalyzer.hpp index 288a5977a16..925635f4fdc 100644 --- a/src/hotspot/share/ci/bcEscapeAnalyzer.hpp +++ b/src/hotspot/share/ci/bcEscapeAnalyzer.hpp @@ -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 @@ -105,7 +105,7 @@ class BCEscapeAnalyzer : public ArenaObj { bool contains(uint arg_set1, uint arg_set2); public: - BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent = NULL); + BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent = nullptr); // accessors ciMethod* method() const { return _method; } diff --git a/src/hotspot/share/ci/ciArray.cpp b/src/hotspot/share/ci/ciArray.cpp index 6db31f4cb88..7d7a3ddea94 100644 --- a/src/hotspot/share/ci/ciArray.cpp +++ b/src/hotspot/share/ci/ciArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -46,7 +46,7 @@ static BasicType fixup_element_type(BasicType bt) { ciConstant ciArray::element_value_impl(BasicType elembt, arrayOop ary, int index) { - if (ary == NULL) + if (ary == nullptr) return ciConstant(); assert(ary->is_array(), ""); if (index < 0 || index >= ary->length()) diff --git a/src/hotspot/share/ci/ciCallProfile.hpp b/src/hotspot/share/ci/ciCallProfile.hpp index e00a1ee6b00..76aca113169 100644 --- a/src/hotspot/share/ci/ciCallProfile.hpp +++ b/src/hotspot/share/ci/ciCallProfile.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ private: _morphism = 0; _count = -1; _receiver_count[0] = -1; - _receiver[0] = NULL; + _receiver[0] = nullptr; } void add_receiver(ciKlass* receiver, int receiver_count); diff --git a/src/hotspot/share/ci/ciConstantPoolCache.cpp b/src/hotspot/share/ci/ciConstantPoolCache.cpp index 2e73ee8b3fe..8dc9cfc75e1 100644 --- a/src/hotspot/share/ci/ciConstantPoolCache.cpp +++ b/src/hotspot/share/ci/ciConstantPoolCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -57,7 +57,7 @@ void* ciConstantPoolCache::get(int index) { int pos = _keys->find_sorted(index, found); if (!found) { // This element is not present in the cache. - return NULL; + return nullptr; } return _elements->at(pos); } diff --git a/src/hotspot/share/ci/ciEnv.cpp b/src/hotspot/share/ci/ciEnv.cpp index b1884563cc9..08a1026c86e 100644 --- a/src/hotspot/share/ci/ciEnv.cpp +++ b/src/hotspot/share/ci/ciEnv.cpp @@ -91,17 +91,17 @@ ciObject* ciEnv::_null_object_instance; -#define VM_CLASS_DEFN(name, ignore_s) ciInstanceKlass* ciEnv::_##name = NULL; +#define VM_CLASS_DEFN(name, ignore_s) ciInstanceKlass* ciEnv::_##name = nullptr; VM_CLASSES_DO(VM_CLASS_DEFN) #undef VM_CLASS_DEFN -ciSymbol* ciEnv::_unloaded_cisymbol = NULL; -ciInstanceKlass* ciEnv::_unloaded_ciinstance_klass = NULL; -ciObjArrayKlass* ciEnv::_unloaded_ciobjarrayklass = NULL; +ciSymbol* ciEnv::_unloaded_cisymbol = nullptr; +ciInstanceKlass* ciEnv::_unloaded_ciinstance_klass = nullptr; +ciObjArrayKlass* ciEnv::_unloaded_ciobjarrayklass = nullptr; -jobject ciEnv::_ArrayIndexOutOfBoundsException_handle = NULL; -jobject ciEnv::_ArrayStoreException_handle = NULL; -jobject ciEnv::_ClassCastException_handle = NULL; +jobject ciEnv::_ArrayIndexOutOfBoundsException_handle = nullptr; +jobject ciEnv::_ArrayStoreException_handle = nullptr; +jobject ciEnv::_ClassCastException_handle = nullptr; #ifndef PRODUCT static bool firstEnv = true; @@ -117,28 +117,28 @@ ciEnv::ciEnv(CompileTask* task) thread->set_env(this); assert(ciEnv::current() == this, "sanity"); - _oop_recorder = NULL; - _debug_info = NULL; - _dependencies = NULL; - _failure_reason = NULL; + _oop_recorder = nullptr; + _debug_info = nullptr; + _dependencies = nullptr; + _failure_reason = nullptr; _inc_decompile_count_on_failure = true; _compilable = MethodCompilable; _break_at_compile = false; - _compiler_data = NULL; + _compiler_data = nullptr; #ifndef PRODUCT assert(!firstEnv, "not initialized properly"); #endif /* !PRODUCT */ _num_inlined_bytecodes = 0; - assert(task == NULL || thread->task() == task, "sanity"); - if (task != NULL) { + assert(task == nullptr || thread->task() == task, "sanity"); + if (task != nullptr) { task->mark_started(os::elapsed_counter()); } _task = task; - _log = NULL; + _log = nullptr; // Temporary buffer for creating symbols and such. - _name_buffer = NULL; + _name_buffer = nullptr; _name_buffer_len = 0; _arena = &_ciEnv_arena; @@ -153,17 +153,17 @@ ciEnv::ciEnv(CompileTask* task) assert(Universe::is_fully_initialized(), "should be complete"); oop o = Universe::null_ptr_exception_instance(); - assert(o != NULL, "should have been initialized"); + assert(o != nullptr, "should have been initialized"); _NullPointerException_instance = get_object(o)->as_instance(); o = Universe::arithmetic_exception_instance(); - assert(o != NULL, "should have been initialized"); + assert(o != nullptr, "should have been initialized"); _ArithmeticException_instance = get_object(o)->as_instance(); - _ArrayIndexOutOfBoundsException_instance = NULL; - _ArrayStoreException_instance = NULL; - _ClassCastException_instance = NULL; - _the_null_string = NULL; - _the_min_jint_string = NULL; + _ArrayIndexOutOfBoundsException_instance = nullptr; + _ArrayStoreException_instance = nullptr; + _ClassCastException_instance = nullptr; + _the_null_string = nullptr; + _the_min_jint_string = nullptr; _jvmti_redefinition_count = 0; _jvmti_can_hotswap_or_post_breakpoint = false; @@ -171,8 +171,8 @@ ciEnv::ciEnv(CompileTask* task) _jvmti_can_post_on_exceptions = false; _jvmti_can_pop_frame = false; - _dyno_klasses = NULL; - _dyno_locs = NULL; + _dyno_klasses = nullptr; + _dyno_locs = nullptr; _dyno_name[0] = '\0'; } @@ -242,29 +242,29 @@ ciEnv::ciEnv(Arena* arena) : _ciEnv_arena(mtCompiler) { // Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc. CompilerThread* current_thread = CompilerThread::current(); - assert(current_thread->env() == NULL, "must be"); + assert(current_thread->env() == nullptr, "must be"); current_thread->set_env(this); assert(ciEnv::current() == this, "sanity"); - _oop_recorder = NULL; - _debug_info = NULL; - _dependencies = NULL; - _failure_reason = NULL; + _oop_recorder = nullptr; + _debug_info = nullptr; + _dependencies = nullptr; + _failure_reason = nullptr; _inc_decompile_count_on_failure = true; _compilable = MethodCompilable_never; _break_at_compile = false; - _compiler_data = NULL; + _compiler_data = nullptr; #ifndef PRODUCT assert(firstEnv, "must be first"); firstEnv = false; #endif /* !PRODUCT */ _num_inlined_bytecodes = 0; - _task = NULL; - _log = NULL; + _task = nullptr; + _log = nullptr; // Temporary buffer for creating symbols and such. - _name_buffer = NULL; + _name_buffer = nullptr; _name_buffer_len = 0; _arena = arena; @@ -278,13 +278,13 @@ ciEnv::ciEnv(Arena* arena) : _ciEnv_arena(mtCompiler) { assert(Universe::is_fully_initialized(), "must be"); - _NullPointerException_instance = NULL; - _ArithmeticException_instance = NULL; - _ArrayIndexOutOfBoundsException_instance = NULL; - _ArrayStoreException_instance = NULL; - _ClassCastException_instance = NULL; - _the_null_string = NULL; - _the_min_jint_string = NULL; + _NullPointerException_instance = nullptr; + _ArithmeticException_instance = nullptr; + _ArrayIndexOutOfBoundsException_instance = nullptr; + _ArrayStoreException_instance = nullptr; + _ClassCastException_instance = nullptr; + _the_null_string = nullptr; + _the_min_jint_string = nullptr; _jvmti_redefinition_count = 0; _jvmti_can_hotswap_or_post_breakpoint = false; @@ -292,8 +292,8 @@ ciEnv::ciEnv(Arena* arena) : _ciEnv_arena(mtCompiler) { _jvmti_can_post_on_exceptions = false; _jvmti_can_pop_frame = false; - _dyno_klasses = NULL; - _dyno_locs = NULL; + _dyno_klasses = nullptr; + _dyno_locs = nullptr; } ciEnv::~ciEnv() { @@ -302,7 +302,7 @@ ciEnv::~ciEnv() { _factory->remove_symbols(); // Need safepoint to clear the env on the thread. RedefineClasses might // be reading it. - current_thread->set_env(NULL); + current_thread->set_env(nullptr); ) } @@ -319,7 +319,7 @@ bool ciEnv::cache_jvmti_state() { _jvmti_can_pop_frame = JvmtiExport::can_pop_frame(); _jvmti_can_get_owned_monitor_info = JvmtiExport::can_get_owned_monitor_info(); _jvmti_can_walk_any_space = JvmtiExport::can_walk_any_space(); - return _task != NULL && _task->method()->is_old(); + return _task != nullptr && _task->method()->is_old(); } bool ciEnv::jvmti_state_changed() const { @@ -368,11 +368,11 @@ void ciEnv::cache_dtrace_flags() { // helper for lazy exception creation ciInstance* ciEnv::get_or_create_exception(jobject& handle, Symbol* name) { VM_ENTRY_MARK; - if (handle == NULL) { + if (handle == nullptr) { // Cf. universe.cpp, creation of Universe::_null_ptr_exception_instance. InstanceKlass* ik = SystemDictionary::find_instance_klass(THREAD, name, Handle(), Handle()); - jobject objh = NULL; - if (ik != NULL) { + jobject objh = nullptr; + if (ik != nullptr) { oop obj = ik->allocate_instance(THREAD); if (!HAS_PENDING_EXCEPTION) objh = JNIHandles::make_global(Handle(THREAD, obj)); @@ -384,7 +384,7 @@ ciInstance* ciEnv::get_or_create_exception(jobject& handle, Symbol* name) { } } oop obj = JNIHandles::resolve(handle); - return obj == NULL? NULL: get_object(obj)->as_instance(); + return obj == nullptr? nullptr: get_object(obj)->as_instance(); } ciInstanceKlass* ciEnv::get_box_klass_for_primitive_type(BasicType type) { @@ -400,12 +400,12 @@ ciInstanceKlass* ciEnv::get_box_klass_for_primitive_type(BasicType type) { default: assert(false, "not a primitive: %s", type2name(type)); - return NULL; + return nullptr; } } ciInstance* ciEnv::ArrayIndexOutOfBoundsException_instance() { - if (_ArrayIndexOutOfBoundsException_instance == NULL) { + if (_ArrayIndexOutOfBoundsException_instance == nullptr) { _ArrayIndexOutOfBoundsException_instance = get_or_create_exception(_ArrayIndexOutOfBoundsException_handle, vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); @@ -413,7 +413,7 @@ ciInstance* ciEnv::ArrayIndexOutOfBoundsException_instance() { return _ArrayIndexOutOfBoundsException_instance; } ciInstance* ciEnv::ArrayStoreException_instance() { - if (_ArrayStoreException_instance == NULL) { + if (_ArrayStoreException_instance == nullptr) { _ArrayStoreException_instance = get_or_create_exception(_ArrayStoreException_handle, vmSymbols::java_lang_ArrayStoreException()); @@ -421,7 +421,7 @@ ciInstance* ciEnv::ArrayStoreException_instance() { return _ArrayStoreException_instance; } ciInstance* ciEnv::ClassCastException_instance() { - if (_ClassCastException_instance == NULL) { + if (_ClassCastException_instance == nullptr) { _ClassCastException_instance = get_or_create_exception(_ClassCastException_handle, vmSymbols::java_lang_ClassCastException()); @@ -430,7 +430,7 @@ ciInstance* ciEnv::ClassCastException_instance() { } ciInstance* ciEnv::the_null_string() { - if (_the_null_string == NULL) { + if (_the_null_string == nullptr) { VM_ENTRY_MARK; _the_null_string = get_object(Universe::the_null_string())->as_instance(); } @@ -438,7 +438,7 @@ ciInstance* ciEnv::the_null_string() { } ciInstance* ciEnv::the_min_jint_string() { - if (_the_min_jint_string == NULL) { + if (_the_min_jint_string == nullptr) { VM_ENTRY_MARK; _the_min_jint_string = get_object(Universe::the_min_jint_string())->as_instance(); } @@ -459,7 +459,7 @@ ciMethod* ciEnv::get_method_from_handle(Method* method) { // ConstantPool::verify_constant_pool_resolve. bool ciEnv::check_klass_accessibility(ciKlass* accessing_klass, Klass* resolved_klass) { - if (accessing_klass == NULL || !accessing_klass->is_loaded()) { + if (accessing_klass == nullptr || !accessing_klass->is_loaded()) { return true; } if (accessing_klass->is_obj_array_klass()) { @@ -503,14 +503,14 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass, // Check for prior unloaded klass. The SystemDictionary's answers // can vary over time but the compiler needs consistency. ciKlass* unloaded_klass = check_get_unloaded_klass(accessing_klass, name); - if (unloaded_klass != NULL) { - if (require_local) return NULL; + if (unloaded_klass != nullptr) { + if (require_local) return nullptr; return unloaded_klass; } Handle loader; Handle domain; - if (accessing_klass != NULL) { + if (accessing_klass != nullptr) { loader = Handle(current, accessing_klass->loader()); domain = Handle(current, accessing_klass->protection_domain()); } @@ -546,13 +546,13 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass, cpool, get_symbol(ss.as_symbol()), require_local); - if (elem_klass != NULL && elem_klass->is_loaded()) { + if (elem_klass != nullptr && elem_klass->is_loaded()) { // Now make an array for it return ciObjArrayKlass::make_impl(elem_klass); } } - if (found_klass == NULL && !cpool.is_null() && cpool->has_preresolution()) { + if (found_klass == nullptr && !cpool.is_null() && cpool->has_preresolution()) { // Look inside the constant pool for pre-resolved class entries. for (int i = cpool->length() - 1; i >= 1; i--) { if (cpool->tag_at(i).is_klass()) { @@ -565,12 +565,12 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass, } } - if (found_klass != NULL) { + if (found_klass != nullptr) { // Found it. Build a CI handle. return get_klass(found_klass); } - if (require_local) return NULL; + if (require_local) return nullptr; // Not yet loaded into the VM, or not governed by loader constraints. // Make a CI representative for it. @@ -596,8 +596,8 @@ ciKlass* ciEnv::get_klass_by_index_impl(const constantPoolHandle& cpool, int index, bool& is_accessible, ciInstanceKlass* accessor) { - Klass* klass = NULL; - Symbol* klass_name = NULL; + Klass* klass = nullptr; + Symbol* klass_name = nullptr; if (cpool->tag_at(index).is_symbol()) { klass_name = cpool->symbol_at(index); @@ -605,12 +605,12 @@ ciKlass* ciEnv::get_klass_by_index_impl(const constantPoolHandle& cpool, // Check if it's resolved if it's not a symbol constant pool entry. klass = ConstantPool::klass_at_if_loaded(cpool, index); // Try to look it up by name. - if (klass == NULL) { + if (klass == nullptr) { klass_name = cpool->klass_name_at(index); } } - if (klass == NULL) { + if (klass == nullptr) { // Not found in constant pool. Use the name to do the lookup. ciKlass* k = get_klass_by_name_impl(accessor, cpool, @@ -620,7 +620,7 @@ ciKlass* ciEnv::get_klass_by_index_impl(const constantPoolHandle& cpool, if (!k->is_loaded()) { is_accessible = false; } else if (k->loader() != accessor->loader() && - get_klass_by_name_impl(accessor, cpool, k->name(), true) == NULL) { + get_klass_by_name_impl(accessor, cpool, k->name(), true) == nullptr) { // Loaded only remotely. Not linked yet. is_accessible = false; } else { @@ -634,7 +634,7 @@ ciKlass* ciEnv::get_klass_by_index_impl(const constantPoolHandle& cpool, // can vary over time but the compiler needs consistency. ciSymbol* name = get_symbol(klass->name()); ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name); - if (unloaded_klass != NULL) { + if (unloaded_klass != nullptr) { is_accessible = false; return unloaded_klass; } @@ -693,12 +693,12 @@ ciConstant ciEnv::unbox_primitive_value(ciObject* cibox, BasicType expected_bt) ciConstant ciEnv::get_resolved_constant(const constantPoolHandle& cpool, int obj_index) { assert(obj_index >= 0, ""); oop obj = cpool->resolved_reference_at(obj_index); - if (obj == NULL) { + if (obj == nullptr) { // Unresolved constant. It is resolved when the corresponding slot contains a non-null reference. // Null constant is represented as a sentinel (non-null) value. return ciConstant(); } else if (obj == Universe::the_null_sentinel()) { - return ciConstant(T_OBJECT, get_object(NULL)); + return ciConstant(T_OBJECT, get_object(nullptr)); } else { ciObject* ciobj = get_object(obj); if (ciobj->is_array()) { @@ -751,7 +751,7 @@ ciConstant ciEnv::get_constant_by_index_impl(const constantPoolHandle& cpool, ciInstance* constant = get_object(string)->as_instance(); return ciConstant(T_OBJECT, constant); } else if (tag.is_unresolved_klass_in_error()) { - return ciConstant(T_OBJECT, get_unloaded_klass_mirror(NULL)); + return ciConstant(T_OBJECT, get_unloaded_klass_mirror(nullptr)); } else if (tag.is_klass() || tag.is_unresolved_klass()) { bool will_link; ciKlass* klass = get_klass_by_index_impl(cpool, index, will_link, accessor); @@ -805,12 +805,12 @@ ciConstant ciEnv::get_constant_by_index(const constantPoolHandle& cpool, ciField* ciEnv::get_field_by_index_impl(ciInstanceKlass* accessor, int index) { ciConstantPoolCache* cache = accessor->field_cache(); - if (cache == NULL) { + if (cache == nullptr) { ciField* field = new (arena()) ciField(accessor, index); return field; } else { ciField* field = (ciField*)cache->get(index); - if (field == NULL) { + if (field == nullptr) { field = new (arena()) ciField(accessor, index); cache->insert(index, field); } @@ -859,7 +859,7 @@ Method* ciEnv::lookup_method(ciInstanceKlass* accessor, return LinkResolver::linktime_resolve_virtual_method_or_null(link_info); default: fatal("Unhandled bytecode: %s", Bytecodes::name(bc)); - return NULL; // silence compiler warnings + return nullptr; // silence compiler warnings } } @@ -870,7 +870,7 @@ ciMethod* ciEnv::get_method_by_index_impl(const constantPoolHandle& cpool, int index, Bytecodes::Code bc, ciInstanceKlass* accessor) { assert(cpool.not_null(), "need constant pool"); - assert(accessor != NULL, "need origin of access"); + assert(accessor != nullptr, "need origin of access"); if (bc == Bytecodes::_invokedynamic) { ConstantPoolCacheEntry* cpce = cpool->invokedynamic_cp_cache_entry_at(index); bool is_resolved = !cpce->is_f1_null(); @@ -916,7 +916,7 @@ ciMethod* ciEnv::get_method_by_index_impl(const constantPoolHandle& cpool, case Bytecodes::_invokestatic: { Method* m = ConstantPool::method_at_if_loaded(cpool, index); - if (m != NULL) { + if (m != nullptr) { return get_method(m); } } @@ -930,16 +930,16 @@ ciMethod* ciEnv::get_method_by_index_impl(const constantPoolHandle& cpool, constantTag tag = cpool->tag_ref_at(index); assert(accessor->get_instanceKlass() == cpool->pool_holder(), "not the pool holder?"); Method* m = lookup_method(accessor, holder, name_sym, sig_sym, bc, tag); - if (m != NULL && + if (m != nullptr && (bc == Bytecodes::_invokestatic ? m->method_holder()->is_not_initialized() : !m->method_holder()->is_loaded())) { - m = NULL; + m = nullptr; } - if (m != NULL && ReplayCompiles && !ciReplay::is_loaded(m)) { - m = NULL; + if (m != nullptr && ReplayCompiles && !ciReplay::is_loaded(m)) { + m = nullptr; } - if (m != NULL) { + if (m != nullptr) { // We found the method. return get_method(m); } @@ -966,7 +966,7 @@ ciInstanceKlass* ciEnv::get_instance_klass_for_declared_method_holder(ciKlass* m // require checks to make sure the expected type was found. Given that this // only occurs for clone() the more extensive fix seems like overkill so // instead we simply smear the array type into Object. - guarantee(method_holder != NULL, "no method holder"); + guarantee(method_holder != nullptr, "no method holder"); if (method_holder->is_instance_klass()) { return method_holder->as_instance_klass(); } else if (method_holder->is_array_klass()) { @@ -974,7 +974,7 @@ ciInstanceKlass* ciEnv::get_instance_klass_for_declared_method_holder(ciKlass* m } else { ShouldNotReachHere(); } - return NULL; + return nullptr; } @@ -991,7 +991,7 @@ ciMethod* ciEnv::get_method_by_index(const constantPoolHandle& cpool, // ciEnv::name_buffer char *ciEnv::name_buffer(int req_len) { if (_name_buffer_len < req_len) { - if (_name_buffer == NULL) { + if (_name_buffer == nullptr) { _name_buffer = (char*)arena()->Amalloc(sizeof(char)*req_len); _name_buffer_len = req_len; } else { @@ -1048,12 +1048,12 @@ void ciEnv::register_method(ciMethod* target, int immediate_oops_patched, RTMState rtm_state) { VM_ENTRY_MARK; - nmethod* nm = NULL; + nmethod* nm = nullptr; { methodHandle method(THREAD, target->get_Method()); // We require method counters to store some method state (max compilation levels) required by the compilation policy. - if (method->get_method_counters(THREAD) == NULL) { + if (method->get_method_counters(THREAD) == nullptr) { record_failure("can't create method counters"); // All buffers in the CodeBuffer are allocated in the CodeCache. // If the code buffer is created on each compile attempt @@ -1092,7 +1092,7 @@ void ciEnv::register_method(ciMethod* target, } if (!failing()) { - if (log() != NULL) { + if (log() != nullptr) { // Log the dependencies which this compilation declares. dependencies()->log_all_dependencies(); } @@ -1105,7 +1105,7 @@ void ciEnv::register_method(ciMethod* target, } #if INCLUDE_RTM_OPT if (!failing() && (rtm_state != NoRTM) && - (method()->method_data() != NULL) && + (method()->method_data() != nullptr) && (method()->method_data()->rtm_state() != rtm_state)) { // Preemptive decompile if rtm state was changed. record_failure("RTM state change invalidated rtm code"); @@ -1119,7 +1119,7 @@ void ciEnv::register_method(ciMethod* target, if (failing()) { // While not a true deoptimization, it is a preemptive decompile. MethodData* mdo = method()->method_data(); - if (mdo != NULL && _inc_decompile_count_on_failure) { + if (mdo != nullptr && _inc_decompile_count_on_failure) { mdo->inc_decompile_count(); } @@ -1146,7 +1146,7 @@ void ciEnv::register_method(ciMethod* target, // Free codeBlobs code_buffer->free_blob(); - if (nm != NULL) { + if (nm != nullptr) { nm->set_has_unsafe_access(has_unsafe_access); nm->set_has_wide_vectors(has_wide_vectors); nm->set_has_monitors(has_monitors); @@ -1159,12 +1159,12 @@ void ciEnv::register_method(ciMethod* target, if (TieredCompilation) { // If there is an old version we're done with it CompiledMethod* old = method->code(); - if (TraceMethodReplacement && old != NULL) { + if (TraceMethodReplacement && old != nullptr) { ResourceMark rm; char *method_name = method->name_and_sig_as_C_string(); tty->print_cr("Replacing method %s", method_name); } - if (old != NULL) { + if (old != nullptr) { old->make_not_used(); } } @@ -1198,7 +1198,7 @@ void ciEnv::register_method(ciMethod* target, } NoSafepointVerifier nsv; - if (nm != NULL) { + if (nm != nullptr) { // Compilation succeeded, post what we know about it nm->post_compiled_method(task()); task()->set_num_inlined_bytecodes(num_inlined_bytecodes()); @@ -1214,20 +1214,20 @@ void ciEnv::register_method(ciMethod* target, // ciEnv::find_system_klass ciKlass* ciEnv::find_system_klass(ciSymbol* klass_name) { VM_ENTRY_MARK; - return get_klass_by_name_impl(NULL, constantPoolHandle(), klass_name, false); + return get_klass_by_name_impl(nullptr, constantPoolHandle(), klass_name, false); } // ------------------------------------------------------------------ // ciEnv::comp_level int ciEnv::comp_level() { - if (task() == NULL) return CompilationPolicy::highest_compile_level(); + if (task() == nullptr) return CompilationPolicy::highest_compile_level(); return task()->comp_level(); } // ------------------------------------------------------------------ // ciEnv::compile_id int ciEnv::compile_id() { - if (task() == NULL) return 0; + if (task() == nullptr) return 0; return task()->compile_id(); } @@ -1246,7 +1246,7 @@ int ciEnv::num_inlined_bytecodes() const { // ------------------------------------------------------------------ // ciEnv::record_failure() void ciEnv::record_failure(const char* reason) { - if (_failure_reason == NULL) { + if (_failure_reason == nullptr) { // Record the first failure reason. _failure_reason = reason; } @@ -1267,7 +1267,7 @@ void ciEnv::record_method_not_compilable(const char* reason, bool all_tiers) { // Only note transitions to a worse state if (new_compilable > _compilable) { - if (log() != NULL) { + if (log() != nullptr) { if (all_tiers) { log()->elem("method_not_compilable"); } else { @@ -1278,7 +1278,7 @@ void ciEnv::record_method_not_compilable(const char* reason, bool all_tiers) { _compilable = new_compilable; // Reset failure reason; this one is more important. - _failure_reason = NULL; + _failure_reason = nullptr; record_failure(reason); } } @@ -1354,7 +1354,7 @@ bool ciEnv::print_dyno_loc(outputStream* out, const InstanceKlass* ik) const { } // Look up the location descriptor for the given class and return it as a string. -// Returns NULL if no location is found. +// Returns null if no location is found. const char *ciEnv::dyno_name(const InstanceKlass* ik) const { if (ik->is_hidden()) { stringStream ss; @@ -1364,7 +1364,7 @@ const char *ciEnv::dyno_name(const InstanceKlass* ik) const { return call_site; } } - return NULL; + return nullptr; } // Look up the location descriptor for the given class and return it as a string. @@ -1380,7 +1380,7 @@ const char *ciEnv::replay_name(ciKlass* k) const { // Returns the class name as a fallback if no location is found. const char *ciEnv::replay_name(const InstanceKlass* ik) const { const char* name = dyno_name(ik); - if (name != NULL) { + if (name != nullptr) { return name; } return ik->name()->as_quoted_ascii(); @@ -1398,7 +1398,7 @@ void ciEnv::record_member(Thread* thread, oop member) { } // Check MemberName.method.vmtarget field Method* vmtarget = java_lang_invoke_MemberName::vmtarget(member); - if (vmtarget != NULL) { + if (vmtarget != nullptr) { RecordLocation fp2(this, ""); InstanceKlass* ik = vmtarget->method_holder(); record_best_dyno_loc(ik); @@ -1423,7 +1423,7 @@ void ciEnv::record_lambdaform(Thread* thread, oop form) { // Check LambdaForm.names array objArrayOop names = (objArrayOop)obj_field(form, "names"); - if (names != NULL) { + if (names != nullptr) { RecordLocation lp0(this, "names"); int len = names->length(); for (int i = 0; i < len; ++i) { @@ -1432,22 +1432,22 @@ void ciEnv::record_lambdaform(Thread* thread, oop form) { // Check LambdaForm.names[i].function field RecordLocation lp2(this, "function"); oop function = obj_field(name, "function"); - if (function != NULL) { + if (function != nullptr) { // Check LambdaForm.names[i].function.member field oop member = obj_field(function, "member"); - if (member != NULL) { + if (member != nullptr) { RecordLocation lp3(this, "member"); record_member(thread, member); } // Check LambdaForm.names[i].function.resolvedHandle field oop mh = obj_field(function, "resolvedHandle"); - if (mh != NULL) { + if (mh != nullptr) { RecordLocation lp3(this, "resolvedHandle"); record_mh(thread, mh); } // Check LambdaForm.names[i].function.invoker field oop invoker = obj_field(function, "invoker"); - if (invoker != NULL) { + if (invoker != nullptr) { RecordLocation lp3(this, "invoker"); record_mh(thread, invoker); } @@ -1477,7 +1477,7 @@ void ciEnv::record_mh(Thread* thread, oop mh) { for (int index = 0; index <= max_arg; ++index) { jio_snprintf(arg_name, sizeof (arg_name), "argL%d", index); oop arg = obj_field(mh, arg_name); - if (arg != NULL) { + if (arg != nullptr) { RecordLocation fp(this, "%s", arg_name); if (arg->klass()->is_instance_klass()) { InstanceKlass* ik2 = InstanceKlass::cast(arg->klass()); @@ -1496,7 +1496,7 @@ void ciEnv::record_mh(Thread* thread, oop mh) { // The object is typically the "appendix" object, or Bootstrap Method (BSM) object. void ciEnv::record_call_site_obj(Thread* thread, oop obj) { - if (obj != NULL) { + if (obj != nullptr) { if (java_lang_invoke_MethodHandle::is_instance(obj)) { record_mh(thread, obj); } else if (java_lang_invoke_ConstantCallSite::is_instance(obj)) { @@ -1571,8 +1571,8 @@ void ciEnv::process_invokehandle(const constantPoolHandle &cp, int index, JavaTh // Search the class hierarchy for dynamic classes reachable through dynamic call sites or // constant pool entries and record for future lookup. void ciEnv::find_dynamic_call_sites() { - _dyno_klasses = new (arena()) GrowableArray(arena(), 100, 0, NULL); - _dyno_locs = new (arena()) GrowableArray(arena(), 100, 0, NULL); + _dyno_klasses = new (arena()) GrowableArray(arena(), 100, 0, nullptr); + _dyno_locs = new (arena()) GrowableArray(arena(), 100, 0, nullptr); // Iterate over the class hierarchy for (ClassHierarchyIterator iter(vmClasses::Object_klass()); !iter.done(); iter.next()) { @@ -1627,7 +1627,7 @@ void ciEnv::find_dynamic_call_sites() { if (pool->tag_at(i).is_method_handle()) { bool found_it; oop mh = pool->find_cached_constant_at(i, found_it, thread); - if (mh != NULL) { + if (mh != nullptr) { RecordLocation fp(this, "%d", i); record_mh(thread, mh); } @@ -1641,7 +1641,7 @@ void ciEnv::dump_compile_data(outputStream* out) { CompileTask* task = this->task(); if (task) { #ifdef COMPILER2 - if (ReplayReduce && compiler_data() != NULL) { + if (ReplayReduce && compiler_data() != nullptr) { // Dump C2 "reduced" inlining data. ((Compile*)compiler_data())->dump_inline_data_reduced(out); } @@ -1652,7 +1652,7 @@ void ciEnv::dump_compile_data(outputStream* out) { out->print("compile "); get_method(method)->dump_name_as_ascii(out); out->print(" %d %d", entry_bci, comp_level); - if (compiler_data() != NULL) { + if (compiler_data() != nullptr) { if (is_c2_compile(comp_level)) { #ifdef COMPILER2 // Dump C2 inlining data. @@ -1722,7 +1722,7 @@ void ciEnv::dump_replay_data(int compile_id) { int fd = os::open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666); if (fd != -1) { FILE* replay_data_file = os::fdopen(fd, "w"); - if (replay_data_file != NULL) { + if (replay_data_file != nullptr) { fileStream replay_data_stream(replay_data_file, /*need_close=*/true); dump_replay_data(&replay_data_stream); tty->print_cr("# Compiler replay data is saved as: %s", buffer); @@ -1740,7 +1740,7 @@ void ciEnv::dump_inline_data(int compile_id) { int fd = os::open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666); if (fd != -1) { FILE* inline_data_file = os::fdopen(fd, "w"); - if (inline_data_file != NULL) { + if (inline_data_file != nullptr) { fileStream replay_data_stream(inline_data_file, /*need_close=*/true); GUARDED_VM_ENTRY( MutexLocker ml(Compile_lock); diff --git a/src/hotspot/share/ci/ciEnv.hpp b/src/hotspot/share/ci/ciEnv.hpp index 21b442b6e05..8eb47e8cf82 100644 --- a/src/hotspot/share/ci/ciEnv.hpp +++ b/src/hotspot/share/ci/ciEnv.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -107,7 +107,7 @@ private: ciInstance* _the_min_jint_string; // The Java string "-2147483648" // Look up a klass by name from a particular class loader (the accessor's). - // If require_local, result must be defined in that class loader, or NULL. + // If require_local, result must be defined in that class loader, or null. // If !require_local, a result from remote class loader may be reported, // if sufficient class loader constraints exist such that initiating // a class loading request from the given loader is bound to return @@ -170,7 +170,7 @@ private: // Get a ciObject from the object factory. Ensures uniqueness // of ciObjects. ciObject* get_object(oop o) { - if (o == NULL) { + if (o == nullptr) { return _null_object_instance; } else { return _factory->get(o); @@ -178,17 +178,17 @@ private: } ciSymbol* get_symbol(Symbol* o) { - if (o == NULL) { + if (o == nullptr) { ShouldNotReachHere(); - return NULL; + return nullptr; } else { return _factory->get_symbol(o); } } ciMetadata* get_metadata(Metadata* o) { - if (o == NULL) { - return NULL; + if (o == nullptr) { + return nullptr; } else { return _factory->get_metadata(o); } @@ -199,31 +199,31 @@ private: } ciInstance* get_instance(oop o) { - if (o == NULL) return NULL; + if (o == nullptr) return nullptr; return get_object(o)->as_instance(); } ciObjArrayKlass* get_obj_array_klass(Klass* o) { - if (o == NULL) return NULL; + if (o == nullptr) return nullptr; return get_metadata(o)->as_obj_array_klass(); } ciTypeArrayKlass* get_type_array_klass(Klass* o) { - if (o == NULL) return NULL; + if (o == nullptr) return nullptr; return get_metadata(o)->as_type_array_klass(); } ciKlass* get_klass(Klass* o) { - if (o == NULL) return NULL; + if (o == nullptr) return nullptr; return get_metadata(o)->as_klass(); } ciInstanceKlass* get_instance_klass(Klass* o) { - if (o == NULL) return NULL; + if (o == nullptr) return nullptr; return get_metadata(o)->as_instance_klass(); } ciMethod* get_method(Method* o) { - if (o == NULL) return NULL; + if (o == nullptr) return nullptr; return get_metadata(o)->as_method(); } ciMethodData* get_method_data(MethodData* o) { - if (o == NULL) return NULL; + if (o == nullptr) return nullptr; return get_metadata(o)->as_method_data(); } @@ -269,7 +269,7 @@ private: } // See if we already have an unloaded klass for the given name - // or return NULL if not. + // or return null if not. ciKlass *check_get_unloaded_klass(ciKlass* accessing_klass, ciSymbol* name) { return _factory->get_unloaded_klass(accessing_klass, name, false); } @@ -319,7 +319,7 @@ public: // This is true if the compilation is not going to produce code. // (It is reasonable to retry failed compilations.) - bool failing() { return _failure_reason != NULL; } + bool failing() { return _failure_reason != nullptr; } // Reason this compilation is failing, such as "too many basic blocks". const char* failure_reason() { return _failure_reason; } @@ -334,10 +334,10 @@ public: case ciEnv::MethodCompilable_never: return "not retryable"; case ciEnv::MethodCompilable: - return NULL; + return nullptr; default: ShouldNotReachHere(); - return NULL; + return nullptr; } } @@ -394,11 +394,11 @@ public: #undef VM_CLASS_FUNC ciInstance* NullPointerException_instance() { - assert(_NullPointerException_instance != NULL, "initialization problem"); + assert(_NullPointerException_instance != nullptr, "initialization problem"); return _NullPointerException_instance; } ciInstance* ArithmeticException_instance() { - assert(_ArithmeticException_instance != NULL, "initialization problem"); + assert(_ArithmeticException_instance != nullptr, "initialization problem"); return _ArithmeticException_instance; } diff --git a/src/hotspot/share/ci/ciExceptionHandler.cpp b/src/hotspot/share/ci/ciExceptionHandler.cpp index c83305a05ba..6c30e715965 100644 --- a/src/hotspot/share/ci/ciExceptionHandler.cpp +++ b/src/hotspot/share/ci/ciExceptionHandler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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,7 +38,7 @@ ciInstanceKlass* ciExceptionHandler::catch_klass() { VM_ENTRY_MARK; assert(!is_catch_all(), "bad index"); - if (_catch_klass == NULL) { + if (_catch_klass == nullptr) { bool will_link; assert(_loading_klass->get_instanceKlass()->is_linked(), "must be linked before accessing constant pool"); constantPoolHandle cpool(THREAD, _loading_klass->get_instanceKlass()->constants()); @@ -62,7 +62,7 @@ void ciExceptionHandler::print() { tty->print("print(" ex_klass="); _catch_klass->print(); } diff --git a/src/hotspot/share/ci/ciExceptionHandler.hpp b/src/hotspot/share/ci/ciExceptionHandler.hpp index 291adf3ac9e..9240ca2e6b3 100644 --- a/src/hotspot/share/ci/ciExceptionHandler.hpp +++ b/src/hotspot/share/ci/ciExceptionHandler.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -57,7 +57,7 @@ public: _limit = limit; _handler_bci = handler_bci; _catch_klass_index = klass_index; - _catch_klass = NULL; + _catch_klass = nullptr; } int start() { return _start; } diff --git a/src/hotspot/share/ci/ciField.cpp b/src/hotspot/share/ci/ciField.cpp index 24bf59dcb91..9fbe4af64bd 100644 --- a/src/hotspot/share/ci/ciField.cpp +++ b/src/hotspot/share/ci/ciField.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -44,7 +44,7 @@ // the ciField will be incomplete. // The ciObjectFactory cannot create circular data structures in one query. -// To avoid vicious circularities, we initialize ciField::_type to NULL +// To avoid vicious circularities, we initialize ciField::_type to null // for reference types and derive it lazily from the ciField::_signature. // Primitive types are eagerly initialized, and basic layout queries // can succeed without initialization, using only the BasicType of the field. @@ -71,7 +71,7 @@ // ------------------------------------------------------------------ // ciField::ciField ciField::ciField(ciInstanceKlass* klass, int index) : - _known_to_link_with_put(NULL), _known_to_link_with_get(NULL) { + _known_to_link_with_put(nullptr), _known_to_link_with_get(nullptr) { ASSERT_IN_VM; CompilerThread *THREAD = CompilerThread::current(); @@ -155,7 +155,7 @@ ciField::ciField(ciInstanceKlass* klass, int index) : fieldDescriptor field_desc; Klass* canonical_holder = loaded_decl_holder->find_field(name, signature, &field_desc); - if (canonical_holder == NULL) { + if (canonical_holder == nullptr) { // Field lookup failed. Will be detected by will_link. _holder = declared_holder; _offset = -1; @@ -191,7 +191,7 @@ ciField::ciField(ciInstanceKlass* klass, int index) : } ciField::ciField(fieldDescriptor *fd) : - _known_to_link_with_put(NULL), _known_to_link_with_get(NULL) { + _known_to_link_with_put(nullptr), _known_to_link_with_get(nullptr) { ASSERT_IN_VM; // Get the field's name, signature, and type. @@ -204,7 +204,7 @@ ciField::ciField(fieldDescriptor *fd) : // If the field is a pointer type, get the klass of the // field. if (is_reference_type(field_type)) { - _type = NULL; // must call compute_type on first access + _type = nullptr; // must call compute_type on first access } else { _type = ciType::make(field_type); } @@ -217,7 +217,7 @@ ciField::ciField(fieldDescriptor *fd) : } static bool trust_final_non_static_fields(ciInstanceKlass* holder) { - if (holder == NULL) + if (holder == nullptr) return false; if (holder->name() == ciSymbols::java_lang_System()) // Never trust strangely unstable finals: System.out, etc. @@ -258,7 +258,7 @@ void ciField::initialize_from(fieldDescriptor* fd) { _flags = ciFlags(fd->access_flags()); _offset = fd->offset(); Klass* field_holder = fd->field_holder(); - assert(field_holder != NULL, "null field_holder"); + assert(field_holder != nullptr, "null field_holder"); _holder = CURRENT_ENV->get_instance_klass(field_holder); // Check to see if the field is constant. @@ -270,7 +270,7 @@ void ciField::initialize_from(fieldDescriptor* fd) { // not be constant is when the field is a *special* static & final field // whose value may change. The three examples are java.lang.System.in, // java.lang.System.out, and java.lang.System.err. - assert(vmClasses::System_klass() != NULL, "Check once per vm"); + assert(vmClasses::System_klass() != nullptr, "Check once per vm"); if (k == vmClasses::System_klass()) { // Check offsets for case 2: System.in, System.out, or System.err if (_offset == java_lang_System::in_offset() || @@ -289,7 +289,7 @@ void ciField::initialize_from(fieldDescriptor* fd) { } } else { // For CallSite objects treat the target field as a compile time constant. - assert(vmClasses::CallSite_klass() != NULL, "should be already initialized"); + assert(vmClasses::CallSite_klass() != nullptr, "should be already initialized"); if (k == vmClasses::CallSite_klass() && _offset == java_lang_invoke_CallSite::target_offset()) { assert(!has_initialized_final_update(), "CallSite is not supposed to have writes to final fields outside initializers"); @@ -420,7 +420,7 @@ bool ciField::will_link(ciMethod* accessing_method, bool ciField::is_call_site_target() { ciInstanceKlass* callsite_klass = CURRENT_ENV->CallSite_klass(); - if (callsite_klass == NULL) + if (callsite_klass == nullptr) return false; return (holder()->is_subclass_of(callsite_klass) && (name() == ciSymbols::target_name())); } @@ -446,7 +446,7 @@ void ciField::print() { tty->print(" signature="); _signature->print_symbol(); tty->print(" offset=%d type=", _offset); - if (_type != NULL) + if (_type != nullptr) _type->print_name(); else tty->print("(reference)"); diff --git a/src/hotspot/share/ci/ciField.hpp b/src/hotspot/share/ci/ciField.hpp index 4442afc85a4..3055f1460e5 100644 --- a/src/hotspot/share/ci/ciField.hpp +++ b/src/hotspot/share/ci/ciField.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -99,10 +99,10 @@ public: ciSymbol* signature() const { return _signature; } // Of what type is this field? - ciType* type() { return (_type == NULL) ? compute_type() : _type; } + ciType* type() { return (_type == nullptr) ? compute_type() : _type; } // How is this field actually stored in memory? - BasicType layout_type() { return type2field[(_type == NULL) ? T_OBJECT : _type->basic_type()]; } + BasicType layout_type() { return type2field[(_type == nullptr) ? T_OBJECT : _type->basic_type()]; } // How big is this field in memory? int size_in_bytes() { return type2aelembytes(layout_type()); } diff --git a/src/hotspot/share/ci/ciInstance.cpp b/src/hotspot/share/ci/ciInstance.cpp index cb014ea00f0..66175623665 100644 --- a/src/hotspot/share/ci/ciInstance.cpp +++ b/src/hotspot/share/ci/ciInstance.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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,16 +42,16 @@ ciType* ciInstance::java_mirror_type() { VM_ENTRY_MARK; oop m = get_oop(); - // Return NULL if it is not java.lang.Class. - if (m == NULL || m->klass() != vmClasses::Class_klass()) { - return NULL; + // Return null if it is not java.lang.Class. + if (m == nullptr || m->klass() != vmClasses::Class_klass()) { + return nullptr; } // Return either a primitive type or a klass. if (java_lang_Class::is_primitive(m)) { return ciType::make(java_lang_Class::primitive_type(m)); } else { Klass* k = java_lang_Class::as_Klass(m); - assert(k != NULL, ""); + assert(k != nullptr, ""); return CURRENT_THREAD_ENV->get_klass(k); } } @@ -60,7 +60,7 @@ ciType* ciInstance::java_mirror_type() { // ciInstance::field_value_impl ciConstant ciInstance::field_value_impl(BasicType field_btype, int offset) { oop obj = get_oop(); - assert(obj != NULL, "bad oop"); + assert(obj != nullptr, "bad oop"); switch(field_btype) { case T_BYTE: return ciConstant(field_btype, obj->byte_field(offset)); case T_CHAR: return ciConstant(field_btype, obj->char_field(offset)); @@ -81,7 +81,7 @@ ciConstant ciInstance::field_value_impl(BasicType field_btype, int offset) { // or ciInstance is created. The compiler may be able to use // information about the object's class (which is exact) or length. - if (o == NULL) { + if (o == nullptr) { return ciConstant(field_btype, ciNullObject::make()); } else { return ciConstant(field_btype, CURRENT_ENV->get_object(o)); @@ -112,7 +112,7 @@ ciConstant ciInstance::field_value(ciField* field) { ciConstant ciInstance::field_value_by_offset(int field_offset) { ciInstanceKlass* ik = klass()->as_instance_klass(); ciField* field = ik->get_field_by_offset(field_offset, false); - if (field == NULL) + if (field == nullptr) return ciConstant(); // T_ILLEGAL return field_value(field); } diff --git a/src/hotspot/share/ci/ciInstance.hpp b/src/hotspot/share/ci/ciInstance.hpp index aa328391ad4..3af07edcd9e 100644 --- a/src/hotspot/share/ci/ciInstance.hpp +++ b/src/hotspot/share/ci/ciInstance.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ protected: public: // If this object is a java mirror, return the corresponding type. - // Otherwise, return NULL. + // Otherwise, return null. // (Remember that a java mirror is an instance of java.lang.Class.) ciType* java_mirror_type(); diff --git a/src/hotspot/share/ci/ciInstanceKlass.cpp b/src/hotspot/share/ci/ciInstanceKlass.cpp index b9aa07a0b0b..ce848b5f726 100644 --- a/src/hotspot/share/ci/ciInstanceKlass.cpp +++ b/src/hotspot/share/ci/ciInstanceKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -66,10 +66,10 @@ ciInstanceKlass::ciInstanceKlass(Klass* k) : _has_nonstatic_concrete_methods = ik->has_nonstatic_concrete_methods(); _is_hidden = ik->is_hidden(); _is_record = ik->is_record(); - _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields: + _nonstatic_fields = nullptr; // initialized lazily by compute_nonstatic_fields: _has_injected_fields = -1; - _implementor = NULL; // we will fill these lazily - _transitive_interfaces = NULL; + _implementor = nullptr; // we will fill these lazily + _transitive_interfaces = nullptr; // Ensure that the metadata wrapped by the ciMetadata is kept alive by GC. // This is primarily useful for metadata which is considered as weak roots @@ -79,11 +79,11 @@ ciInstanceKlass::ciInstanceKlass(Klass* k) : oop holder = ik->klass_holder(); if (ik->class_loader_data()->has_class_mirror_holder()) { // Though ciInstanceKlass records class loader oop, it's not enough to keep - // non-strong hidden classes alive (loader == NULL). Klass holder should + // non-strong hidden classes alive (loader == nullptr). Klass holder should // be used instead. It is enough to record a ciObject, since cached elements are never removed // during ciObjectFactory lifetime. ciObjectFactory itself is created for // every compilation and lives for the whole duration of the compilation. - assert(holder != NULL, "holder of hidden class is the mirror which is never null"); + assert(holder != nullptr, "holder of hidden class is the mirror which is never null"); (void)CURRENT_ENV->get_object(holder); } @@ -104,8 +104,8 @@ ciInstanceKlass::ciInstanceKlass(Klass* k) : _has_trusted_loader = compute_has_trusted_loader(); // Lazy fields get filled in only upon request. - _super = NULL; - _java_mirror = NULL; + _super = nullptr; + _java_mirror = nullptr; if (is_shared()) { if (k != vmClasses::Object_klass()) { @@ -114,7 +114,7 @@ ciInstanceKlass::ciInstanceKlass(Klass* k) : //compute_nonstatic_fields(); // done outside of constructor } - _field_cache = NULL; + _field_cache = nullptr; } // Version for unloaded classes: @@ -125,16 +125,16 @@ ciInstanceKlass::ciInstanceKlass(ciSymbol* name, assert(name->char_at(0) != JVM_SIGNATURE_ARRAY, "not an instance klass"); _init_state = (InstanceKlass::ClassState)0; _has_nonstatic_fields = false; - _nonstatic_fields = NULL; + _nonstatic_fields = nullptr; _has_injected_fields = -1; _is_hidden = false; _is_record = false; _loader = loader; _protection_domain = protection_domain; _is_shared = false; - _super = NULL; - _java_mirror = NULL; - _field_cache = NULL; + _super = nullptr; + _java_mirror = nullptr; + _field_cache = nullptr; _has_trusted_loader = compute_has_trusted_loader(); } @@ -154,7 +154,7 @@ void ciInstanceKlass::compute_shared_init_state() { bool ciInstanceKlass::compute_shared_has_subklass() { GUARDED_VM_ENTRY( InstanceKlass* ik = get_instanceKlass(); - _has_subklass = ik->subklass() != NULL ? subklass_true : subklass_false; + _has_subklass = ik->subklass() != nullptr ? subklass_true : subklass_false; return _has_subklass == subklass_true; ) } @@ -191,9 +191,9 @@ jobject ciInstanceKlass::protection_domain_handle() { // Get the field cache associated with this klass. ciConstantPoolCache* ciInstanceKlass::field_cache() { if (is_shared()) { - return NULL; + return nullptr; } - if (_field_cache == NULL) { + if (_field_cache == nullptr) { assert(!is_java_lang_Object(), "Object has no fields"); Arena* arena = CURRENT_ENV->arena(); _field_cache = new (arena) ciConstantPoolCache(arena, 5); @@ -222,13 +222,13 @@ ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) { ciInstanceKlass* self = this; assert(self->is_loaded(), "must be loaded to access field info"); ciField* field = self->get_field_by_offset(offset, false); - if (field != NULL) { + if (field != nullptr) { return field->holder(); } else { for (;;) { assert(self->is_loaded(), "must be loaded to have size"); ciInstanceKlass* super = self->super(); - if (super == NULL || + if (super == nullptr || super->nof_nonstatic_fields() == 0 || super->layout_helper_size_in_bytes() <= offset) { return self; @@ -252,7 +252,7 @@ bool ciInstanceKlass::is_java_lang_Object() const { bool ciInstanceKlass::uses_default_loader() const { // Note: We do not need to resolve the handle or enter the VM // in order to test null-ness. - return _loader == NULL; + return _loader == nullptr; } // ------------------------------------------------------------------ @@ -355,7 +355,7 @@ void ciInstanceKlass::print_impl(outputStream* st) { // Get the superklass of this klass. ciInstanceKlass* ciInstanceKlass::super() { assert(is_loaded(), "must be loaded"); - if (_super == NULL && !is_java_lang_Object()) { + if (_super == nullptr && !is_java_lang_Object()) { GUARDED_VM_ENTRY( Klass* super_klass = get_instanceKlass()->super(); _super = CURRENT_ENV->get_instance_klass(super_klass); @@ -373,7 +373,7 @@ ciInstance* ciInstanceKlass::java_mirror() { if (is_shared()) { return ciKlass::java_mirror(); } - if (_java_mirror == NULL) { + if (_java_mirror == nullptr) { _java_mirror = ciKlass::java_mirror(); } return _java_mirror; @@ -382,15 +382,15 @@ ciInstance* ciInstanceKlass::java_mirror() { // ------------------------------------------------------------------ // ciInstanceKlass::unique_concrete_subklass ciInstanceKlass* ciInstanceKlass::unique_concrete_subklass() { - if (!is_loaded()) return NULL; // No change if class is not loaded - if (!is_abstract()) return NULL; // Only applies to abstract classes. - if (!has_subklass()) return NULL; // Must have at least one subklass. + if (!is_loaded()) return nullptr; // No change if class is not loaded + if (!is_abstract()) return nullptr; // Only applies to abstract classes. + if (!has_subklass()) return nullptr; // Must have at least one subklass. VM_ENTRY_MARK; InstanceKlass* ik = get_instanceKlass(); Klass* up = ik->up_cast_abstract(); assert(up->is_instance_klass(), "must be InstanceKlass"); if (ik == up) { - return NULL; + return nullptr; } return CURRENT_THREAD_ENV->get_instance_klass(up); } @@ -400,7 +400,7 @@ ciInstanceKlass* ciInstanceKlass::unique_concrete_subklass() { bool ciInstanceKlass::has_finalizable_subclass() { if (!is_loaded()) return true; VM_ENTRY_MARK; - return Dependencies::find_finalizable_subclass(get_instanceKlass()) != NULL; + return Dependencies::find_finalizable_subclass(get_instanceKlass()) != nullptr; } // ------------------------------------------------------------------ @@ -423,13 +423,13 @@ ciField* ciInstanceKlass::get_field_by_offset(int field_offset, bool is_static) break; // could do binary search or check bins, but probably not worth it } - return NULL; + return nullptr; } VM_ENTRY_MARK; InstanceKlass* k = get_instanceKlass(); fieldDescriptor fd; if (!k->find_field_from_offset(field_offset, is_static, &fd)) { - return NULL; + return nullptr; } ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd); return field; @@ -442,8 +442,8 @@ ciField* ciInstanceKlass::get_field_by_name(ciSymbol* name, ciSymbol* signature, InstanceKlass* k = get_instanceKlass(); fieldDescriptor fd; Klass* def = k->find_field(name->get_symbol(), signature->get_symbol(), is_static, &fd); - if (def == NULL) { - return NULL; + if (def == nullptr) { + return nullptr; } ciField* field = new (CURRENT_THREAD_ENV->arena()) ciField(&fd); return field; @@ -460,32 +460,32 @@ static int sort_field_by_offset(ciField** a, ciField** b) { int ciInstanceKlass::compute_nonstatic_fields() { assert(is_loaded(), "must be loaded"); - if (_nonstatic_fields != NULL) + if (_nonstatic_fields != nullptr) return _nonstatic_fields->length(); if (!has_nonstatic_fields()) { Arena* arena = CURRENT_ENV->arena(); - _nonstatic_fields = new (arena) GrowableArray(arena, 0, 0, NULL); + _nonstatic_fields = new (arena) GrowableArray(arena, 0, 0, nullptr); return 0; } assert(!is_java_lang_Object(), "bootstrap OK"); ciInstanceKlass* super = this->super(); - GrowableArray* super_fields = NULL; - if (super != NULL && super->has_nonstatic_fields()) { + GrowableArray* super_fields = nullptr; + if (super != nullptr && super->has_nonstatic_fields()) { int super_flen = super->nof_nonstatic_fields(); super_fields = super->_nonstatic_fields; - assert(super_flen == 0 || super_fields != NULL, "first get nof_fields"); + assert(super_flen == 0 || super_fields != nullptr, "first get nof_fields"); } - GrowableArray* fields = NULL; + GrowableArray* fields = nullptr; GUARDED_VM_ENTRY({ fields = compute_nonstatic_fields_impl(super_fields); }); - if (fields == NULL) { + if (fields == nullptr) { // This can happen if this class (java.lang.Class) has invisible fields. - if (super_fields != NULL) { + if (super_fields != nullptr) { _nonstatic_fields = super_fields; return super_fields->length(); } else { @@ -508,7 +508,7 @@ ciInstanceKlass::compute_nonstatic_fields_impl(GrowableArray* ASSERT_IN_VM; Arena* arena = CURRENT_ENV->arena(); int flen = 0; - GrowableArray* fields = NULL; + GrowableArray* fields = nullptr; InstanceKlass* k = get_instanceKlass(); for (JavaFieldStream fs(k); !fs.done(); fs.next()) { if (fs.access_flags().is_static()) continue; @@ -517,13 +517,13 @@ ciInstanceKlass::compute_nonstatic_fields_impl(GrowableArray* // allocate the array: if (flen == 0) { - return NULL; // return nothing if none are locally declared + return nullptr; // return nothing if none are locally declared } - if (super_fields != NULL) { + if (super_fields != nullptr) { flen += super_fields->length(); } - fields = new (arena) GrowableArray(arena, flen, 0, NULL); - if (super_fields != NULL) { + fields = new (arena) GrowableArray(arena, flen, 0, nullptr); + if (super_fields != nullptr) { fields->appendAll(super_fields); } @@ -552,7 +552,7 @@ void ciInstanceKlass::compute_injected_fields() { assert(is_loaded(), "must be loaded"); int has_injected_fields = 0; - if (super() != NULL && super()->has_injected_fields()) { + if (super() != nullptr && super()->has_injected_fields()) { has_injected_fields = 1; } else { GUARDED_VM_ENTRY({ @@ -573,7 +573,7 @@ bool ciInstanceKlass::has_object_fields() const { bool ciInstanceKlass::compute_has_trusted_loader() { ASSERT_IN_VM; oop loader_oop = loader(); - if (loader_oop == NULL) { + if (loader_oop == nullptr) { return true; // bootstrap class loader } return java_lang_ClassLoader::is_trusted_loader(loader_oop); @@ -590,7 +590,7 @@ ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) { Symbol* sig_sym= signature->get_symbol(); Method* m = k->find_method(name_sym, sig_sym); - if (m == NULL) return NULL; + if (m == nullptr) return nullptr; return CURRENT_THREAD_ENV->get_method(m); } @@ -617,7 +617,7 @@ bool ciInstanceKlass::is_leaf_type() { // will be checked later under the Compile_lock. ciInstanceKlass* ciInstanceKlass::implementor() { ciInstanceKlass* impl = _implementor; - if (impl == NULL) { + if (impl == nullptr) { if (is_shared()) { impl = this; // assume a well-known interface never has a unique implementor } else { @@ -625,7 +625,7 @@ ciInstanceKlass* ciInstanceKlass::implementor() { VM_ENTRY_MARK; MutexLocker ml(Compile_lock); Klass* k = get_instanceKlass()->implementor(); - if (k != NULL) { + if (k != nullptr) { if (k == get_instanceKlass()) { // More than one implementors. Use 'this' in this case. impl = this; @@ -681,13 +681,13 @@ class StaticFinalFieldPrinter : public FieldClosure { case T_ARRAY: // fall-through case T_OBJECT: { oop value = mirror->obj_field_acquire(fd->offset()); - if (value == NULL) { + if (value == nullptr) { _out->print_cr("null"); } else if (value->is_instance()) { assert(fd->field_type() == T_OBJECT, ""); if (value->is_a(vmClasses::String_klass())) { const char* ascii_value = java_lang_String::as_quoted_ascii(value); - _out->print_cr("\"%s\"", (ascii_value != NULL) ? ascii_value : ""); + _out->print_cr("\"%s\"", (ascii_value != nullptr) ? ascii_value : ""); } else { const char* klass_name = value->klass()->name()->as_quoted_ascii(); _out->print_cr("%s", klass_name); @@ -720,7 +720,7 @@ const char *ciInstanceKlass::replay_name() const { void ciInstanceKlass::dump_replay_instanceKlass(outputStream* out, InstanceKlass* ik) { if (ik->is_hidden()) { const char *name = CURRENT_ENV->dyno_name(ik); - if (name != NULL) { + if (name != nullptr) { out->print_cr("instanceKlass %s # %s", name, ik->name()->as_quoted_ascii()); } else { out->print_cr("# instanceKlass %s", ik->name()->as_quoted_ascii()); @@ -764,7 +764,7 @@ void ciInstanceKlass::dump_replay_data(outputStream* out) { // Try to record related loaded classes Klass* sub = ik->subklass(); - while (sub != NULL) { + while (sub != nullptr) { if (sub->is_instance_klass()) { InstanceKlass *isub = InstanceKlass::cast(sub); dump_replay_instanceKlass(out, isub); diff --git a/src/hotspot/share/ci/ciInstanceKlass.hpp b/src/hotspot/share/ci/ciInstanceKlass.hpp index c970232778a..4c327e1f32d 100644 --- a/src/hotspot/share/ci/ciInstanceKlass.hpp +++ b/src/hotspot/share/ci/ciInstanceKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ private: int _has_injected_fields; // any non static injected fields? lazily initialized. // The possible values of the _implementor fall into following three cases: - // NULL: no implementor. + // null: no implementor. // A ciInstanceKlass that's not itself: one implementor. // Itself: more than one implementor. ciInstanceKlass* _implementor; @@ -183,7 +183,7 @@ public: ciInstanceKlass* impl; assert(is_loaded(), "must be loaded"); impl = implementor(); - if (impl == NULL) { + if (impl == nullptr) { return 0; } else if (impl != this) { return 1; @@ -210,7 +210,7 @@ public: // total number of nonstatic fields (including inherited): int nof_nonstatic_fields() { - if (_nonstatic_fields == NULL) + if (_nonstatic_fields == nullptr) return compute_nonstatic_fields(); else return _nonstatic_fields->length(); @@ -227,7 +227,7 @@ public: // nth nonstatic field (presented by ascending address) ciField* nonstatic_field_at(int i) { - assert(_nonstatic_fields != NULL, ""); + assert(_nonstatic_fields != nullptr, ""); return _nonstatic_fields->at(i); } @@ -258,7 +258,7 @@ public: ciInstanceKlass* unique_implementor() { assert(is_loaded(), "must be loaded"); ciInstanceKlass* impl = implementor(); - return (impl != this ? impl : NULL); + return (impl != this ? impl : nullptr); } // Is the defining class loader of this class the default loader? @@ -283,7 +283,7 @@ public: if (is_loaded() && is_final() && !is_interface()) { return this; } - return NULL; + return nullptr; } bool can_be_instantiated() { diff --git a/src/hotspot/share/ci/ciKlass.cpp b/src/hotspot/share/ci/ciKlass.cpp index be9f903ff49..6e70d69f05d 100644 --- a/src/hotspot/share/ci/ciKlass.cpp +++ b/src/hotspot/share/ci/ciKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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,7 +41,7 @@ ciKlass::ciKlass(Klass* k) : ciType(k) { Klass* klass = get_Klass(); _layout_helper = klass->layout_helper(); Symbol* klass_name = klass->name(); - assert(klass_name != NULL, "wrong ciKlass constructor"); + assert(klass_name != nullptr, "wrong ciKlass constructor"); _name = CURRENT_ENV->get_symbol(klass_name); } @@ -136,7 +136,7 @@ ciKlass* ciKlass::super_of_depth(juint i) { VM_ENTRY_MARK; Klass* this_klass = get_Klass(); Klass* super = this_klass->primary_super_of_depth(i); - return (super != NULL) ? CURRENT_THREAD_ENV->get_klass(super) : NULL; + return (super != nullptr) ? CURRENT_THREAD_ENV->get_klass(super) : nullptr; } // ------------------------------------------------------------------ diff --git a/src/hotspot/share/ci/ciKlass.hpp b/src/hotspot/share/ci/ciKlass.hpp index 467284b7cde..2dd5a5e2c0b 100644 --- a/src/hotspot/share/ci/ciKlass.hpp +++ b/src/hotspot/share/ci/ciKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -57,16 +57,16 @@ protected: Klass* get_Klass() const { Klass* k = (Klass*)_metadata; - assert(k != NULL, "illegal use of unloaded klass"); + assert(k != nullptr, "illegal use of unloaded klass"); return k; } // Certain subklasses have an associated class loader. - virtual oop loader() { return NULL; } - virtual jobject loader_handle() { return NULL; } + virtual oop loader() { return nullptr; } + virtual jobject loader_handle() { return nullptr; } - virtual oop protection_domain() { return NULL; } - virtual jobject protection_domain_handle() { return NULL; } + virtual oop protection_domain() { return nullptr; } + virtual jobject protection_domain_handle() { return nullptr; } const char* type_string() { return "ciKlass"; } diff --git a/src/hotspot/share/ci/ciMetadata.hpp b/src/hotspot/share/ci/ciMetadata.hpp index dcf01b692dd..81dff044db6 100644 --- a/src/hotspot/share/ci/ciMetadata.hpp +++ b/src/hotspot/share/ci/ciMetadata.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -40,12 +40,12 @@ class ciMetadata: public ciBaseObject { protected: Metadata* _metadata; - ciMetadata(): _metadata(NULL) {} + ciMetadata(): _metadata(nullptr) {} ciMetadata(Metadata* o): _metadata(o) {} virtual bool is_classless() const; public: - bool is_loaded() const { return _metadata != NULL || is_classless(); } + bool is_loaded() const { return _metadata != nullptr || is_classless(); } virtual bool is_metadata() const { return true; } diff --git a/src/hotspot/share/ci/ciMethod.cpp b/src/hotspot/share/ci/ciMethod.cpp index 7fff3f02073..627f28ad5b9 100644 --- a/src/hotspot/share/ci/ciMethod.cpp +++ b/src/hotspot/share/ci/ciMethod.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -70,7 +70,7 @@ ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) : ciMetadata(h_m()), _holder(holder) { - assert(h_m() != NULL, "no null method"); + assert(h_m() != nullptr, "no null method"); assert(_holder->get_instanceKlass() == h_m->method_holder(), ""); // These fields are always filled in in loaded methods. @@ -90,13 +90,13 @@ ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) : _has_reserved_stack_access = h_m->has_reserved_stack_access(); _is_overpass = h_m->is_overpass(); // Lazy fields, filled in on demand. Require allocation. - _code = NULL; - _exception_handlers = NULL; - _liveness = NULL; - _method_blocks = NULL; + _code = nullptr; + _exception_handlers = nullptr; + _liveness = nullptr; + _method_blocks = nullptr; #if defined(COMPILER2) - _flow = NULL; - _bcea = NULL; + _flow = nullptr; + _bcea = nullptr; #endif // COMPILER2 // Check for blackhole intrinsic and then populate the intrinsic ID. @@ -107,7 +107,7 @@ ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) : if (env->jvmti_can_hotswap_or_post_breakpoint()) { // 6328518 check hotswap conditions under the right lock. MutexLocker locker(Compile_lock); - if (Dependencies::check_evol_method(h_m()) != NULL) { + if (Dependencies::check_evol_method(h_m()) != nullptr) { _is_c1_compilable = false; _is_c2_compilable = false; _can_be_parsed = false; @@ -138,7 +138,7 @@ ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) : ciSymbol* sig_symbol = env->get_symbol(h_m->signature()); constantPoolHandle cpool(Thread::current(), h_m->constants()); _signature = new (env->arena()) ciSignature(_holder, cpool, sig_symbol); - _method_data = NULL; + _method_data = nullptr; // Take a snapshot of these values, so they will be commensurate with the MDO. if (ProfileInterpreter || CompilerConfig::is_c1_profiling()) { int invcnt = h_m->interpreter_invocation_count(); @@ -166,20 +166,20 @@ ciMethod::ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature, ciInstanceKlass* accessor) : - ciMetadata((Metadata*)NULL), + ciMetadata((Metadata*)nullptr), _name( name), _holder( holder), - _method_data( NULL), - _method_blocks( NULL), + _method_data( nullptr), + _method_blocks( nullptr), _intrinsic_id( vmIntrinsics::_none), _inline_instructions_size(-1), _can_be_statically_bound(false), _can_omit_stack_trace(true), - _liveness( NULL) + _liveness( nullptr) #if defined(COMPILER2) , - _flow( NULL), - _bcea( NULL) + _flow( nullptr), + _bcea( nullptr) #endif // COMPILER2 { // Usually holder and accessor are the same type but in some cases @@ -208,7 +208,7 @@ void ciMethod::load_code() { // Revert any breakpoint bytecodes in ci's copy if (me->number_of_breakpoints() > 0) { BreakpointInfo* bp = me->method_holder()->breakpoints(); - for (; bp != NULL; bp = bp->next()) { + for (; bp != nullptr; bp = bp->next()) { if (bp->match(me)) { code_at_put(bp->bci(), bp->orig_bytecode()); } @@ -320,7 +320,7 @@ bool ciMethod::has_balanced_monitors() { // ciMethod::get_flow_analysis ciTypeFlow* ciMethod::get_flow_analysis() { #if defined(COMPILER2) - if (_flow == NULL) { + if (_flow == nullptr) { ciEnv* env = CURRENT_ENV; _flow = new (env->arena()) ciTypeFlow(env, this); _flow->do_flow(); @@ -328,7 +328,7 @@ ciTypeFlow* ciMethod::get_flow_analysis() { return _flow; #else // COMPILER2 ShouldNotReachHere(); - return NULL; + return nullptr; #endif // COMPILER2 } @@ -345,7 +345,7 @@ ciTypeFlow* ciMethod::get_osr_flow_analysis(int osr_bci) { return flow; #else // COMPILER2 ShouldNotReachHere(); - return NULL; + return nullptr; #endif // COMPILER2 } @@ -355,7 +355,7 @@ ciTypeFlow* ciMethod::get_osr_flow_analysis(int osr_bci) { // Which local variables are live at a specific bci? MethodLivenessResult ciMethod::raw_liveness_at_bci(int bci) { check_is_loaded(); - if (_liveness == NULL) { + if (_liveness == nullptr) { // Create the liveness analyzer. Arena* arena = CURRENT_ENV->arena(); _liveness = new (arena) MethodLiveness(arena, this); @@ -416,7 +416,7 @@ ResourceBitMap ciMethod::live_local_oops_at_bci(int bci) { // Marks all bcis where a new basic block starts const BitMap& ciMethod::bci_block_start() { check_is_loaded(); - if (_liveness == NULL) { + if (_liveness == nullptr) { // Create the liveness analyzer. Arena* arena = CURRENT_ENV->arena(); _liveness = new (arena) MethodLiveness(arena, this); @@ -457,9 +457,9 @@ int ciMethod::check_overflow(int c, Bytecodes::Code code) { ciCallProfile ciMethod::call_profile_at_bci(int bci) { ResourceMark rm; ciCallProfile result; - if (method_data() != NULL && method_data()->is_mature()) { + if (method_data() != nullptr && method_data()->is_mature()) { ciProfileData* data = method_data()->bci_to_data(bci); - if (data != NULL && data->is_CounterData()) { + if (data != nullptr && data->is_CounterData()) { // Every profiled call site has a counter. int count = check_overflow(data->as_CounterData()->count(), java_code_at_bci(bci)); @@ -473,7 +473,7 @@ ciCallProfile ciMethod::call_profile_at_bci(int bci) { // Precompute morphism for the possible fixup for (uint i = 0; i < call->row_limit(); i++) { ciKlass* receiver = call->receiver(i); - if (receiver == NULL) continue; + if (receiver == nullptr) continue; morphism++; } int epsilon = 0; @@ -487,7 +487,7 @@ ciCallProfile ciMethod::call_profile_at_bci(int bci) { } for (uint i = 0; i < call->row_limit(); i++) { ciKlass* receiver = call->receiver(i); - if (receiver == NULL) continue; + if (receiver == nullptr) continue; int rcount = saturated_add(call->receiver_count(i), epsilon); if (rcount == 0) rcount = 1; // Should be valid value receivers_count_total = saturated_add(receivers_count_total, rcount); @@ -564,15 +564,15 @@ void ciMethod::assert_call_type_ok(int bci) { * * @param [in]bci bci of the call * @param [in]i argument number - * @param [out]type profiled type of argument, NULL if none + * @param [out]type profiled type of argument, null if none * @param [out]ptr_kind whether always null, never null or maybe null * @return true if profiling exists * */ bool ciMethod::argument_profiled_type(int bci, int i, ciKlass*& type, ProfilePtrKind& ptr_kind) { - if (MethodData::profile_parameters() && method_data() != NULL && method_data()->is_mature()) { + if (MethodData::profile_parameters() && method_data() != nullptr && method_data()->is_mature()) { ciProfileData* data = method_data()->bci_to_data(bci); - if (data != NULL) { + if (data != nullptr) { if (data->is_VirtualCallTypeData()) { assert_virtual_call_type_ok(bci); ciVirtualCallTypeData* call = (ciVirtualCallTypeData*)data->as_VirtualCallTypeData(); @@ -602,15 +602,15 @@ bool ciMethod::argument_profiled_type(int bci, int i, ciKlass*& type, ProfilePtr * the call at bci bci * * @param [in]bci bci of the call - * @param [out]type profiled type of argument, NULL if none + * @param [out]type profiled type of argument, null if none * @param [out]ptr_kind whether always null, never null or maybe null * @return true if profiling exists * */ bool ciMethod::return_profiled_type(int bci, ciKlass*& type, ProfilePtrKind& ptr_kind) { - if (MethodData::profile_return() && method_data() != NULL && method_data()->is_mature()) { + if (MethodData::profile_return() && method_data() != nullptr && method_data()->is_mature()) { ciProfileData* data = method_data()->bci_to_data(bci); - if (data != NULL) { + if (data != nullptr) { if (data->is_VirtualCallTypeData()) { assert_virtual_call_type_ok(bci); ciVirtualCallTypeData* call = (ciVirtualCallTypeData*)data->as_VirtualCallTypeData(); @@ -637,15 +637,15 @@ bool ciMethod::return_profiled_type(int bci, ciKlass*& type, ProfilePtrKind& ptr * Check whether profiling provides a type for the parameter i * * @param [in]i parameter number - * @param [out]type profiled type of parameter, NULL if none + * @param [out]type profiled type of parameter, null if none * @param [out]ptr_kind whether always null, never null or maybe null * @return true if profiling exists * */ bool ciMethod::parameter_profiled_type(int i, ciKlass*& type, ProfilePtrKind& ptr_kind) { - if (MethodData::profile_parameters() && method_data() != NULL && method_data()->is_mature()) { + if (MethodData::profile_parameters() && method_data() != nullptr && method_data()->is_mature()) { ciParametersTypeData* parameters = method_data()->parameters_type_data(); - if (parameters != NULL && i < parameters->number_of_parameters()) { + if (parameters != nullptr && i < parameters->number_of_parameters()) { type = parameters->valid_parameter_type(i); ptr_kind = parameters->parameter_ptr_kind(i); return true; @@ -659,7 +659,7 @@ bool ciMethod::parameter_profiled_type(int i, ciKlass*& type, ProfilePtrKind& pt // ciMethod::find_monomorphic_target // // Given a certain calling environment, find the monomorphic target -// for the call. Return NULL if the call is not monomorphic in +// for the call. Return null if the call is not monomorphic in // its calling environment, or if there are only abstract methods. // The returned method is never abstract. // Note: If caller uses a non-null result, it must inform dependencies @@ -672,13 +672,13 @@ ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller, if (actual_recv->is_interface()) { // %%% We cannot trust interface types, yet. See bug 6312651. - return NULL; + return nullptr; } ciMethod* root_m = resolve_invoke(caller, actual_recv, check_access, true /* allow_abstract */); - if (root_m == NULL) { + if (root_m == nullptr) { // Something went wrong looking up the actual receiver method. - return NULL; + return nullptr; } // Make certain quick checks even if UseCHA is false. @@ -693,7 +693,7 @@ ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller, // Easy case. There is no other place to put a method, so don't bother // to go through the VM_ENTRY_MARK and all the rest. if (root_m->is_abstract()) { - return NULL; + return nullptr; } return root_m; } @@ -704,7 +704,7 @@ ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller, // The inline_native_clone intrinsic narrows Object to T[] properly, // so there is no need to do the same job here. - if (!UseCHA) return NULL; + if (!UseCHA) return nullptr; VM_ENTRY_MARK; @@ -719,16 +719,16 @@ ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller, this->get_Method())); } else { if (root_m->is_abstract()) { - return NULL; // not supported + return nullptr; // not supported } target = methodHandle(THREAD, Dependencies::find_unique_concrete_method(context, root_m->get_Method())); } - assert(target() == NULL || !target()->is_abstract(), "not allowed"); + assert(target() == nullptr || !target()->is_abstract(), "not allowed"); // %%% Should upgrade this ciMethod API to look for 1 or 2 concrete methods. } #ifndef PRODUCT - if (TraceDependencies && target() != NULL && target() != root_m->get_Method()) { + if (TraceDependencies && target() != nullptr && target() != root_m->get_Method()) { tty->print("found a non-root unique target method"); tty->print_cr(" context = %s", actual_recv->get_Klass()->external_name()); tty->print(" method = "); @@ -737,8 +737,8 @@ ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller, } #endif //PRODUCT - if (target() == NULL) { - return NULL; + if (target() == nullptr) { + return nullptr; } if (target() == root_m->get_Method()) { return root_m; @@ -748,11 +748,11 @@ ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller, // If we are going to reason about inheritance, it's easiest // if the method in question is public, protected, or private. // If the answer is not root_m, it is conservatively correct - // to return NULL, even if the CHA encountered irrelevant + // to return null, even if the CHA encountered irrelevant // methods in other packages. // %%% TO DO: Work out logic for package-private methods // with the same name but different vtable indexes. - return NULL; + return nullptr; } return CURRENT_THREAD_ENV->get_method(target()); } @@ -783,7 +783,7 @@ bool ciMethod::can_omit_stack_trace() const { // ciMethod::resolve_invoke // // Given a known receiver klass, find the target for the call. -// Return NULL if the call has no target or the target is abstract. +// Return null if the call has no target or the target is abstract. ciMethod* ciMethod::resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, bool check_access, bool allow_abstract) { check_is_loaded(); VM_ENTRY_MARK; @@ -797,7 +797,7 @@ ciMethod* ciMethod::resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, boo LinkInfo link_info(resolved, h_name, h_signature, caller_klass, check_access ? LinkInfo::AccessCheck::required : LinkInfo::AccessCheck::skip, check_access ? LinkInfo::LoaderConstraintCheck::required : LinkInfo::LoaderConstraintCheck::skip); - Method* m = NULL; + Method* m = nullptr; // Only do exact lookup if receiver klass has been linked. Otherwise, // the vtable has not been setup, and the LinkResolver will fail. if (recv->is_array_klass() @@ -810,9 +810,9 @@ ciMethod* ciMethod::resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, boo } } - if (m == NULL) { - // Return NULL only if there was a problem with lookup (uninitialized class, etc.) - return NULL; + if (m == nullptr) { + // Return null only if there was a problem with lookup (uninitialized class, etc.) + return nullptr; } ciMethod* result = this; @@ -822,7 +822,7 @@ ciMethod* ciMethod::resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, boo if (result->is_abstract() && !allow_abstract) { // Don't return abstract methods because they aren't optimizable or interesting. - return NULL; + return nullptr; } return result; } @@ -893,7 +893,7 @@ ciKlass* ciMethod::get_declared_method_holder_at_bci(int bci) { // they can be usefully and stably compared against the // invocation counts in methods. int ciMethod::scale_count(int count, float prof_factor) { - if (count > 0 && method_data() != NULL) { + if (count > 0 && method_data() != nullptr) { int counter_life = method_data()->invocation_count(); int method_life = interpreter_invocation_count(); if (method_life < counter_life) { // may happen because of the snapshot timing @@ -979,13 +979,13 @@ bool ciMethod::ensure_method_data(const methodHandle& h_m) { if (is_native() || is_abstract() || h_m()->is_accessor()) { return true; } - if (h_m()->method_data() == NULL) { + if (h_m()->method_data() == nullptr) { Method::build_profiling_method_data(h_m, THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; } } - if (h_m()->method_data() != NULL) { + if (h_m()->method_data() != nullptr) { _method_data = CURRENT_ENV->get_method_data(h_m()->method_data()); return _method_data->load_data(); } else { @@ -997,7 +997,7 @@ bool ciMethod::ensure_method_data(const methodHandle& h_m) { // public, retroactive version bool ciMethod::ensure_method_data() { bool result = true; - if (_method_data == NULL || _method_data->is_empty()) { + if (_method_data == nullptr || _method_data->is_empty()) { GUARDED_VM_ENTRY({ methodHandle mh(Thread::current(), get_Method()); result = ensure_method_data(mh); @@ -1011,7 +1011,7 @@ bool ciMethod::ensure_method_data() { // ciMethod::method_data // ciMethodData* ciMethod::method_data() { - if (_method_data != NULL) { + if (_method_data != nullptr) { return _method_data; } VM_ENTRY_MARK; @@ -1019,7 +1019,7 @@ ciMethodData* ciMethod::method_data() { Thread* my_thread = JavaThread::current(); methodHandle h_m(my_thread, get_Method()); - if (h_m()->method_data() != NULL) { + if (h_m()->method_data() != nullptr) { _method_data = CURRENT_ENV->get_method_data(h_m()->method_data()); _method_data->load_data(); } else { @@ -1032,11 +1032,11 @@ ciMethodData* ciMethod::method_data() { // ------------------------------------------------------------------ // ciMethod::method_data_or_null // Returns a pointer to ciMethodData if MDO exists on the VM side, -// NULL otherwise. +// null otherwise. ciMethodData* ciMethod::method_data_or_null() { ciMethodData *md = method_data(); if (md->is_empty()) { - return NULL; + return nullptr; } return md; } @@ -1123,7 +1123,7 @@ int ciMethod::inline_instructions_size() { if (_inline_instructions_size == -1) { GUARDED_VM_ENTRY( CompiledMethod* code = get_Method()->code(); - if (code != NULL && (code->comp_level() == CompLevel_full_optimization)) { + if (code != nullptr && (code->comp_level() == CompLevel_full_optimization)) { int isize = code->insts_end() - code->verified_entry_point() - code->skipped_instructions_size(); _inline_instructions_size = isize > 0 ? isize : 0; } else { @@ -1139,7 +1139,7 @@ int ciMethod::inline_instructions_size() { void ciMethod::log_nmethod_identity(xmlStream* log) { GUARDED_VM_ENTRY( CompiledMethod* code = get_Method()->code(); - if (code != NULL) { + if (code != nullptr) { code->log_identity(log); } ) @@ -1271,18 +1271,18 @@ bool ciMethod::is_vector_method() const { BCEscapeAnalyzer *ciMethod::get_bcea() { #ifdef COMPILER2 - if (_bcea == NULL) { - _bcea = new (CURRENT_ENV->arena()) BCEscapeAnalyzer(this, NULL); + if (_bcea == nullptr) { + _bcea = new (CURRENT_ENV->arena()) BCEscapeAnalyzer(this, nullptr); } return _bcea; #else // COMPILER2 ShouldNotReachHere(); - return NULL; + return nullptr; #endif // COMPILER2 } ciMethodBlocks *ciMethod::get_method_blocks() { - if (_method_blocks == NULL) { + if (_method_blocks == nullptr) { Arena *arena = CURRENT_ENV->arena(); _method_blocks = new (arena) ciMethodBlocks(arena, this); } @@ -1314,8 +1314,8 @@ void ciMethod::dump_replay_data(outputStream* st) { st->print("ciMethod "); dump_name_as_ascii(st); st->print_cr(" %d %d %d %d %d", - mcs == NULL ? 0 : mcs->invocation_counter()->raw_counter(), - mcs == NULL ? 0 : mcs->backedge_counter()->raw_counter(), + mcs == nullptr ? 0 : mcs->invocation_counter()->raw_counter(), + mcs == nullptr ? 0 : mcs->backedge_counter()->raw_counter(), interpreter_invocation_count(), interpreter_throwout_count(), _inline_instructions_size); diff --git a/src/hotspot/share/ci/ciMethod.hpp b/src/hotspot/share/ci/ciMethod.hpp index 11086a9a6e3..90792d7cc20 100644 --- a/src/hotspot/share/ci/ciMethod.hpp +++ b/src/hotspot/share/ci/ciMethod.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -175,12 +175,12 @@ class ciMethod : public ciMetadata { Method* get_Method() const { Method* m = (Method*)_metadata; - assert(m != NULL, "illegal use of unloaded method"); + assert(m != nullptr, "illegal use of unloaded method"); return m; } // Method code and related information. - address code() { if (_code == NULL) load_code(); return _code; } + address code() { if (_code == nullptr) load_code(); return _code; } int code_size() const { check_is_loaded(); return _code_size; } int max_stack() const { check_is_loaded(); return _max_stack; } int max_locals() const { check_is_loaded(); return _max_locals; } @@ -214,11 +214,11 @@ class ciMethod : public ciMetadata { Bytecodes::Code java_code_at_bci(int bci) { address bcp = code() + bci; - return Bytecodes::java_code_at(NULL, bcp); + return Bytecodes::java_code_at(nullptr, bcp); } Bytecodes::Code raw_code_at_bci(int bci) { address bcp = code() + bci; - return Bytecodes::code_at(NULL, bcp); + return Bytecodes::code_at(nullptr, bcp); } BCEscapeAnalyzer *get_bcea(); ciMethodBlocks *get_method_blocks(); @@ -283,12 +283,12 @@ class ciMethod : public ciMetadata { bool ignored_will_link; ciSignature* declared_signature; get_method_at_bci(bci, ignored_will_link, &declared_signature); - assert(declared_signature != NULL, "cannot be null"); + assert(declared_signature != nullptr, "cannot be null"); return declared_signature; } // Given a certain calling environment, find the monomorphic target - // for the call. Return NULL if the call is not monomorphic in + // for the call. Return null if the call is not monomorphic in // its calling environment. ciMethod* find_monomorphic_target(ciInstanceKlass* caller, ciInstanceKlass* callee_holder, @@ -296,7 +296,7 @@ class ciMethod : public ciMetadata { bool check_access = true); // Given a known receiver klass, find the target for the call. - // Return NULL if the call has no target or is abstract. + // Return null if the call has no target or is abstract. ciMethod* resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, bool check_access = true, bool allow_abstract = false); // Find the proper vtable index to invoke this method. diff --git a/src/hotspot/share/ci/ciMethodBlocks.cpp b/src/hotspot/share/ci/ciMethodBlocks.cpp index 52a6d735839..03dd2c31f99 100644 --- a/src/hotspot/share/ci/ciMethodBlocks.cpp +++ b/src/hotspot/share/ci/ciMethodBlocks.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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,7 +41,7 @@ ciBlock *ciMethodBlocks::block_containing(int bci) { bool ciMethodBlocks::is_block_start(int bci) { assert(bci >= 0 && bci < _code_size, "valid bytecode range"); ciBlock *b = _bci_to_block[bci]; - assert(b != NULL, "must have block for bytecode"); + assert(b != nullptr, "must have block for bytecode"); return b->start_bci() == bci; } @@ -55,7 +55,7 @@ ciBlock *ciMethodBlocks::split_block_at(int bci) { ciBlock *former_block = block_containing(bci); ciBlock *new_block = new(_arena) ciBlock(_method, _num_blocks++, former_block->start_bci()); _blocks->append(new_block); - assert(former_block != NULL, "must not be NULL"); + assert(former_block != nullptr, "must not be nullptr"); new_block->set_limit_bci(bci); former_block->set_start_bci(bci); for (int pos=bci-1; pos >= 0; pos--) { @@ -63,7 +63,7 @@ ciBlock *ciMethodBlocks::split_block_at(int bci) { if (current_block == former_block) { // Replace it. _bci_to_block[pos] = new_block; - } else if (current_block == NULL) { + } else if (current_block == nullptr) { // Non-bytecode start. Skip. continue; } else { @@ -84,7 +84,7 @@ ciBlock *ciMethodBlocks::split_block_at(int bci) { ciBlock *ciMethodBlocks::make_block_at(int bci) { ciBlock *cb = block_containing(bci); - if (cb == NULL ) { + if (cb == nullptr ) { // This is our first time visiting this bytecode. Create // a fresh block and assign it this starting point. ciBlock *nb = new(_arena) ciBlock(_method, _num_blocks++, bci); @@ -117,9 +117,9 @@ void ciMethodBlocks::do_analysis() { // Determine if a new block has been made at the current bci. If // this block differs from our current range, switch to the new // one and end the old one. - assert(cur_block != NULL, "must always have a current block"); + assert(cur_block != nullptr, "must always have a current block"); ciBlock *new_block = block_containing(bci); - if (new_block == NULL || new_block == cur_block) { + if (new_block == nullptr || new_block == cur_block) { // We have not marked this bci as the start of a new block. // Keep interpreting the current_range. _bci_to_block[bci] = cur_block; @@ -265,7 +265,7 @@ ciMethodBlocks::ciMethodBlocks(Arena *arena, ciMethod *meth): _method(meth), _arena(arena), _num_blocks(0), _code_size(meth->code_size()) { int block_estimate = _code_size / 8; - _blocks = new(_arena) GrowableArray(_arena, block_estimate, 0, NULL); + _blocks = new(_arena) GrowableArray(_arena, block_estimate, 0, nullptr); int b2bsize = _code_size * sizeof(ciBlock **); _bci_to_block = (ciBlock **) arena->Amalloc(b2bsize); Copy::zero_to_words((HeapWord*) _bci_to_block, b2bsize / sizeof(HeapWord)); diff --git a/src/hotspot/share/ci/ciMethodData.cpp b/src/hotspot/share/ci/ciMethodData.cpp index c50f4f067ac..9bd73d32ff9 100644 --- a/src/hotspot/share/ci/ciMethodData.cpp +++ b/src/hotspot/share/ci/ciMethodData.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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,7 +41,7 @@ // ciMethodData::ciMethodData(MethodData* md) : ciMetadata(md), - _data_size(0), _extra_data_size(0), _data(NULL), + _data_size(0), _extra_data_size(0), _data(nullptr), // Set an initial hint. Don't use set_hint_di() because // first_di() may be out of bounds if data_size is 0. _hint_di(first_di()), @@ -51,7 +51,7 @@ ciMethodData::ciMethodData(MethodData* md) _eflags(0), _arg_local(0), _arg_stack(0), _arg_returned(0), _invocation_counter(0), _orig(), - _parameters(NULL) {} + _parameters(nullptr) {} // Check for entries that reference an unloaded method class PrepareExtraDataClosure : public CleanExtraDataClosure { @@ -70,7 +70,7 @@ public: if (!m->method_holder()->is_loader_alive()) { return false; } - if (CURRENT_ENV->cached_metadata(m) == NULL) { + if (CURRENT_ENV->cached_metadata(m) == nullptr) { // Uncached entries need to be pre-populated. _uncached_methods.append(m); } @@ -169,7 +169,7 @@ void ciMethodData::load_remaining_extra_data() { bool ciMethodData::load_data() { MethodData* mdo = get_MethodData(); - if (mdo == NULL) { + if (mdo == nullptr) { return false; } @@ -236,7 +236,7 @@ bool ciMethodData::load_data() { ci_data = next_data(ci_data); data = mdo->next_data(data); } - if (mdo->parameters_type_data() != NULL) { + if (mdo->parameters_type_data() != nullptr) { _parameters = data_layout_at(mdo->parameters_type_data_di()); ciParametersTypeData* parameters = new ciParametersTypeData(_parameters); parameters->translate_from(mdo->parameters_type_data()); @@ -273,7 +273,7 @@ bool ciMethodData::load_data() { void ciReceiverTypeData::translate_receiver_data_from(const ProfileData* data) { for (uint row = 0; row < row_limit(); row++) { Klass* k = data->as_ReceiverTypeData()->receiver(row); - if (k != NULL) { + if (k != nullptr) { if (k->is_loader_alive()) { ciKlass* klass = CURRENT_ENV->get_klass(k); set_receiver(row, klass); @@ -282,7 +282,7 @@ void ciReceiverTypeData::translate_receiver_data_from(const ProfileData* data) { clear_row(row); } } else { - set_receiver(row, NULL); + set_receiver(row, nullptr); } } } @@ -291,9 +291,9 @@ void ciTypeStackSlotEntries::translate_type_data_from(const TypeStackSlotEntries for (int i = 0; i < number_of_entries(); i++) { intptr_t k = entries->type(i); Klass* klass = (Klass*)klass_part(k); - if (klass != NULL && !klass->is_loader_alive()) { + if (klass != nullptr && !klass->is_loader_alive()) { // With concurrent class unloading, the MDO could have stale metadata; override it - TypeStackSlotEntries::set_type(i, TypeStackSlotEntries::with_status((Klass*)NULL, k)); + TypeStackSlotEntries::set_type(i, TypeStackSlotEntries::with_status((Klass*)nullptr, k)); } else { TypeStackSlotEntries::set_type(i, translate_klass(k)); } @@ -303,9 +303,9 @@ void ciTypeStackSlotEntries::translate_type_data_from(const TypeStackSlotEntries void ciReturnTypeEntry::translate_type_data_from(const ReturnTypeEntry* ret) { intptr_t k = ret->type(); Klass* klass = (Klass*)klass_part(k); - if (klass != NULL && !klass->is_loader_alive()) { + if (klass != nullptr && !klass->is_loader_alive()) { // With concurrent class unloading, the MDO could have stale metadata; override it - set_type(ReturnTypeEntry::with_status((Klass*)NULL, k)); + set_type(ReturnTypeEntry::with_status((Klass*)nullptr, k)); } else { set_type(translate_klass(k)); } @@ -320,7 +320,7 @@ void ciSpeculativeTrapData::translate_from(const ProfileData* data) { // Get the data at an arbitrary (sort of) data index. ciProfileData* ciMethodData::data_at(int data_index) { if (out_of_bounds(data_index)) { - return NULL; + return nullptr; } DataLayout* data_layout = data_layout_at(data_index); return data_from(data_layout); @@ -331,7 +331,7 @@ ciProfileData* ciMethodData::data_from(DataLayout* data_layout) { case DataLayout::no_tag: default: ShouldNotReachHere(); - return NULL; + return nullptr; case DataLayout::bit_data_tag: return new ciBitData(data_layout); case DataLayout::counter_data_tag: @@ -371,7 +371,7 @@ DataLayout* ciMethodData::next_data_layout(DataLayout* current) { int current_index = dp_to_di((address)current); int next_index = current_index + current->size_in_bytes(); if (out_of_bounds(next_index)) { - return NULL; + return nullptr; } DataLayout* next = data_layout_at(next_index); return next; @@ -386,11 +386,11 @@ ciProfileData* ciMethodData::bci_to_extra_data(int bci, ciMethod* m, bool& two_f case DataLayout::no_tag: _saw_free_extra_data = true; // observed an empty slot (common case) two_free_slots = (MethodData::next_extra(dp)->tag() == DataLayout::no_tag); - return NULL; + return nullptr; case DataLayout::arg_info_data_tag: - return NULL; // ArgInfoData is after the trap data right before the parameter data. + return nullptr; // ArgInfoData is after the trap data right before the parameter data. case DataLayout::bit_data_tag: - if (m == NULL && dp->bci() == bci) { + if (m == nullptr && dp->bci() == bci) { return new ciBitData(dp); } break; @@ -398,7 +398,7 @@ ciProfileData* ciMethodData::bci_to_extra_data(int bci, ciMethod* m, bool& two_f ciSpeculativeTrapData* data = new ciSpeculativeTrapData(dp); // data->method() might be null if the MDO is snapshotted // concurrently with a trap - if (m != NULL && data->method() == m && dp->bci() == bci) { + if (m != nullptr && data->method() == m && dp->bci() == bci) { return data; } break; @@ -407,13 +407,13 @@ ciProfileData* ciMethodData::bci_to_extra_data(int bci, ciMethod* m, bool& two_f fatal("bad tag = %d", dp->tag()); } } - return NULL; + return nullptr; } -// Translate a bci to its corresponding data, or NULL. +// Translate a bci to its corresponding data, or nullptr. ciProfileData* ciMethodData::bci_to_data(int bci, ciMethod* m) { - // If m is not NULL we look for a SpeculativeTrapData entry - if (m == NULL) { + // If m is not nullptr we look for a SpeculativeTrapData entry + if (m == nullptr) { DataLayout* data_layout = data_layout_before(bci); for ( ; is_valid(data_layout); data_layout = next_data_layout(data_layout)) { if (data_layout->bci() == bci) { @@ -426,16 +426,16 @@ ciProfileData* ciMethodData::bci_to_data(int bci, ciMethod* m) { } bool two_free_slots = false; ciProfileData* result = bci_to_extra_data(bci, m, two_free_slots); - if (result != NULL) { + if (result != nullptr) { return result; } - if (m != NULL && !two_free_slots) { + if (m != nullptr && !two_free_slots) { // We were looking for a SpeculativeTrapData entry we didn't // find. Room is not available for more SpeculativeTrapData // entries, look in the non SpeculativeTrapData entries. - return bci_to_data(bci, NULL); + return bci_to_data(bci, nullptr); } - return NULL; + return nullptr; } // Conservatively decode the trap_state of a ciProfileData. @@ -450,7 +450,7 @@ int ciMethodData::has_trap_at(ciProfileData* data, int reason) { } else if (per_bc_reason == Deoptimization::Reason_none) { // We cannot conclude anything; a trap happened somewhere, maybe here. return -1; - } else if (data == NULL) { + } else if (data == nullptr) { // No profile here, not even an extra_data record allocated on the fly. // If there are empty extra_data records, and there had been a trap, // there would have been a non-null data pointer. If there are no @@ -465,7 +465,7 @@ int ciMethodData::has_trap_at(ciProfileData* data, int reason) { } int ciMethodData::trap_recompiled_at(ciProfileData* data) { - if (data == NULL) { + if (data == nullptr) { return (_saw_free_extra_data? 0: -1); // (see previous method) } else { return Deoptimization::trap_state_is_recompiled(data->trap_state())? 1: 0; @@ -475,10 +475,10 @@ int ciMethodData::trap_recompiled_at(ciProfileData* data) { void ciMethodData::clear_escape_info() { VM_ENTRY_MARK; MethodData* mdo = get_MethodData(); - if (mdo != NULL) { + if (mdo != nullptr) { mdo->clear_escape_info(); ArgInfoData *aid = arg_info(); - int arg_count = (aid == NULL) ? 0 : aid->number_of_args(); + int arg_count = (aid == nullptr) ? 0 : aid->number_of_args(); for (int i = 0; i < arg_count; i++) { set_arg_modified(i, 0); } @@ -490,7 +490,7 @@ void ciMethodData::clear_escape_info() { void ciMethodData::update_escape_info() { VM_ENTRY_MARK; MethodData* mdo = get_MethodData(); - if ( mdo != NULL) { + if ( mdo != nullptr) { mdo->set_eflags(_eflags); mdo->set_arg_local(_arg_local); mdo->set_arg_stack(_arg_stack); @@ -505,7 +505,7 @@ void ciMethodData::update_escape_info() { void ciMethodData::set_compilation_stats(short loops, short blocks) { VM_ENTRY_MARK; MethodData* mdo = get_MethodData(); - if (mdo != NULL) { + if (mdo != nullptr) { mdo->set_num_loops(loops); mdo->set_num_blocks(blocks); } @@ -514,7 +514,7 @@ void ciMethodData::set_compilation_stats(short loops, short blocks) { void ciMethodData::set_would_profile(bool p) { VM_ENTRY_MARK; MethodData* mdo = get_MethodData(); - if (mdo != NULL) { + if (mdo != nullptr) { mdo->set_would_profile(p); } } @@ -522,9 +522,9 @@ void ciMethodData::set_would_profile(bool p) { void ciMethodData::set_argument_type(int bci, int i, ciKlass* k) { VM_ENTRY_MARK; MethodData* mdo = get_MethodData(); - if (mdo != NULL) { + if (mdo != nullptr) { ProfileData* data = mdo->bci_to_data(bci); - if (data != NULL) { + if (data != nullptr) { if (data->is_CallTypeData()) { data->as_CallTypeData()->set_argument_type(i, k->get_Klass()); } else { @@ -538,7 +538,7 @@ void ciMethodData::set_argument_type(int bci, int i, ciKlass* k) { void ciMethodData::set_parameter_type(int i, ciKlass* k) { VM_ENTRY_MARK; MethodData* mdo = get_MethodData(); - if (mdo != NULL) { + if (mdo != nullptr) { mdo->parameters_type_data()->set_type(i, k->get_Klass()); } } @@ -546,9 +546,9 @@ void ciMethodData::set_parameter_type(int i, ciKlass* k) { void ciMethodData::set_return_type(int bci, ciKlass* k) { VM_ENTRY_MARK; MethodData* mdo = get_MethodData(); - if (mdo != NULL) { + if (mdo != nullptr) { ProfileData* data = mdo->bci_to_data(bci); - if (data != NULL) { + if (data != nullptr) { if (data->is_CallTypeData()) { data->as_CallTypeData()->set_return_type(k->get_Klass()); } else { @@ -585,7 +585,7 @@ void ciMethodData::set_arg_returned(int i) { void ciMethodData::set_arg_modified(int arg, uint val) { ArgInfoData *aid = arg_info(); - if (aid == NULL) + if (aid == nullptr) return; assert(arg >= 0 && arg < aid->number_of_args(), "valid argument number"); aid->set_arg_modified(arg, val); @@ -605,14 +605,14 @@ bool ciMethodData::is_arg_returned(int i) const { uint ciMethodData::arg_modified(int arg) const { ArgInfoData *aid = arg_info(); - if (aid == NULL) + if (aid == nullptr) return 0; assert(arg >= 0 && arg < aid->number_of_args(), "valid argument number"); return aid->arg_modified(arg); } ciParametersTypeData* ciMethodData::parameters_type_data() const { - return _parameters != NULL ? new ciParametersTypeData(_parameters) : NULL; + return _parameters != nullptr ? new ciParametersTypeData(_parameters) : nullptr; } ByteSize ciMethodData::offset_of_slot(ciProfileData* data, ByteSize slot_offset_in_data) { @@ -636,7 +636,7 @@ ciArgInfoData *ciMethodData::arg_info() const { if (dp->tag() == DataLayout::arg_info_data_tag) return new ciArgInfoData(dp); } - return NULL; + return nullptr; } @@ -646,7 +646,7 @@ void ciMethodData::print_impl(outputStream* st) { } void ciMethodData::dump_replay_data_type_helper(outputStream* out, int round, int& count, ProfileData* pdata, ByteSize offset, ciKlass* k) { - if (k != NULL) { + if (k != nullptr) { if (round == 0) { count++; } else { @@ -687,7 +687,7 @@ void ciMethodData::dump_replay_data_extra_data_helper(outputStream* out, int rou case DataLayout::speculative_trap_data_tag: { ciSpeculativeTrapData* data = new ciSpeculativeTrapData(dp); ciMethod* m = data->method(); - if (m != NULL) { + if (m != nullptr) { if (round == 0) { count++; } else { @@ -753,7 +753,7 @@ void ciMethodData::dump_replay_data(outputStream* out) { dump_replay_data_call_type_helper(out, round, count, call_type_data); } } - if (parameters != NULL) { + if (parameters != nullptr) { for (int i = 0; i < parameters->number_of_parameters(); i++) { dump_replay_data_type_helper(out, round, count, parameters, ParametersTypeData::type_offset(i), parameters->valid_parameter_type(i)); } @@ -774,7 +774,7 @@ void ciMethodData::print() { void ciMethodData::print_data_on(outputStream* st) { ResourceMark rm; ciParametersTypeData* parameters = parameters_type_data(); - if (parameters != NULL) { + if (parameters != nullptr) { parameters->print_data_on(st); } ciProfileData* data; @@ -858,11 +858,11 @@ void ciReceiverTypeData::print_receiver_data_on(outputStream* st) const { uint row; int entries = 0; for (row = 0; row < row_limit(); row++) { - if (receiver(row) != NULL) entries++; + if (receiver(row) != nullptr) entries++; } st->print_cr("count(%u) entries(%u)", count(), entries); for (row = 0; row < row_limit(); row++) { - if (receiver(row) != NULL) { + if (receiver(row) != nullptr) { tab(st); receiver(row)->print_name_on(st); st->print_cr("(%u)", receiver_count(row)); diff --git a/src/hotspot/share/ci/ciMethodData.hpp b/src/hotspot/share/ci/ciMethodData.hpp index cccea68a16e..9c6c877da67 100644 --- a/src/hotspot/share/ci/ciMethodData.hpp +++ b/src/hotspot/share/ci/ciMethodData.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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,11 +68,11 @@ class ciTypeEntries { protected: static intptr_t translate_klass(intptr_t k) { Klass* v = TypeEntries::valid_klass(k); - if (v != NULL) { + if (v != nullptr) { ciKlass* klass = CURRENT_ENV->get_klass(v); return with_status(klass, k); } - return with_status(NULL, k); + return with_status(nullptr, k); } public: @@ -80,10 +80,10 @@ public: if (!TypeEntries::is_type_none(k) && !TypeEntries::is_type_unknown(k)) { ciKlass* res = (ciKlass*)TypeEntries::klass_part(k); - assert(res != NULL, "invalid"); + assert(res != nullptr, "invalid"); return res; } else { - return NULL; + return nullptr; } } @@ -186,7 +186,7 @@ public: } #ifndef PRODUCT - void print_data_on(outputStream* st, const char* extra = NULL) const; + void print_data_on(outputStream* st, const char* extra = nullptr) const; #endif }; @@ -203,7 +203,7 @@ public: ciKlass* receiver(uint row) const { assert((uint)row < row_limit(), "oob"); ciKlass* recv = (ciKlass*)intptr_at(receiver0_offset + row * receiver_type_row_cell_count); - assert(recv == NULL || recv->is_klass(), "wrong type"); + assert(recv == nullptr || recv->is_klass(), "wrong type"); return recv; } @@ -213,7 +213,7 @@ public: } void translate_receiver_data_from(const ProfileData* data); #ifndef PRODUCT - void print_data_on(outputStream* st, const char* extra = NULL) const; + void print_data_on(outputStream* st, const char* extra = nullptr) const; void print_receiver_data_on(outputStream* st) const; #endif }; @@ -238,7 +238,7 @@ public: rtd_super()->translate_receiver_data_from(data); } #ifndef PRODUCT - void print_data_on(outputStream* st, const char* extra = NULL) const; + void print_data_on(outputStream* st, const char* extra = nullptr) const; #endif }; @@ -295,7 +295,7 @@ public: } #ifndef PRODUCT - void print_data_on(outputStream* st, const char* extra = NULL) const; + void print_data_on(outputStream* st, const char* extra = nullptr) const; #endif }; @@ -339,7 +339,7 @@ public: } #ifndef PRODUCT - void print_data_on(outputStream* st, const char* extra = NULL) const; + void print_data_on(outputStream* st, const char* extra = nullptr) const; #endif }; @@ -358,7 +358,7 @@ public: } #ifndef PRODUCT - void print_data_on(outputStream* st, const char* extra = NULL) const; + void print_data_on(outputStream* st, const char* extra = nullptr) const; #endif }; @@ -403,13 +403,13 @@ private: // Coherent snapshot of original header. MethodData::CompilerCounters _orig; - // Area dedicated to parameters. NULL if no parameter profiling for this method. + // Area dedicated to parameters. null if no parameter profiling for this method. DataLayout* _parameters; int parameters_size() const { - return _parameters == NULL ? 0 : parameters_type_data()->size_in_bytes(); + return _parameters == nullptr ? 0 : parameters_type_data()->size_in_bytes(); } - ciMethodData(MethodData* md = NULL); + ciMethodData(MethodData* md = nullptr); // Accessors int data_size() const { return _data_size; } @@ -443,7 +443,7 @@ private: DataLayout* data_layout_before(int bci) { // avoid SEGV on this edge case if (data_size() == 0) - return NULL; + return nullptr; DataLayout* layout = data_layout_at(hint_di()); if (layout->bci() <= bci) return layout; @@ -511,16 +511,16 @@ public: ciProfileData* first_data() { return data_at(first_di()); } ciProfileData* next_data(ciProfileData* current); DataLayout* next_data_layout(DataLayout* current); - bool is_valid(ciProfileData* current) { return current != NULL; } - bool is_valid(DataLayout* current) { return current != NULL; } + bool is_valid(ciProfileData* current) { return current != nullptr; } + bool is_valid(DataLayout* current) { return current != nullptr; } DataLayout* extra_data_base() const { return data_layout_at(data_size()); } DataLayout* args_data_limit() const { return data_layout_at(data_size() + extra_data_size() - parameters_size()); } - // Get the data at an arbitrary bci, or NULL if there is none. If m - // is not NULL look for a SpeculativeTrapData if any first. - ciProfileData* bci_to_data(int bci, ciMethod* m = NULL); + // Get the data at an arbitrary bci, or null if there is none. If m + // is not null look for a SpeculativeTrapData if any first. + ciProfileData* bci_to_data(int bci, ciMethod* m = nullptr); uint overflow_trap_count() const { return _orig.overflow_trap_count(); @@ -540,7 +540,7 @@ public: // Helpful query functions that decode trap_state. int has_trap_at(ciProfileData* data, int reason); int has_trap_at(int bci, ciMethod* m, int reason) { - assert((m != NULL) == Deoptimization::reason_is_speculate(reason), "inconsistent method/reason"); + assert((m != nullptr) == Deoptimization::reason_is_speculate(reason), "inconsistent method/reason"); return has_trap_at(bci_to_data(bci, m), reason); } int trap_recompiled_at(ciProfileData* data); diff --git a/src/hotspot/share/ci/ciObjArray.cpp b/src/hotspot/share/ci/ciObjArray.cpp index 09ade58e985..d06665d6163 100644 --- a/src/hotspot/share/ci/ciObjArray.cpp +++ b/src/hotspot/share/ci/ciObjArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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,7 +38,7 @@ ciObject* ciObjArray::obj_at(int index) { objArrayOop array = get_objArrayOop(); assert(index >= 0 && index < array->length(), "OOB access"); oop o = array->obj_at(index); - if (o == NULL) { + if (o == nullptr) { return ciNullObject::make(); } else { return CURRENT_ENV->get_object(o); diff --git a/src/hotspot/share/ci/ciObjArrayKlass.cpp b/src/hotspot/share/ci/ciObjArrayKlass.cpp index 1fc2934a25f..1b47702599b 100644 --- a/src/hotspot/share/ci/ciObjArrayKlass.cpp +++ b/src/hotspot/share/ci/ciObjArrayKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -48,7 +48,7 @@ ciObjArrayKlass::ciObjArrayKlass(Klass* k) : ciArrayKlass(k) { if (dimension() == 1) { _element_klass = _base_element_klass; } else { - _element_klass = NULL; + _element_klass = nullptr; } if (!ciObjectFactory::is_initialized()) { assert(_element_klass->is_java_lang_Object(), "only arrays of object are shared"); @@ -70,7 +70,7 @@ ciObjArrayKlass::ciObjArrayKlass(ciSymbol* array_name, if (dimension == 1) { _element_klass = base_element_klass; } else { - _element_klass = NULL; + _element_klass = nullptr; } } @@ -79,8 +79,8 @@ ciObjArrayKlass::ciObjArrayKlass(ciSymbol* array_name, // // What is the one-level element type of this array? ciKlass* ciObjArrayKlass::element_klass() { - if (_element_klass == NULL) { - assert(dimension() > 1, "_element_klass should not be NULL"); + if (_element_klass == nullptr) { + assert(dimension() > 1, "_element_klass should not be null"); // Produce the element klass. if (is_loaded()) { VM_ENTRY_MARK; @@ -179,11 +179,11 @@ ciKlass* ciObjArrayKlass::exact_klass() { ciType* base = base_element_type(); if (base->is_instance_klass()) { ciInstanceKlass* ik = base->as_instance_klass(); - if (ik->exact_klass() != NULL) { + if (ik->exact_klass() != nullptr) { return this; } } else if (base->is_primitive_type()) { return this; } - return NULL; + return nullptr; } diff --git a/src/hotspot/share/ci/ciObject.cpp b/src/hotspot/share/ci/ciObject.cpp index 793dda7f2ff..e2d7dddb6f2 100644 --- a/src/hotspot/share/ci/ciObject.cpp +++ b/src/hotspot/share/ci/ciObject.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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,7 +58,7 @@ ciObject::ciObject(oop o) { Handle obj(Thread::current(), o); _handle = JNIHandles::make_global(obj); } - _klass = NULL; + _klass = nullptr; assert(oopDesc::is_oop_or_null(o), "Checking"); } @@ -72,7 +72,7 @@ ciObject::ciObject(Handle h) { } else { _handle = JNIHandles::make_global(h); } - _klass = NULL; + _klass = nullptr; assert(oopDesc::is_oop_or_null(h()), "Checking"); } @@ -83,19 +83,19 @@ ciObject::ciObject(Handle h) { // klass/method, if that makes sense. ciObject::ciObject(ciKlass* klass) { ASSERT_IN_VM; - assert(klass != NULL, "must supply klass"); - _handle = NULL; + assert(klass != nullptr, "must supply klass"); + _handle = nullptr; _klass = klass; } // ------------------------------------------------------------------ // ciObject::ciObject // -// NULL variant. Used only by ciNullObject. +// null variant. Used only by ciNullObject. ciObject::ciObject() { ASSERT_IN_VM; - _handle = NULL; - _klass = NULL; + _handle = nullptr; + _klass = nullptr; } // ------------------------------------------------------------------ @@ -111,14 +111,14 @@ oop ciObject::get_oop() const { // // Get the ciKlass of this ciObject. ciKlass* ciObject::klass() { - if (_klass == NULL) { - if (_handle == NULL) { - // When both _klass and _handle are NULL, we are dealing + if (_klass == nullptr) { + if (_handle == nullptr) { + // When both _klass and _handle are null, we are dealing // with the distinguished instance of ciNullObject. // No one should ask it for its klass. assert(is_null_object(), "must be null object"); ShouldNotReachHere(); - return NULL; + return nullptr; } GUARDED_VM_ENTRY( @@ -164,7 +164,7 @@ int ciObject::hash() { // This method should be changed to return an generified address // to discourage use of the JNI handle. jobject ciObject::constant_encoding() { - assert(is_null_object() || handle() != NULL, "cannot embed null pointer"); + assert(is_null_object() || handle() != nullptr, "cannot embed null pointer"); return handle(); } @@ -189,7 +189,7 @@ bool ciObject::should_be_constant() { return true; } - return handle() == NULL; + return handle() == nullptr; } // ------------------------------------------------------------------ @@ -211,7 +211,7 @@ void ciObject::print(outputStream* st) { // Print debugging output about the oop this ciObject represents. void ciObject::print_oop(outputStream* st) { if (is_null_object()) { - st->print_cr("NULL"); + st->print_cr("nullptr"); } else if (!is_loaded()) { st->print_cr("UNLOADED"); } else { diff --git a/src/hotspot/share/ci/ciObject.hpp b/src/hotspot/share/ci/ciObject.hpp index d1118fa768d..213e147e2d3 100644 --- a/src/hotspot/share/ci/ciObject.hpp +++ b/src/hotspot/share/ci/ciObject.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ class ciObject : public ciBaseObject { private: // A JNI handle referring to an oop in the VM. This - // handle may, in a small set of cases, correctly be NULL. + // handle may, in a small set of cases, correctly be null. jobject _handle; ciKlass* _klass; @@ -120,7 +120,7 @@ public: // By convention the ciNullObject is considered loaded, and // primitive types are considered loaded. bool is_loaded() const { - return handle() != NULL || is_classless(); + return handle() != nullptr || is_classless(); } // Subclass casting with assertions. diff --git a/src/hotspot/share/ci/ciObjectFactory.cpp b/src/hotspot/share/ci/ciObjectFactory.cpp index d93cd4e4f56..ee099f46664 100644 --- a/src/hotspot/share/ci/ciObjectFactory.cpp +++ b/src/hotspot/share/ci/ciObjectFactory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -70,7 +70,7 @@ // problematic the underlying data structure can be switched to some // sort of balanced binary tree. -GrowableArray* ciObjectFactory::_shared_ci_metadata = NULL; +GrowableArray* ciObjectFactory::_shared_ci_metadata = nullptr; ciSymbol* ciObjectFactory::_shared_ci_symbols[vmSymbols::number_of_symbols()]; int ciObjectFactory::_shared_ident_limit = 0; volatile bool ciObjectFactory::_initialized = false; @@ -81,20 +81,20 @@ volatile bool ciObjectFactory::_initialized = false; ciObjectFactory::ciObjectFactory(Arena* arena, int expected_size) : _arena(arena), - _ci_metadata(arena, expected_size, 0, NULL), - _unloaded_methods(arena, 4, 0, NULL), - _unloaded_klasses(arena, 8, 0, NULL), - _unloaded_instances(arena, 4, 0, NULL), - _return_addresses(arena, 8, 0, NULL), - _symbols(arena, 100, 0, NULL), + _ci_metadata(arena, expected_size, 0, nullptr), + _unloaded_methods(arena, 4, 0, nullptr), + _unloaded_klasses(arena, 8, 0, nullptr), + _unloaded_instances(arena, 4, 0, nullptr), + _return_addresses(arena, 8, 0, nullptr), + _symbols(arena, 100, 0, nullptr), _next_ident(_shared_ident_limit), _non_perm_count(0) { for (int i = 0; i < NON_PERM_BUCKETS; i++) { - _non_perm_bucket[i] = NULL; + _non_perm_bucket[i] = nullptr; } // If the shared ci objects exist append them to this factory's objects - if (_shared_ci_metadata != NULL) { + if (_shared_ci_metadata != nullptr) { _ci_metadata.appendAll(_shared_ci_metadata); } } @@ -143,7 +143,7 @@ void ciObjectFactory::init_shared_objects() { for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) { BasicType t = (BasicType)i; - if (type2name(t) != NULL && !is_reference_type(t) && + if (type2name(t) != nullptr && !is_reference_type(t) && t != T_NARROWOOP && t != T_NARROWKLASS) { ciType::_basic_types[t] = new (_arena) ciType(t); init_ident_of(ciType::_basic_types[t]); @@ -174,7 +174,7 @@ void ciObjectFactory::init_shared_objects() { ciEnv::_unloaded_cisymbol = ciObjectFactory::get_symbol(vmSymbols::dummy_symbol()); // Create dummy InstanceKlass and ObjArrayKlass object and assign them idents - ciEnv::_unloaded_ciinstance_klass = new (_arena) ciInstanceKlass(ciEnv::_unloaded_cisymbol, NULL, NULL); + ciEnv::_unloaded_ciinstance_klass = new (_arena) ciInstanceKlass(ciEnv::_unloaded_cisymbol, nullptr, nullptr); init_ident_of(ciEnv::_unloaded_ciinstance_klass); ciEnv::_unloaded_ciobjarrayklass = new (_arena) ciObjArrayKlass(ciEnv::_unloaded_cisymbol, ciEnv::_unloaded_ciinstance_klass, 1); init_ident_of(ciEnv::_unloaded_ciobjarrayklass); @@ -236,7 +236,7 @@ ciObject* ciObjectFactory::get(oop key) { assert(Universe::heap()->is_in(key), "must be"); NonPermObject* &bucket = find_non_perm(key); - if (bucket != NULL) { + if (bucket != nullptr) { return bucket->object(); } @@ -272,7 +272,7 @@ ciMetadata* ciObjectFactory::cached_metadata(Metadata* key) { int index = _ci_metadata.find_sorted(key, found); if (!found) { - return NULL; + return nullptr; } return _ci_metadata.at(index)->as_metadata(); } @@ -297,7 +297,7 @@ ciMetadata* ciObjectFactory::get_metadata(Metadata* key) { #ifdef ASSERT if (CIObjectFactoryVerify) { - Metadata* last = NULL; + Metadata* last = nullptr; for (int j = 0; j < _ci_metadata.length(); j++) { Metadata* o = _ci_metadata.at(j)->constant_encoding(); assert(last < o, "out of order"); @@ -369,7 +369,7 @@ ciObject* ciObjectFactory::create_new_object(oop o) { // The oop is of some type not supported by the compiler interface. ShouldNotReachHere(); - return NULL; + return nullptr; } // ------------------------------------------------------------------ @@ -405,7 +405,7 @@ ciMetadata* ciObjectFactory::create_new_metadata(Metadata* o) { // The Metadata* is of some type not supported by the compiler interface. ShouldNotReachHere(); - return NULL; + return nullptr; } //------------------------------------------------------------------ @@ -420,8 +420,8 @@ ciMethod* ciObjectFactory::get_unloaded_method(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature, ciInstanceKlass* accessor) { - assert(accessor != NULL, "need origin of access"); - ciSignature* that = NULL; + assert(accessor != nullptr, "need origin of access"); + ciSignature* that = nullptr; for (int i = 0; i < _unloaded_methods.length(); i++) { ciMethod* entry = _unloaded_methods.at(i); if (entry->holder()->equals(holder) && @@ -433,7 +433,7 @@ ciMethod* ciObjectFactory::get_unloaded_method(ciInstanceKlass* holder, return entry; } else { // Lazily create ciSignature - if (that == NULL) that = new (arena()) ciSignature(accessor, constantPoolHandle(), signature); + if (that == nullptr) that = new (arena()) ciSignature(accessor, constantPoolHandle(), signature); if (entry->signature()->equals(that)) { // We've found a match. return entry; @@ -464,9 +464,9 @@ ciKlass* ciObjectFactory::get_unloaded_klass(ciKlass* accessing_klass, ciSymbol* name, bool create_if_not_found) { EXCEPTION_CONTEXT; - oop loader = NULL; - oop domain = NULL; - if (accessing_klass != NULL) { + oop loader = nullptr; + oop domain = nullptr; + if (accessing_klass != nullptr) { loader = accessing_klass->loader(); domain = accessing_klass->protection_domain(); } @@ -481,11 +481,11 @@ ciKlass* ciObjectFactory::get_unloaded_klass(ciKlass* accessing_klass, } if (!create_if_not_found) - return NULL; + return nullptr; // This is a new unloaded klass. Create it and stick it in // the cache. - ciKlass* new_klass = NULL; + ciKlass* new_klass = nullptr; // Two cases: this is an unloaded ObjArrayKlass or an // unloaded InstanceKlass. Deal with both. @@ -495,7 +495,7 @@ ciKlass* ciObjectFactory::get_unloaded_klass(ciKlass* accessing_klass, int dimension = ss.skip_array_prefix(); // skip all '['s BasicType element_type = ss.type(); assert(element_type != T_ARRAY, "unsuccessful decomposition"); - ciKlass* element_klass = NULL; + ciKlass* element_klass = nullptr; if (element_type == T_OBJECT) { ciEnv *env = CURRENT_THREAD_ENV; ciSymbol* ci_name = env->get_symbol(ss.as_symbol()); @@ -512,9 +512,9 @@ ciKlass* ciObjectFactory::get_unloaded_klass(ciKlass* accessing_klass, } new_klass = new (arena()) ciObjArrayKlass(name, element_klass, dimension); } else { - jobject loader_handle = NULL; - jobject domain_handle = NULL; - if (accessing_klass != NULL) { + jobject loader_handle = nullptr; + jobject domain_handle = nullptr; + if (accessing_klass != nullptr) { loader_handle = accessing_klass->loader_handle(); domain_handle = accessing_klass->protection_domain_handle(); } @@ -563,7 +563,7 @@ ciInstance* ciObjectFactory::get_unloaded_instance(ciInstanceKlass* instance_kla // // Currently, this ignores the parameters and returns a unique unloaded instance. ciInstance* ciObjectFactory::get_unloaded_klass_mirror(ciKlass* type) { - assert(ciEnv::_Class_klass != NULL, ""); + assert(ciEnv::_Class_klass != nullptr, ""); return get_unloaded_instance(ciEnv::_Class_klass->as_instance_klass()); } @@ -577,7 +577,7 @@ ciInstance* ciObjectFactory::get_unloaded_method_handle_constant(ciKlass* holde ciSymbol* name, ciSymbol* signature, int ref_kind) { - assert(ciEnv::_MethodHandle_klass != NULL, ""); + assert(ciEnv::_MethodHandle_klass != nullptr, ""); return get_unloaded_instance(ciEnv::_MethodHandle_klass->as_instance_klass()); } @@ -588,12 +588,12 @@ ciInstance* ciObjectFactory::get_unloaded_method_handle_constant(ciKlass* holde // // Currently, this ignores the parameters and returns a unique unloaded instance. ciInstance* ciObjectFactory::get_unloaded_method_type_constant(ciSymbol* signature) { - assert(ciEnv::_MethodType_klass != NULL, ""); + assert(ciEnv::_MethodType_klass != nullptr, ""); return get_unloaded_instance(ciEnv::_MethodType_klass->as_instance_klass()); } ciInstance* ciObjectFactory::get_unloaded_object_constant() { - assert(ciEnv::_Object_klass != NULL, ""); + assert(ciEnv::_Object_klass != nullptr, ""); return get_unloaded_instance(ciEnv::_Object_klass->as_instance_klass()); } @@ -633,7 +633,7 @@ void ciObjectFactory::init_ident_of(ciBaseObject* obj) { obj->set_ident(_next_ident++); } -static ciObjectFactory::NonPermObject* emptyBucket = NULL; +static ciObjectFactory::NonPermObject* emptyBucket = nullptr; // ------------------------------------------------------------------ // ciObjectFactory::find_non_perm @@ -645,7 +645,7 @@ ciObjectFactory::NonPermObject* &ciObjectFactory::find_non_perm(oop key) { assert(Universe::heap()->is_in(key), "must be"); ciMetadata* klass = get_metadata(key->klass()); NonPermObject* *bp = &_non_perm_bucket[(unsigned) klass->hash() % NON_PERM_BUCKETS]; - for (NonPermObject* p; (p = (*bp)) != NULL; bp = &p->next()) { + for (NonPermObject* p; (p = (*bp)) != nullptr; bp = &p->next()) { if (is_equal(p, key)) break; } return (*bp); diff --git a/src/hotspot/share/ci/ciReplay.cpp b/src/hotspot/share/ci/ciReplay.cpp index 77158cb614f..ad48903294c 100644 --- a/src/hotspot/share/ci/ciReplay.cpp +++ b/src/hotspot/share/ci/ciReplay.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -146,19 +146,19 @@ class CompileReplay : public StackObj { _protection_domain_initialized = false; _stream = os::fopen(filename, "rt"); - if (_stream == NULL) { + if (_stream == nullptr) { fprintf(stderr, "ERROR: Can't open replay file %s\n", filename); } - _ci_inline_records = NULL; - _error_message = NULL; + _ci_inline_records = nullptr; + _error_message = nullptr; _buffer_length = 32; _buffer = NEW_RESOURCE_ARRAY(char, _buffer_length); _bufptr = _buffer; - _imethod = NULL; - _iklass = NULL; + _imethod = nullptr; + _iklass = nullptr; _entry_bci = 0; _comp_level = 0; _version = 0; @@ -167,7 +167,7 @@ class CompileReplay : public StackObj { } ~CompileReplay() { - if (_stream != NULL) fclose(_stream); + if (_stream != nullptr) fclose(_stream); } void test() { @@ -183,11 +183,11 @@ class CompileReplay : public StackObj { } bool had_error() { - return _error_message != NULL || _thread->has_pending_exception(); + return _error_message != nullptr || _thread->has_pending_exception(); } bool can_replay() { - return !(_stream == NULL || had_error()); + return !(_stream == nullptr || had_error()); } void report_error(const char* msg) { @@ -246,20 +246,20 @@ class CompileReplay : public StackObj { } if (_bufptr == str) { // nothing here - return NULL; + return nullptr; } return str; } char* parse_string() { - if (had_error()) return NULL; + if (had_error()) return nullptr; skip_ws(); return scan_and_terminate(' '); } char* parse_quoted_string() { - if (had_error()) return NULL; + if (had_error()) return nullptr; skip_ws(); @@ -273,7 +273,7 @@ class CompileReplay : public StackObj { char* parse_escaped_string() { char* result = parse_quoted_string(); - if (result != NULL) { + if (result != nullptr) { unescape_string(result); } return result; @@ -282,7 +282,7 @@ class CompileReplay : public StackObj { // Look for the tag 'tag' followed by an bool parse_tag_and_count(const char* tag, int& length) { const char* t = parse_string(); - if (t == NULL) { + if (t == nullptr) { return false; } @@ -299,7 +299,7 @@ class CompileReplay : public StackObj { char* parse_data(const char* tag, int& length) { int read_size = 0; if (!parse_tag_and_count(tag, read_size)) { - return NULL; + return nullptr; } int actual_size = sizeof(MethodData::CompilerCounters); @@ -341,7 +341,7 @@ class CompileReplay : public StackObj { // Where each # is an intptr_t item intptr_t* parse_intptr_data(const char* tag, int& length) { if (!parse_tag_and_count(tag, length)) { - return NULL; + return nullptr; } intptr_t* result = NEW_RESOURCE_ARRAY(intptr_t, length); @@ -356,16 +356,16 @@ class CompileReplay : public StackObj { // Parse a possibly quoted version of a symbol into a symbolOop Symbol* parse_symbol() { const char* str = parse_escaped_string(); - if (str != NULL) { + if (str != nullptr) { Symbol* sym = SymbolTable::new_symbol(str); return sym; } - return NULL; + return nullptr; } bool parse_terminator() { char* terminator = parse_string(); - if (terminator != NULL && strcmp(terminator, ";") == 0) { + if (terminator != nullptr && strcmp(terminator, ";") == 0) { return true; } return false; @@ -376,12 +376,12 @@ class CompileReplay : public StackObj { // syntax: @cpi * ; Klass* parse_cp_ref(TRAPS) { JavaThread* thread = THREAD; - oop obj = NULL; + oop obj = nullptr; char* ref = parse_string(); if (strcmp(ref, "bci") == 0) { Method* m = parse_method(CHECK_NULL); - if (m == NULL) { - return NULL; + if (m == nullptr) { + return nullptr; } InstanceKlass* ik = m->method_holder(); @@ -393,7 +393,7 @@ class CompileReplay : public StackObj { int bci = parse_int("bci"); if (m->validate_bci(bci) != bci) { report_error("bad bci"); - return NULL; + return nullptr; } ik->link_class(CHECK_NULL); @@ -401,12 +401,12 @@ class CompileReplay : public StackObj { Bytecode_invoke bytecode = Bytecode_invoke_check(caller, bci); if (!Bytecodes::is_defined(bytecode.code()) || !bytecode.is_valid()) { report_error("no invoke found at bci"); - return NULL; + return nullptr; } bytecode.verify(); int index = bytecode.index(); - ConstantPoolCacheEntry* cp_cache_entry = NULL; + ConstantPoolCacheEntry* cp_cache_entry = nullptr; CallInfo callInfo; Bytecodes::Code bc = bytecode.invoke_code(); LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, bc, CHECK_NULL); @@ -423,7 +423,7 @@ class CompileReplay : public StackObj { cp_cache_entry->set_method_handle(cp, callInfo); } else { report_error("no dynamic invoke found"); - return NULL; + return nullptr; } char* dyno_ref = parse_string(); if (strcmp(dyno_ref, "") == 0) { @@ -431,12 +431,12 @@ class CompileReplay : public StackObj { } else if (strcmp(dyno_ref, "") == 0) { if (!parse_terminator()) { report_error("no dynamic invoke found"); - return NULL; + return nullptr; } Method* adapter = cp_cache_entry->f1_as_method(); - if (adapter == NULL) { + if (adapter == nullptr) { report_error("no adapter found"); - return NULL; + return nullptr; } return adapter->method_holder(); } else if (strcmp(dyno_ref, "") == 0) { @@ -445,18 +445,18 @@ class CompileReplay : public StackObj { obj = cp->resolve_possibly_cached_constant_at(bootstrap_specifier.bsm_index(), CHECK_NULL); } else { report_error("unrecognized token"); - return NULL; + return nullptr; } } else { // constant pool ref (MethodHandle) if (strcmp(ref, "cpi") != 0) { report_error("unexpected token"); - return NULL; + return nullptr; } Klass* k = parse_klass(CHECK_NULL); - if (k == NULL) { - return NULL; + if (k == nullptr) { + return nullptr; } InstanceKlass* ik = InstanceKlass::cast(k); const constantPoolHandle cp(Thread::current(), ik->constants()); @@ -465,28 +465,28 @@ class CompileReplay : public StackObj { if (cpi >= cp->length()) { report_error("bad cpi"); - return NULL; + return nullptr; } if (!cp->tag_at(cpi).is_method_handle()) { report_error("no method handle found at cpi"); - return NULL; + return nullptr; } ik->link_class(CHECK_NULL); obj = cp->resolve_possibly_cached_constant_at(cpi, CHECK_NULL); } - if (obj == NULL) { + if (obj == nullptr) { report_error("null cp object found"); - return NULL; + return nullptr; } - Klass* k = NULL; + Klass* k = nullptr; skip_ws(); // loop: read fields - char* field = NULL; + char* field = nullptr; do { field = parse_string(); - if (field == NULL) { + if (field == nullptr) { report_error("no field found"); - return NULL; + return nullptr; } if (strcmp(field, ";") == 0) { break; @@ -494,32 +494,32 @@ class CompileReplay : public StackObj { // raw Method* if (strcmp(field, "") == 0) { Method* vmtarget = java_lang_invoke_MemberName::vmtarget(obj); - k = (vmtarget == NULL) ? NULL : vmtarget->method_holder(); - if (k == NULL) { + k = (vmtarget == nullptr) ? nullptr : vmtarget->method_holder(); + if (k == nullptr) { report_error("null vmtarget found"); - return NULL; + return nullptr; } if (!parse_terminator()) { report_error("missing terminator"); - return NULL; + return nullptr; } return k; } obj = ciReplay::obj_field(obj, field); // array - if (obj != NULL && obj->is_objArray()) { + if (obj != nullptr && obj->is_objArray()) { objArrayOop arr = (objArrayOop)obj; int index = parse_int("index"); if (index >= arr->length()) { report_error("bad array index"); - return NULL; + return nullptr; } obj = arr->obj_at(index); } - } while (obj != NULL); - if (obj == NULL) { + } while (obj != nullptr); + if (obj == nullptr) { report_error("null field found"); - return NULL; + return nullptr; } k = obj->klass(); return k; @@ -535,17 +535,17 @@ class CompileReplay : public StackObj { if (cp_ref) { ++_bufptr; Klass* k = parse_cp_ref(CHECK_NULL); - if (k != NULL && !k->is_hidden()) { + if (k != nullptr && !k->is_hidden()) { report_error("expected hidden class"); - return NULL; + return nullptr; } return k; } char* str = parse_escaped_string(); Symbol* klass_name = SymbolTable::new_symbol(str); - if (klass_name != NULL) { - Klass* k = NULL; - if (_iklass != NULL) { + if (klass_name != nullptr) { + Klass* k = nullptr; + if (_iklass != nullptr) { k = (Klass*)_iklass->find_klass(ciSymbol::make(klass_name->as_C_string()))->constant_encoding(); } else { k = SystemDictionary::resolve_or_fail(klass_name, _loader, _protection_domain, true, THREAD); @@ -557,13 +557,13 @@ class CompileReplay : public StackObj { report_error(str); if (ReplayIgnoreInitErrors) { CLEAR_PENDING_EXCEPTION; - _error_message = NULL; + _error_message = nullptr; } - return NULL; + return nullptr; } return k; } - return NULL; + return nullptr; } // Lookup a klass @@ -575,14 +575,14 @@ class CompileReplay : public StackObj { // Parse the standard tuple of Method* parse_method(TRAPS) { InstanceKlass* k = (InstanceKlass*)parse_klass(CHECK_NULL); - if (k == NULL) { + if (k == nullptr) { report_error("Can't find holder klass"); - return NULL; + return nullptr; } Symbol* method_name = parse_symbol(); Symbol* method_signature = parse_symbol(); Method* m = k->find_method(method_name, method_signature); - if (m == NULL) { + if (m == nullptr) { report_error("Can't find method"); } return m; @@ -626,7 +626,7 @@ class CompileReplay : public StackObj { tty->print_cr("Error while parsing line %d at position %d: %s\n", line_no, pos, _error_message); if (ReplayIgnoreInitErrors) { CLEAR_PENDING_EXCEPTION; - _error_message = NULL; + _error_message = nullptr; } else { return; } @@ -638,7 +638,7 @@ class CompileReplay : public StackObj { void process_command(TRAPS) { char* cmd = parse_string(); - if (cmd == NULL) { + if (cmd == nullptr) { return; } if (strcmp("#", cmd) == 0) { @@ -679,7 +679,7 @@ class CompileReplay : public StackObj { // validation of comp_level bool is_valid_comp_level(int comp_level) { const int msg_len = 256; - char* msg = NULL; + char* msg = nullptr; if (!is_compile(comp_level)) { msg = NEW_RESOURCE_ARRAY(char, msg_len); jio_snprintf(msg, msg_len, "%d isn't compilation level", comp_level); @@ -690,7 +690,7 @@ class CompileReplay : public StackObj { msg = NEW_RESOURCE_ARRAY(char, msg_len); jio_snprintf(msg, msg_len, "compilation level %d requires C2", comp_level); } - if (msg != NULL) { + if (msg != nullptr) { report_error(msg); return false; } @@ -709,22 +709,22 @@ class CompileReplay : public StackObj { c = get_line(c); // Expecting only lines with "compile" command in inline replay file. char* cmd = parse_string(); - if (cmd == NULL || strcmp("compile", cmd) != 0) { - return NULL; + if (cmd == nullptr || strcmp("compile", cmd) != 0) { + return nullptr; } process_compile(CHECK_NULL); if (had_error()) { tty->print_cr("Error while parsing line %d: %s\n", line_no, _error_message); tty->print_cr("%s", _buffer); - return NULL; + return nullptr; } - if (_ci_inline_records != NULL && _ci_inline_records->length() > 0) { + if (_ci_inline_records != nullptr && _ci_inline_records->length() > 0) { // Found inlining record for the requested method. return _ci_inline_records; } line_no++; } - return NULL; + return nullptr; } // compile inline ( )* @@ -736,7 +736,7 @@ class CompileReplay : public StackObj { if (!is_valid_comp_level(comp_level)) { return; } - if (_imethod != NULL) { + if (_imethod != nullptr) { // Replay Inlining if (entry_bci != _entry_bci || comp_level != _comp_level) { return; @@ -778,7 +778,7 @@ class CompileReplay : public StackObj { new_ciInlineRecord(inl_method, bci, depth, inline_late); } } - if (_imethod != NULL) { + if (_imethod != nullptr) { return; // Replay Inlining } InstanceKlass* ik = method->method_holder(); @@ -796,13 +796,13 @@ class CompileReplay : public StackObj { } // Make sure the existence of a prior compile doesn't stop this one CompiledMethod* nm = (entry_bci != InvocationEntryBci) ? method->lookup_osr_nmethod_for(entry_bci, comp_level, true) : method->code(); - if (nm != NULL) { + if (nm != nullptr) { nm->make_not_entrant(); } replay_state = this; CompileBroker::compile_method(methodHandle(THREAD, method), entry_bci, comp_level, methodHandle(), 0, CompileTask::Reason_Replay, THREAD); - replay_state = NULL; + replay_state = nullptr; } // ciMethod @@ -826,7 +826,7 @@ class CompileReplay : public StackObj { // To be properly initialized, some profiling in the MDO needs the // method to be rewritten (number of arguments at a call for instance) method->method_holder()->link_class(CHECK); - assert(method->method_data() == NULL, "Should only be initialized once"); + assert(method->method_data() == nullptr, "Should only be initialized once"); ClassLoaderData* loader_data = method->method_holder()->class_loader_data(); MethodData* method_data = MethodData::allocate(loader_data, methodHandle(THREAD, method), CHECK); method->set_method_data(method_data); @@ -841,11 +841,11 @@ class CompileReplay : public StackObj { } rec->_orig_data = parse_data("orig", rec->_orig_data_length); - if (rec->_orig_data == NULL) { + if (rec->_orig_data == nullptr) { return; } rec->_data = parse_intptr_data("data", rec->_data_length); - if (rec->_data == NULL) { + if (rec->_data == nullptr) { return; } if (!parse_tag_and_count("oops", rec->_classes_length)) { @@ -889,8 +889,8 @@ class CompileReplay : public StackObj { Klass* k = parse_klass(CHECK); if (_version >= 1) { - if (!_protection_domain_initialized && k != NULL) { - assert(_protection_domain() == NULL, "must be uninitialized"); + if (!_protection_domain_initialized && k != nullptr) { + assert(_protection_domain() == nullptr, "must be uninitialized"); // The first entry is the holder class of the method for which a replay compilation is requested. // Use the same protection domain to load all subsequent classes in order to resolve all classes // in signatures of inlinees. This ensures that inlining can be done as stated in the replay file. @@ -900,11 +900,11 @@ class CompileReplay : public StackObj { _protection_domain_initialized = true; } - if (k == NULL) { + if (k == nullptr) { return; } const char* comment = parse_string(); - bool is_comment = comment != NULL && strcmp(comment, "#") == 0; + bool is_comment = comment != nullptr && strcmp(comment, "#") == 0; if (k->is_hidden() != is_comment) { report_error("hidden class with comment expected"); return; @@ -926,7 +926,7 @@ class CompileReplay : public StackObj { // constant pool tags are in the same state. void process_ciInstanceKlass(TRAPS) { InstanceKlass* k = (InstanceKlass*)parse_klass(CHECK); - if (k == NULL) { + if (k == nullptr) { skip_remaining(); return; } @@ -1025,8 +1025,8 @@ class CompileReplay : public StackObj { void process_staticfield(TRAPS) { InstanceKlass* k = (InstanceKlass *)parse_klass(CHECK); - if (k == NULL || ReplaySuppressInitializers == 0 || - (ReplaySuppressInitializers == 2 && k->class_loader() == NULL)) { + if (k == nullptr || ReplaySuppressInitializers == 0 || + (ReplaySuppressInitializers == 2 && k->class_loader() == nullptr)) { skip_remaining(); return; } @@ -1048,12 +1048,12 @@ class CompileReplay : public StackObj { oop java_mirror = k->java_mirror(); if (field_signature[0] == JVM_SIGNATURE_ARRAY) { int length = parse_int("array length"); - oop value = NULL; + oop value = nullptr; if (field_signature[1] == JVM_SIGNATURE_ARRAY) { // multi dimensional array ArrayKlass* kelem = (ArrayKlass *)parse_klass(CHECK); - if (kelem == NULL) { + if (kelem == nullptr) { return; } int rank = 0; @@ -1175,7 +1175,7 @@ class CompileReplay : public StackObj { return rec; } } - return NULL; + return nullptr; } // Create and initialize a record for a ciInstanceKlass which was present at replay dump time. @@ -1197,7 +1197,7 @@ class CompileReplay : public StackObj { return rec; } } - return NULL; + return nullptr; } // Create and initialize a record for a ciMethodData @@ -1223,7 +1223,7 @@ class CompileReplay : public StackObj { return rec; } } - return NULL; + return nullptr; } // Create and initialize a record for a ciInlineRecord @@ -1241,15 +1241,15 @@ class CompileReplay : public StackObj { // Lookup inlining data for a ciMethod ciInlineRecord* find_ciInlineRecord(Method* method, int bci, int depth) { - if (_ci_inline_records != NULL) { + if (_ci_inline_records != nullptr) { return find_ciInlineRecord(_ci_inline_records, method, bci, depth); } - return NULL; + return nullptr; } static ciInlineRecord* find_ciInlineRecord(GrowableArray* records, Method* method, int bci, int depth) { - if (records != NULL) { + if (records != nullptr) { const char* klass_name = method->method_holder()->name()->as_utf8(); const char* method_name = method->name()->as_utf8(); const char* signature = method->signature()->as_utf8(); @@ -1264,7 +1264,7 @@ class CompileReplay : public StackObj { } } } - return NULL; + return nullptr; } const char* error_message() { @@ -1272,7 +1272,7 @@ class CompileReplay : public StackObj { } void reset() { - _error_message = NULL; + _error_message = nullptr; _ci_method_records.clear(); _ci_method_data_records.clear(); } @@ -1335,13 +1335,13 @@ void ciReplay::replay(TRAPS) { } bool ciReplay::no_replay_state() { - return replay_state == NULL; + return replay_state == nullptr; } void* ciReplay::load_inline_data(ciMethod* method, int entry_bci, int comp_level) { if (FLAG_IS_DEFAULT(InlineDataFile)) { tty->print_cr("ERROR: no inline replay data file specified (use -XX:InlineDataFile=inline_pid12345.txt)."); - return NULL; + return nullptr; } VM_ENTRY_MARK; @@ -1349,7 +1349,7 @@ void* ciReplay::load_inline_data(ciMethod* method, int entry_bci, int comp_level CompileReplay rp(InlineDataFile, THREAD); if (!rp.can_replay()) { tty->print_cr("ciReplay: !rp.can_replay()"); - return NULL; + return nullptr; } void* data = rp.process_inline(method, method->get_Method(), entry_bci, comp_level, THREAD); if (HAS_PENDING_EXCEPTION) { @@ -1357,12 +1357,12 @@ void* ciReplay::load_inline_data(ciMethod* method, int entry_bci, int comp_level CLEAR_PENDING_EXCEPTION; java_lang_Throwable::print_stack_trace(throwable, tty); tty->cr(); - return NULL; + return nullptr; } if (rp.had_error()) { tty->print_cr("ciReplay: Failed on %s", rp.error_message()); - return NULL; + return nullptr; } return data; } @@ -1418,7 +1418,7 @@ void ciReplay::initialize(ciMethodData* m) { Method* method = m->get_MethodData()->method(); ciMethodDataRecord* rec = replay_state->find_ciMethodDataRecord(method); - if (rec == NULL) { + if (rec == nullptr) { // This indicates some mismatch with the original environment and // the replay environment though it's not always enough to // interfere with reproducing a bug @@ -1438,7 +1438,7 @@ void ciReplay::initialize(ciMethodData* m) { Klass *k = rec->_classes[i]; // In case this class pointer is is tagged, preserve the tag bits intptr_t status = 0; - if (k != NULL) { + if (k != nullptr) { status = ciTypeEntries::with_status(env->get_metadata(k)->as_klass(), rec->_data[rec->_classes_offsets[i]]); } rec->_data[rec->_classes_offsets[i]] = status; @@ -1468,25 +1468,25 @@ bool ciReplay::should_not_inline(ciMethod* method) { } VM_ENTRY_MARK; // ciMethod without a record shouldn't be inlined. - return replay_state->find_ciMethodRecord(method->get_Method()) == NULL; + return replay_state->find_ciMethodRecord(method->get_Method()) == nullptr; } bool ciReplay::should_inline(void* data, ciMethod* method, int bci, int inline_depth, bool& should_delay) { - if (data != NULL) { + if (data != nullptr) { GrowableArray* records = (GrowableArray*)data; VM_ENTRY_MARK; // Inline record are ordered by bci and depth. ciInlineRecord* record = CompileReplay::find_ciInlineRecord(records, method->get_Method(), bci, inline_depth); - if (record == NULL) { + if (record == nullptr) { return false; } should_delay = record->_inline_late; return true; - } else if (replay_state != NULL) { + } else if (replay_state != nullptr) { VM_ENTRY_MARK; // Inline record are ordered by bci and depth. ciInlineRecord* record = replay_state->find_ciInlineRecord(method->get_Method(), bci, inline_depth); - if (record == NULL) { + if (record == nullptr) { return false; } should_delay = record->_inline_late; @@ -1496,15 +1496,15 @@ bool ciReplay::should_inline(void* data, ciMethod* method, int bci, int inline_d } bool ciReplay::should_not_inline(void* data, ciMethod* method, int bci, int inline_depth) { - if (data != NULL) { + if (data != nullptr) { GrowableArray* records = (GrowableArray*)data; VM_ENTRY_MARK; // Inline record are ordered by bci and depth. - return CompileReplay::find_ciInlineRecord(records, method->get_Method(), bci, inline_depth) == NULL; - } else if (replay_state != NULL) { + return CompileReplay::find_ciInlineRecord(records, method->get_Method(), bci, inline_depth) == nullptr; + } else if (replay_state != nullptr) { VM_ENTRY_MARK; // Inline record are ordered by bci and depth. - return replay_state->find_ciInlineRecord(method->get_Method(), bci, inline_depth) == NULL; + return replay_state->find_ciInlineRecord(method->get_Method(), bci, inline_depth) == nullptr; } return false; } @@ -1519,7 +1519,7 @@ void ciReplay::initialize(ciMethod* m) { Method* method = m->get_Method(); ciMethodRecord* rec = replay_state->find_ciMethodRecord(method); - if (rec == NULL) { + if (rec == nullptr) { // This indicates some mismatch with the original environment and // the replay environment though it's not always enough to // interfere with reproducing a bug @@ -1533,7 +1533,7 @@ void ciReplay::initialize(ciMethod* m) { m->_interpreter_invocation_count = rec->_interpreter_invocation_count; m->_interpreter_throwout_count = rec->_interpreter_throwout_count; MethodCounters* mcs = method->get_method_counters(CHECK_AND_CLEAR); - guarantee(mcs != NULL, "method counters allocation failed"); + guarantee(mcs != nullptr, "method counters allocation failed"); mcs->invocation_counter()->_counter = rec->_invocation_counter; mcs->backedge_counter()->_counter = rec->_backedge_counter; } @@ -1544,7 +1544,7 @@ void ciReplay::initialize(ciInstanceKlass* ci_ik, InstanceKlass* ik) { ASSERT_IN_VM; ciInstanceKlassRecord* rec = replay_state->find_ciInstanceKlass(ik); - assert(rec != NULL, "ciInstanceKlass must be whitelisted"); + assert(rec != nullptr, "ciInstanceKlass must be whitelisted"); ci_ik->_java_mirror = CURRENT_ENV->get_instance(JNIHandles::resolve(rec->_java_mirror)); } @@ -1557,7 +1557,7 @@ bool ciReplay::is_loaded(Method* method) { ResourceMark rm; ciMethodRecord* rec = replay_state->find_ciMethodRecord(method); - return rec != NULL; + return rec != nullptr; } bool ciReplay::is_klass_unresolved(const InstanceKlass* klass) { @@ -1567,7 +1567,7 @@ bool ciReplay::is_klass_unresolved(const InstanceKlass* klass) { // Check if klass is found on whitelist. ciInstanceKlassRecord* rec = replay_state->find_ciInstanceKlass(klass); - return rec == NULL; + return rec == nullptr; } oop ciReplay::obj_field(oop obj, Symbol* name) { @@ -1595,14 +1595,14 @@ oop ciReplay::obj_field(oop obj, Symbol* name) { } ik = ik->java_super(); - } while (ik != NULL); - return NULL; + } while (ik != nullptr); + return nullptr; } oop ciReplay::obj_field(oop obj, const char *name) { Symbol* fname = SymbolTable::probe(name, (int)strlen(name)); - if (fname == NULL) { - return NULL; + if (fname == nullptr) { + return nullptr; } return obj_field(obj, fname); } diff --git a/src/hotspot/share/ci/ciSignature.cpp b/src/hotspot/share/ci/ciSignature.cpp index afb3188c8e4..efa056ef985 100644 --- a/src/hotspot/share/ci/ciSignature.cpp +++ b/src/hotspot/share/ci/ciSignature.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -39,10 +39,10 @@ // ------------------------------------------------------------------ // ciSignature::ciSignature ciSignature::ciSignature(ciKlass* accessing_klass, const constantPoolHandle& cpool, ciSymbol* symbol) - : _symbol(symbol), _accessing_klass(accessing_klass), _types(CURRENT_ENV->arena(), 8, 0, NULL) { + : _symbol(symbol), _accessing_klass(accessing_klass), _types(CURRENT_ENV->arena(), 8, 0, nullptr) { ASSERT_IN_VM; EXCEPTION_CONTEXT; - assert(accessing_klass != NULL, "need origin of access"); + assert(accessing_klass != nullptr, "need origin of access"); ciEnv* env = CURRENT_ENV; @@ -50,7 +50,7 @@ ciSignature::ciSignature(ciKlass* accessing_klass, const constantPoolHandle& cpo ResourceMark rm(THREAD); for (SignatureStream ss(symbol->get_symbol()); !ss.is_done(); ss.next()) { // Process one element of the signature - ciType* type = NULL; + ciType* type = nullptr; if (ss.is_reference()) { ciSymbol* klass_name = env->get_symbol(ss.as_symbol()); type = env->get_klass_by_name_impl(_accessing_klass, cpool, klass_name, false); diff --git a/src/hotspot/share/ci/ciStreams.hpp b/src/hotspot/share/ci/ciStreams.hpp index ac39f369cc1..7dae21a0290 100644 --- a/src/hotspot/share/ci/ciStreams.hpp +++ b/src/hotspot/share/ci/ciStreams.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -84,16 +84,16 @@ public: } ciBytecodeStream() { - reset_to_method(NULL); + reset_to_method(nullptr); } ciMethod* method() const { return _method; } void reset_to_method(ciMethod* m) { _method = m; - if (m == NULL) { - _holder = NULL; - reset(NULL, 0); + if (m == nullptr) { + _holder = nullptr; + reset(nullptr, 0); } else { _holder = m->holder(); reset(m->code(), m->code_size()); @@ -304,7 +304,7 @@ private: // holder is a method's holder ciKlass* _holder; public: - ciSignatureStream(ciSignature* signature, ciKlass* holder = NULL) { + ciSignatureStream(ciSignature* signature, ciKlass* holder = nullptr) { _sig = signature; _pos = 0; _holder = holder; @@ -331,9 +331,9 @@ public: // next klass in the signature ciKlass* next_klass() { ciKlass* sig_k; - if (_holder != NULL) { + if (_holder != nullptr) { sig_k = _holder; - _holder = NULL; + _holder = nullptr; } else { while (!type()->is_klass()) { next(); @@ -373,13 +373,13 @@ public: _pos = 0; _end = _method->_handler_count; - _exception_klass = NULL; + _exception_klass = nullptr; _bci = -1; _is_exact = false; } ciExceptionHandlerStream(ciMethod* method, int bci, - ciInstanceKlass* exception_klass = NULL, + ciInstanceKlass* exception_klass = nullptr, bool is_exact = false) { _method = method; @@ -388,9 +388,9 @@ public: _pos = -1; _end = _method->_handler_count + 1; // include the rethrow handler - _exception_klass = (exception_klass != NULL && exception_klass->is_loaded() + _exception_klass = (exception_klass != nullptr && exception_klass->is_loaded() ? exception_klass - : NULL); + : nullptr); _bci = bci; assert(_bci >= 0, "bci out of range"); _is_exact = is_exact; @@ -424,7 +424,7 @@ public: // Found final active catch block. _end = _pos+1; return; - } else if (_exception_klass == NULL || !handler->catch_klass()->is_loaded()) { + } else if (_exception_klass == nullptr || !handler->catch_klass()->is_loaded()) { // We cannot do any type analysis here. Must conservatively assume // catch block is reachable. return; @@ -457,7 +457,7 @@ public: // Implementation for declarations in bytecode.hpp -Bytecode::Bytecode(const ciBytecodeStream* stream, address bcp): _bcp(bcp != NULL ? bcp : stream->cur_bcp()), _code(Bytecodes::code_at(NULL, addr_at(0))) {} +Bytecode::Bytecode(const ciBytecodeStream* stream, address bcp): _bcp(bcp != nullptr ? bcp : stream->cur_bcp()), _code(Bytecodes::code_at(nullptr, addr_at(0))) {} Bytecode_lookupswitch::Bytecode_lookupswitch(const ciBytecodeStream* stream): Bytecode(stream) { verify(); } Bytecode_tableswitch::Bytecode_tableswitch(const ciBytecodeStream* stream): Bytecode(stream) { verify(); } diff --git a/src/hotspot/share/ci/ciSymbol.cpp b/src/hotspot/share/ci/ciSymbol.cpp index 70d6801b946..40b23deaa7f 100644 --- a/src/hotspot/share/ci/ciSymbol.cpp +++ b/src/hotspot/share/ci/ciSymbol.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -36,7 +36,7 @@ ciSymbol::ciSymbol(Symbol* s, vmSymbolID sid) : _symbol(s), _sid(sid) { - assert(_symbol != NULL, "adding null symbol"); + assert(_symbol != nullptr, "adding null symbol"); _symbol->increment_refcount(); // increment ref count assert(sid_ok(), "sid must be consistent with vmSymbols"); } diff --git a/src/hotspot/share/ci/ciType.cpp b/src/hotspot/share/ci/ciType.cpp index d445f56b213..05645478086 100644 --- a/src/hotspot/share/ci/ciType.cpp +++ b/src/hotspot/share/ci/ciType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -111,7 +111,7 @@ ciType* ciType::make(BasicType t) { // Note: Bare T_ADDRESS means a raw pointer type, not a return_address. assert((uint)t < T_CONFLICT+1, "range check"); if (t == T_OBJECT) return ciEnv::_Object_klass; // java/lang/Object - assert(_basic_types[t] != NULL, "domain check"); + assert(_basic_types[t] != nullptr, "domain check"); return _basic_types[t]; } diff --git a/src/hotspot/share/ci/ciTypeFlow.cpp b/src/hotspot/share/ci/ciTypeFlow.cpp index ff9859bf98f..7ace4a194b5 100644 --- a/src/hotspot/share/ci/ciTypeFlow.cpp +++ b/src/hotspot/share/ci/ciTypeFlow.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -57,12 +57,12 @@ // ciTypeFlow::JsrSet::JsrSet // Allocate growable array storage in Arena. -ciTypeFlow::JsrSet::JsrSet(Arena* arena, int default_len) : _set(arena, default_len, 0, NULL) { - assert(arena != NULL, "invariant"); +ciTypeFlow::JsrSet::JsrSet(Arena* arena, int default_len) : _set(arena, default_len, 0, nullptr) { + assert(arena != nullptr, "invariant"); } // Allocate growable array storage in current ResourceArea. -ciTypeFlow::JsrSet::JsrSet(int default_len) : _set(default_len, 0, NULL) {} +ciTypeFlow::JsrSet::JsrSet(int default_len) : _set(default_len, 0, nullptr) {} // ------------------------------------------------------------------ // ciTypeFlow::JsrSet::copy_into @@ -167,7 +167,7 @@ void ciTypeFlow::JsrSet::insert_jsr_record(JsrRecord* record) { // Insert the record into the list. JsrRecord* swap = record; - JsrRecord* temp = NULL; + JsrRecord* temp = nullptr; for ( ; pos < len; pos++) { temp = _set.at(pos); _set.at_put(pos, swap); @@ -368,13 +368,13 @@ const ciTypeFlow::StateVector* ciTypeFlow::get_start_state() { ciTypeFlow* non_osr_flow = method()->get_flow_analysis(); if (non_osr_flow->failing()) { record_failure(non_osr_flow->failure_reason()); - return NULL; + return nullptr; } JsrSet* jsrs = new JsrSet(4); Block* non_osr_block = non_osr_flow->existing_block_at(start_bci(), jsrs); - if (non_osr_block == NULL) { + if (non_osr_block == nullptr) { record_failure("cannot reach OSR point"); - return NULL; + return nullptr; } // load up the non-OSR state at this point non_osr_block->copy_state_into(state); @@ -551,7 +551,7 @@ void ciTypeFlow::StateVector::push_translate(ciType* type) { void ciTypeFlow::StateVector::do_aaload(ciBytecodeStream* str) { pop_int(); ciObjArrayKlass* array_klass = pop_objArray(); - if (array_klass == NULL) { + if (array_klass == nullptr) { // Did aaload on a null reference; push a null and ignore the exception. // This instruction will never continue normally. All we have to do // is report a value that will meet correctly with any downstream @@ -588,7 +588,7 @@ void ciTypeFlow::StateVector::do_checkcast(ciBytecodeStream* str) { bool will_link; ciKlass* klass = str->get_klass(will_link); if (!will_link) { - // VM's interpreter will not load 'klass' if object is NULL. + // VM's interpreter will not load 'klass' if object is null. // Type flow after this block may still be needed in two situations: // 1) C2 uses do_null_assert() and continues compilation for later blocks // 2) C2 does an OSR compile in a later block (see bug 4778368). @@ -648,13 +648,13 @@ void ciTypeFlow::StateVector::do_getstatic(ciBytecodeStream* str) { void ciTypeFlow::StateVector::do_invoke(ciBytecodeStream* str, bool has_receiver) { bool will_link; - ciSignature* declared_signature = NULL; + ciSignature* declared_signature = nullptr; ciMethod* callee = str->get_method(will_link, &declared_signature); - assert(declared_signature != NULL, "cannot be null"); + assert(declared_signature != nullptr, "cannot be null"); if (!will_link) { // We weren't able to find the method. if (str->cur_bc() == Bytecodes::_invokedynamic) { - trap(str, NULL, + trap(str, nullptr, Deoptimization::make_trap_request (Deoptimization::Reason_uninitialized, Deoptimization::Action_reinterpret)); @@ -721,7 +721,7 @@ void ciTypeFlow::StateVector::do_jsr(ciBytecodeStream* str) { // ciTypeFlow::StateVector::do_ldc void ciTypeFlow::StateVector::do_ldc(ciBytecodeStream* str) { if (str->is_in_error()) { - trap(str, NULL, Deoptimization::make_trap_request(Deoptimization::Reason_unhandled, + trap(str, nullptr, Deoptimization::make_trap_request(Deoptimization::Reason_unhandled, Deoptimization::Action_none)); return; } @@ -834,9 +834,9 @@ void ciTypeFlow::StateVector::trap(ciBytecodeStream* str, ciKlass* klass, int in // Log information about this trap: CompileLog* log = outer()->env()->log(); - if (log != NULL) { + if (log != nullptr) { int mid = log->identify(outer()->method()); - int kid = (klass == NULL)? -1: log->identify(klass); + int kid = (klass == nullptr)? -1: log->identify(klass); log->begin_elem("uncommon_trap method='%d' bci='%d'", mid, str->cur_bci()); char buf[100]; log->print(" %s", Deoptimization::format_trap_request(buf, sizeof(buf), @@ -1567,7 +1567,7 @@ void ciTypeFlow::SuccIter::next() { next++; } _index = -1; - _succ = NULL; + _succ = nullptr; } // ------------------------------------------------------------------ @@ -1591,17 +1591,17 @@ void ciTypeFlow::SuccIter::set_succ(Block* succ) { // ciTypeFlow::Block::Block ciTypeFlow::Block::Block(ciTypeFlow* outer, ciBlock *ciblk, - ciTypeFlow::JsrSet* jsrs) : _predecessors(outer->arena(), 1, 0, NULL) { + ciTypeFlow::JsrSet* jsrs) : _predecessors(outer->arena(), 1, 0, nullptr) { _ciblock = ciblk; - _exceptions = NULL; - _exc_klasses = NULL; - _successors = NULL; + _exceptions = nullptr; + _exc_klasses = nullptr; + _successors = nullptr; _state = new (outer->arena()) StateVector(outer); JsrSet* new_jsrs = new (outer->arena()) JsrSet(outer->arena(), jsrs->size()); jsrs->copy_into(new_jsrs); _jsrs = new_jsrs; - _next = NULL; + _next = nullptr; _on_work_list = false; _backedge_copy = false; _has_monitorenter = false; @@ -1623,9 +1623,9 @@ ciTypeFlow::Block::Block(ciTypeFlow* outer, void ciTypeFlow::Block::df_init() { _pre_order = -1; assert(!has_pre_order(), ""); _post_order = -1; assert(!has_post_order(), ""); - _loop = NULL; + _loop = nullptr; _irreducible_entry = false; - _rpo_next = NULL; + _rpo_next = nullptr; } // ------------------------------------------------------------------ @@ -1636,7 +1636,7 @@ GrowableArray* ciTypeFlow::Block::successors(ciBytecodeStream* str, ciTypeFlow::StateVector* state, ciTypeFlow::JsrSet* jsrs) { - if (_successors == NULL) { + if (_successors == nullptr) { if (CITraceTypeFlow) { tty->print(">> Computing successors for block "); print_value_on(tty); @@ -1645,18 +1645,18 @@ ciTypeFlow::Block::successors(ciBytecodeStream* str, ciTypeFlow* analyzer = outer(); Arena* arena = analyzer->arena(); - Block* block = NULL; + Block* block = nullptr; bool has_successor = !has_trap() && (control() != ciBlock::fall_through_bci || limit() < analyzer->code_size()); if (!has_successor) { _successors = - new (arena) GrowableArray(arena, 1, 0, NULL); + new (arena) GrowableArray(arena, 1, 0, nullptr); // No successors } else if (control() == ciBlock::fall_through_bci) { assert(str->cur_bci() == limit(), "bad block end"); // This block simply falls through to the next. _successors = - new (arena) GrowableArray(arena, 1, 0, NULL); + new (arena) GrowableArray(arena, 1, 0, nullptr); Block* block = analyzer->block_at(limit(), _jsrs); assert(_successors->length() == FALL_THROUGH, ""); @@ -1665,7 +1665,7 @@ ciTypeFlow::Block::successors(ciBytecodeStream* str, int current_bci = str->cur_bci(); int next_bci = str->next_bci(); int branch_bci = -1; - Block* target = NULL; + Block* target = nullptr; assert(str->next_bci() == limit(), "bad block end"); // This block is not a simple fall-though. Interpret // the current bytecode to find our successors. @@ -1681,7 +1681,7 @@ ciTypeFlow::Block::successors(ciBytecodeStream* str, // Our successors are the branch target and the next bci. branch_bci = str->get_dest(); _successors = - new (arena) GrowableArray(arena, 2, 0, NULL); + new (arena) GrowableArray(arena, 2, 0, nullptr); assert(_successors->length() == IF_NOT_TAKEN, ""); _successors->append(analyzer->block_at(next_bci, jsrs)); assert(_successors->length() == IF_TAKEN, ""); @@ -1691,7 +1691,7 @@ ciTypeFlow::Block::successors(ciBytecodeStream* str, case Bytecodes::_goto: branch_bci = str->get_dest(); _successors = - new (arena) GrowableArray(arena, 1, 0, NULL); + new (arena) GrowableArray(arena, 1, 0, nullptr); assert(_successors->length() == GOTO_TARGET, ""); _successors->append(analyzer->block_at(branch_bci, jsrs)); break; @@ -1699,7 +1699,7 @@ ciTypeFlow::Block::successors(ciBytecodeStream* str, case Bytecodes::_jsr: branch_bci = str->get_dest(); _successors = - new (arena) GrowableArray(arena, 1, 0, NULL); + new (arena) GrowableArray(arena, 1, 0, nullptr); assert(_successors->length() == GOTO_TARGET, ""); _successors->append(analyzer->block_at(branch_bci, jsrs)); break; @@ -1707,7 +1707,7 @@ ciTypeFlow::Block::successors(ciBytecodeStream* str, case Bytecodes::_goto_w: case Bytecodes::_jsr_w: _successors = - new (arena) GrowableArray(arena, 1, 0, NULL); + new (arena) GrowableArray(arena, 1, 0, nullptr); assert(_successors->length() == GOTO_TARGET, ""); _successors->append(analyzer->block_at(str->get_far_dest(), jsrs)); break; @@ -1717,7 +1717,7 @@ ciTypeFlow::Block::successors(ciBytecodeStream* str, int len = tableswitch.length(); _successors = - new (arena) GrowableArray(arena, len+1, 0, NULL); + new (arena) GrowableArray(arena, len+1, 0, nullptr); int bci = current_bci + tableswitch.default_offset(); Block* block = analyzer->block_at(bci, jsrs); assert(_successors->length() == SWITCH_DEFAULT, ""); @@ -1736,7 +1736,7 @@ ciTypeFlow::Block::successors(ciBytecodeStream* str, int npairs = lookupswitch.number_of_pairs(); _successors = - new (arena) GrowableArray(arena, npairs+1, 0, NULL); + new (arena) GrowableArray(arena, npairs+1, 0, nullptr); int bci = current_bci + lookupswitch.default_offset(); Block* block = analyzer->block_at(bci, jsrs); assert(_successors->length() == SWITCH_DEFAULT, ""); @@ -1756,13 +1756,13 @@ ciTypeFlow::Block::successors(ciBytecodeStream* str, case Bytecodes::_dreturn: case Bytecodes::_areturn: case Bytecodes::_return: _successors = - new (arena) GrowableArray(arena, 1, 0, NULL); + new (arena) GrowableArray(arena, 1, 0, nullptr); // No successors break; case Bytecodes::_ret: { _successors = - new (arena) GrowableArray(arena, 1, 0, NULL); + new (arena) GrowableArray(arena, 1, 0, nullptr); Cell local = state->local(str->get_index()); ciType* return_address = state->type_at(local); @@ -1794,7 +1794,7 @@ ciTypeFlow::Block::successors(ciBytecodeStream* str, // // Compute the exceptional successors and types for this Block. void ciTypeFlow::Block::compute_exceptions() { - assert(_exceptions == NULL && _exc_klasses == NULL, "repeat"); + assert(_exceptions == nullptr && _exc_klasses == nullptr, "repeat"); if (CITraceTypeFlow) { tty->print(">> Computing exceptions for block "); @@ -1810,14 +1810,14 @@ void ciTypeFlow::Block::compute_exceptions() { // Allocate our growable arrays. int exc_count = str.count(); - _exceptions = new (arena) GrowableArray(arena, exc_count, 0, NULL); + _exceptions = new (arena) GrowableArray(arena, exc_count, 0, nullptr); _exc_klasses = new (arena) GrowableArray(arena, exc_count, - 0, NULL); + 0, nullptr); for ( ; !str.is_done(); str.next()) { ciExceptionHandler* handler = str.handler(); int bci = handler->handler_bci(); - ciInstanceKlass* klass = NULL; + ciInstanceKlass* klass = nullptr; if (bci == -1) { // There is no catch all. It is possible to exit the method. break; @@ -1875,7 +1875,7 @@ ciTypeFlow::Block* ciTypeFlow::Block::looping_succ(ciTypeFlow::Loop* lp) { return succ; } } - return NULL; + return nullptr; } #ifndef PRODUCT @@ -1902,18 +1902,18 @@ void ciTypeFlow::Block::print_on(outputStream* st) const { st->print (" "); print_value_on(st); st->print(" Stored locals: "); def_locals()->print_on(st, outer()->method()->max_locals()); tty->cr(); - if (loop() && loop()->parent() != NULL) { + if (loop() && loop()->parent() != nullptr) { st->print(" loops:"); Loop* lp = loop(); do { st->print(" %d<-%d", lp->head()->pre_order(),lp->tail()->pre_order()); if (lp->is_irreducible()) st->print("(ir)"); lp = lp->parent(); - } while (lp->parent() != NULL); + } while (lp->parent() != nullptr); } st->cr(); _state->print_on(st); - if (_successors == NULL) { + if (_successors == nullptr) { st->print_cr(" No successor information"); } else { int num_successors = _successors->length(); @@ -1937,7 +1937,7 @@ void ciTypeFlow::Block::print_on(outputStream* st) const { st->cr(); } } - if (_exceptions == NULL) { + if (_exceptions == nullptr) { st->print_cr(" No exception information"); } else { int num_exceptions = _exceptions->length(); @@ -1987,17 +1987,17 @@ ciTypeFlow::ciTypeFlow(ciEnv* env, ciMethod* method, int osr_bci) { _method = method; _has_irreducible_entry = false; _osr_bci = osr_bci; - _failure_reason = NULL; + _failure_reason = nullptr; assert(0 <= start_bci() && start_bci() < code_size() , "correct osr_bci argument: 0 <= %d < %d", start_bci(), code_size()); - _work_list = NULL; + _work_list = nullptr; int ciblock_count = _method->get_method_blocks()->num_blocks(); _idx_to_blocklist = NEW_ARENA_ARRAY(arena(), GrowableArray*, ciblock_count); for (int i = 0; i < ciblock_count; i++) { - _idx_to_blocklist[i] = NULL; + _idx_to_blocklist[i] = nullptr; } - _block_map = NULL; // until all blocks are seen - _jsr_records = NULL; + _block_map = nullptr; // until all blocks are seen + _jsr_records = nullptr; } // ------------------------------------------------------------------ @@ -2008,7 +2008,7 @@ ciTypeFlow::Block* ciTypeFlow::work_list_next() { assert(!work_list_empty(), "work list must not be empty"); Block* next_block = _work_list; _work_list = next_block->next(); - next_block->set_next(NULL); + next_block->set_next(nullptr); next_block->set_on_work_list(false); return next_block; } @@ -2031,16 +2031,16 @@ void ciTypeFlow::add_to_work_list(ciTypeFlow::Block* block) { // decreasing post order sort - Block* prev = NULL; + Block* prev = nullptr; Block* current = _work_list; int po = block->post_order(); - while (current != NULL) { + while (current != nullptr) { if (!current->has_post_order() || po > current->post_order()) break; prev = current; current = current->next(); } - if (prev == NULL) { + if (prev == nullptr) { block->set_next(_work_list); _work_list = block; } else { @@ -2070,10 +2070,10 @@ ciTypeFlow::Block* ciTypeFlow::block_at(int bci, ciTypeFlow::JsrSet* jsrs, Creat assert(ciblk->start_bci() == bci, "bad ciBlock boundaries"); Block* block = get_block_for(ciblk->index(), jsrs, option); - assert(block == NULL? (option == no_create): block->is_backedge_copy() == (option == create_backedge_copy), "create option consistent with result"); + assert(block == nullptr? (option == no_create): block->is_backedge_copy() == (option == create_backedge_copy), "create option consistent with result"); if (CITraceTypeFlow) { - if (block != NULL) { + if (block != nullptr) { tty->print(">> Found block "); block->print_value_on(tty); tty->cr(); @@ -2092,13 +2092,13 @@ ciTypeFlow::Block* ciTypeFlow::block_at(int bci, ciTypeFlow::JsrSet* jsrs, Creat // does not already exist. ciTypeFlow::JsrRecord* ciTypeFlow::make_jsr_record(int entry_address, int return_address) { - if (_jsr_records == NULL) { + if (_jsr_records == nullptr) { _jsr_records = new (arena()) GrowableArray(arena(), 2, 0, - NULL); + nullptr); } - JsrRecord* record = NULL; + JsrRecord* record = nullptr; int len = _jsr_records->length(); for (int i = 0; i < len; i++) { JsrRecord* record = _jsr_records->at(i); @@ -2229,8 +2229,8 @@ bool ciTypeFlow::clone_loop_heads(StateVector* temp_vector, JsrSet* temp_set) { // check _no_ shared head below us Loop* ch; - for (ch = lp->child(); ch != NULL && ch->head() != head; ch = ch->sibling()); - if (ch != NULL) + for (ch = lp->child(); ch != nullptr && ch->head() != head; ch = ch->sibling()); + if (ch != nullptr) continue; // Clone head @@ -2290,8 +2290,8 @@ ciTypeFlow::Block* ciTypeFlow::clone_loop_head(Loop* lp, StateVector* temp_vecto // Accumulate profiled count for all backedges that share this loop's head int total_count = lp->profiled_count(); - for (Loop* lp1 = lp->parent(); lp1 != NULL; lp1 = lp1->parent()) { - for (Loop* lp2 = lp1; lp2 != NULL; lp2 = lp2->sibling()) { + for (Loop* lp1 = lp->parent(); lp1 != nullptr; lp1 = lp1->parent()) { + for (Loop* lp2 = lp1; lp2 != nullptr; lp2 = lp2->sibling()) { if (lp2->head() == head && !lp2->tail()->is_backedge_copy()) { total_count += lp2->profiled_count(); } @@ -2302,8 +2302,8 @@ ciTypeFlow::Block* ciTypeFlow::clone_loop_head(Loop* lp, StateVector* temp_vecto int loops_with_shared_head = 0; Block* latest_tail = tail; bool done = false; - for (Loop* lp1 = lp; lp1 != NULL && !done; lp1 = lp1->parent()) { - for (Loop* lp2 = lp1; lp2 != NULL && !done; lp2 = lp2->sibling()) { + for (Loop* lp1 = lp; lp1 != nullptr && !done; lp1 = lp1->parent()) { + for (Loop* lp2 = lp1; lp2 != nullptr && !done; lp2 = lp2->sibling()) { if (lp2->head() == head && !lp2->tail()->is_backedge_copy()) { count += lp2->profiled_count(); if (lp2->tail()->post_order() < latest_tail->post_order()) { @@ -2422,7 +2422,7 @@ void ciTypeFlow::flow_block(ciTypeFlow::Block* block, } } - GrowableArray* successors = NULL; + GrowableArray* successors = nullptr; if (control != ciBlock::fall_through_bci) { // Check for exceptional control flow from this point. if (has_exceptions && can_trap(str)) { @@ -2441,7 +2441,7 @@ void ciTypeFlow::flow_block(ciTypeFlow::Block* block, state->apply_one_bytecode(&str); } else { // Fall through control - successors = block->successors(&str, NULL, NULL); + successors = block->successors(&str, nullptr, nullptr); } // Save set of locals defined in this block @@ -2461,19 +2461,19 @@ void ciTypeFlow::flow_block(ciTypeFlow::Block* block, // Advance to next loop tree using a preorder, left-to-right traversal. void ciTypeFlow::PreorderLoops::next() { assert(!done(), "must not be done."); - if (_current->child() != NULL) { + if (_current->child() != nullptr) { _current = _current->child(); - } else if (_current->sibling() != NULL) { + } else if (_current->sibling() != nullptr) { _current = _current->sibling(); } else { - while (_current != _root && _current->sibling() == NULL) { + while (_current != _root && _current->sibling() == nullptr) { _current = _current->parent(); } if (_current == _root) { - _current = NULL; + _current = nullptr; assert(done(), "must be done."); } else { - assert(_current->sibling() != NULL, "must be more to do"); + assert(_current->sibling() != nullptr, "must be more to do"); _current = _current->sibling(); } } @@ -2497,7 +2497,7 @@ int ciTypeFlow::Loop::profiled_count() { ciProfileData* data = methodData->bci_to_data(tail->control()); - if (data == NULL || !data->is_JumpData()) { + if (data == nullptr || !data->is_JumpData()) { _profiled_count = 0; return 0; } @@ -2596,12 +2596,12 @@ bool ciTypeFlow::Loop::at_insertion_point(Loop* lp, Loop* current) { // ascending on secondary key: loop tail's pre_order. ciTypeFlow::Loop* ciTypeFlow::Loop::sorted_merge(Loop* lp) { Loop* leaf = this; - Loop* prev = NULL; + Loop* prev = nullptr; Loop* current = leaf; - while (lp != NULL) { + while (lp != nullptr) { int lp_pre_order = lp->head()->pre_order(); // Find insertion point for "lp" - while (current != NULL) { + while (current != nullptr) { if (current == lp) { return leaf; // Already in list } @@ -2614,7 +2614,7 @@ ciTypeFlow::Loop* ciTypeFlow::Loop::sorted_merge(Loop* lp) { Loop* next_lp = lp->parent(); // Save future list of items to insert // Insert lp before current lp->set_parent(current); - if (prev != NULL) { + if (prev != nullptr) { prev->set_parent(lp); } else { leaf = lp; @@ -2631,10 +2631,10 @@ ciTypeFlow::Loop* ciTypeFlow::Loop::sorted_merge(Loop* lp) { // Incrementally build loop tree. void ciTypeFlow::build_loop_tree(Block* blk) { assert(!blk->is_post_visited(), "precondition"); - Loop* innermost = NULL; // merge of loop tree branches over all successors + Loop* innermost = nullptr; // merge of loop tree branches over all successors for (SuccIter iter(blk); !iter.done(); iter.next()) { - Loop* lp = NULL; + Loop* lp = nullptr; Block* succ = iter.succ(); if (!succ->is_post_visited()) { // Found backedge since predecessor post visited, but successor is not @@ -2642,7 +2642,7 @@ void ciTypeFlow::build_loop_tree(Block* blk) { // Create a LoopNode to mark this loop. lp = new (arena()) Loop(succ, blk); - if (succ->loop() == NULL) + if (succ->loop() == nullptr) succ->set_loop(lp); // succ->loop will be updated to innermost loop on a later call, when blk==succ @@ -2650,10 +2650,10 @@ void ciTypeFlow::build_loop_tree(Block* blk) { lp = succ->loop(); // If succ is loop head, find outer loop. - while (lp != NULL && lp->head() == succ) { + while (lp != nullptr && lp->head() == succ) { lp = lp->parent(); } - if (lp == NULL) { + if (lp == nullptr) { // Infinite loop, it's parent is the root lp = loop_tree_root(); } @@ -2670,7 +2670,7 @@ void ciTypeFlow::build_loop_tree(Block* blk) { add_to_work_list(succ); } Loop* plp = lp->parent(); - if (plp == NULL) { + if (plp == nullptr) { // This only happens for some irreducible cases. The parent // will be updated during a later pass. break; @@ -2679,11 +2679,11 @@ void ciTypeFlow::build_loop_tree(Block* blk) { } // Merge loop tree branch for all successors. - innermost = innermost == NULL ? lp : innermost->sorted_merge(lp); + innermost = innermost == nullptr ? lp : innermost->sorted_merge(lp); } // end loop - if (innermost == NULL) { + if (innermost == nullptr) { assert(blk->successors()->length() == 0, "CFG exit"); blk->set_loop(loop_tree_root()); } else if (innermost->head() == blk) { @@ -2692,7 +2692,7 @@ void ciTypeFlow::build_loop_tree(Block* blk) { #ifdef ASSERT assert(blk->loop()->head() == innermost->head(), "same head"); Loop* dl; - for (dl = innermost; dl != NULL && dl != blk->loop(); dl = dl->parent()); + for (dl = innermost; dl != nullptr && dl != blk->loop(); dl = dl->parent()); assert(dl == blk->loop(), "blk->loop() already in innermost list"); #endif blk->set_loop(innermost); @@ -2718,7 +2718,7 @@ void ciTypeFlow::build_loop_tree(Block* blk) { // // Returns true if lp is nested loop. bool ciTypeFlow::Loop::contains(ciTypeFlow::Loop* lp) const { - assert(lp != NULL, ""); + assert(lp != nullptr, ""); if (this == lp || head() == lp->head()) return true; int depth1 = depth(); int depth2 = lp->depth(); @@ -2737,7 +2737,7 @@ bool ciTypeFlow::Loop::contains(ciTypeFlow::Loop* lp) const { // Loop depth int ciTypeFlow::Loop::depth() const { int dp = 0; - for (Loop* lp = this->parent(); lp != NULL; lp = lp->parent()) + for (Loop* lp = this->parent(); lp != nullptr; lp = lp->parent()) dp++; return dp; } @@ -2754,7 +2754,7 @@ void ciTypeFlow::Loop::print(outputStream* st, int indent) const { st->print(" defs: "); def_locals()->print_on(st, _head->outer()->method()->max_locals()); st->cr(); - for (Loop* ch = child(); ch != NULL; ch = ch->sibling()) + for (Loop* ch = child(); ch != nullptr; ch = ch->sibling()) ch->print(st, indent+2); } #endif @@ -2783,7 +2783,7 @@ void ciTypeFlow::df_flow_types(Block* start, stk.push(start); _next_pre_order = 0; // initialize pre_order counter - _rpo_list = NULL; + _rpo_list = nullptr; int next_po = 0; // initialize post_order counter // Compute RPO and the control flow graph @@ -2861,7 +2861,7 @@ void ciTypeFlow::flow_types() { assert(_rpo_list == start, "must be start"); // Any loops found? - if (loop_tree_root()->child() != NULL && + if (loop_tree_root()->child() != nullptr && env()->comp_level() >= CompLevel_full_optimization) { // Loop optimizations are not performed on Tier1 compiles. @@ -2869,8 +2869,8 @@ void ciTypeFlow::flow_types() { // If some loop heads were cloned, recompute postorder and loop tree if (changed) { - loop_tree_root()->set_child(NULL); - for (Block* blk = _rpo_list; blk != NULL;) { + loop_tree_root()->set_child(nullptr); + for (Block* blk = _rpo_list; blk != nullptr;) { Block* next = blk->rpo_next(); blk->df_init(); blk = next; @@ -2904,7 +2904,7 @@ void ciTypeFlow::flow_types() { // // Create the block map, which indexes blocks in reverse post-order. void ciTypeFlow::map_blocks() { - assert(_block_map == NULL, "single initialization"); + assert(_block_map == nullptr, "single initialization"); int block_ct = _next_pre_order; _block_map = NEW_ARENA_ARRAY(arena(), Block*, block_ct); assert(block_ct == block_count(), ""); @@ -2916,10 +2916,10 @@ void ciTypeFlow::map_blocks() { _block_map[rpo] = blk; blk = blk->rpo_next(); } - assert(blk == NULL, "should be done"); + assert(blk == nullptr, "should be done"); for (int j = 0; j < block_ct; j++) { - assert(_block_map[j] != NULL, "must not drop any blocks"); + assert(_block_map[j] != nullptr, "must not drop any blocks"); Block* block = _block_map[j]; // Remove dead blocks from successor lists: for (int e = 0; e <= 1; e++) { @@ -2949,12 +2949,12 @@ void ciTypeFlow::map_blocks() { ciTypeFlow::Block* ciTypeFlow::get_block_for(int ciBlockIndex, ciTypeFlow::JsrSet* jsrs, CreateOption option) { Arena* a = arena(); GrowableArray* blocks = _idx_to_blocklist[ciBlockIndex]; - if (blocks == NULL) { + if (blocks == nullptr) { // Query only? - if (option == no_create) return NULL; + if (option == no_create) return nullptr; // Allocate the growable array. - blocks = new (a) GrowableArray(a, 4, 0, NULL); + blocks = new (a) GrowableArray(a, 4, 0, nullptr); _idx_to_blocklist[ciBlockIndex] = blocks; } @@ -2969,7 +2969,7 @@ ciTypeFlow::Block* ciTypeFlow::get_block_for(int ciBlockIndex, ciTypeFlow::JsrSe } // Query only? - if (option == no_create) return NULL; + if (option == no_create) return nullptr; // We did not find a compatible block. Create one. Block* new_block = new (a) Block(this, _method->get_method_blocks()->block(ciBlockIndex), jsrs); @@ -2984,7 +2984,7 @@ ciTypeFlow::Block* ciTypeFlow::get_block_for(int ciBlockIndex, ciTypeFlow::JsrSe int ciTypeFlow::backedge_copy_count(int ciBlockIndex, ciTypeFlow::JsrSet* jsrs) const { GrowableArray* blocks = _idx_to_blocklist[ciBlockIndex]; - if (blocks == NULL) { + if (blocks == nullptr) { return 0; } @@ -3061,7 +3061,7 @@ bool ciTypeFlow::is_dominated_by(int bci, int dom_bci) { while (changed) { changed = false; // Use reverse postorder iteration - for (Block* blk = _rpo_list; blk != NULL; blk = blk->rpo_next()) { + for (Block* blk = _rpo_list; blk != nullptr; blk = blk->rpo_next()) { if (blk->is_start()) { // Ignore start block continue; @@ -3102,10 +3102,10 @@ bool ciTypeFlow::is_dominated_by(int bci, int dom_bci) { // requests are not optional; if they fail the requestor is responsible for // copying the failure reason up to the ciEnv. (See Parse::Parse.) void ciTypeFlow::record_failure(const char* reason) { - if (env()->log() != NULL) { + if (env()->log() != nullptr) { env()->log()->elem("failure reason='%s' phase='typeflow'", reason); } - if (_failure_reason == NULL) { + if (_failure_reason == nullptr) { // Record the first failure reason. _failure_reason = reason; } @@ -3124,15 +3124,15 @@ void ciTypeFlow::print_on(outputStream* st) const { int limit_bci = code_size(); st->print_cr(" %d bytes", limit_bci); ciMethodBlocks* mblks = _method->get_method_blocks(); - ciBlock* current = NULL; + ciBlock* current = nullptr; for (int bci = 0; bci < limit_bci; bci++) { ciBlock* blk = mblks->block_containing(bci); - if (blk != NULL && blk != current) { + if (blk != nullptr && blk != current) { current = blk; current->print_on(st); GrowableArray* blocks = _idx_to_blocklist[blk->index()]; - int num_blocks = (blocks == NULL) ? 0 : blocks->length(); + int num_blocks = (blocks == nullptr) ? 0 : blocks->length(); if (num_blocks == 0) { st->print_cr(" No Blocks"); @@ -3156,7 +3156,7 @@ void ciTypeFlow::rpo_print_on(outputStream* st) const { method()->name()->print_symbol_on(st); int limit_bci = code_size(); st->print_cr(" %d bytes", limit_bci); - for (Block* blk = _rpo_list; blk != NULL; blk = blk->rpo_next()) { + for (Block* blk = _rpo_list; blk != nullptr; blk = blk->rpo_next()) { blk->print_on(st); st->print_cr("--------------------------------------------------------"); st->cr(); diff --git a/src/hotspot/share/ci/ciTypeFlow.hpp b/src/hotspot/share/ci/ciTypeFlow.hpp index 869acccf57f..187e750a556 100644 --- a/src/hotspot/share/ci/ciTypeFlow.hpp +++ b/src/hotspot/share/ci/ciTypeFlow.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -186,7 +186,7 @@ public: switch (t->basic_type()) { case T_LONG: return long2_type(); case T_DOUBLE: return double2_type(); - default: ShouldNotReachHere(); return NULL; + default: ShouldNotReachHere(); return nullptr; } } @@ -333,16 +333,16 @@ public: } // pop_objArray and pop_typeArray narrow the tos to ciObjArrayKlass // or ciTypeArrayKlass (resp.). In the rare case that an explicit - // null is popped from the stack, we return NULL. Caller beware. + // null is popped from the stack, we return null. Caller beware. ciObjArrayKlass* pop_objArray() { ciType* array = pop_value(); - if (array == null_type()) return NULL; + if (array == null_type()) return nullptr; assert(array->is_obj_array_klass(), "must be object array type"); return array->as_obj_array_klass(); } ciTypeArrayKlass* pop_typeArray() { ciType* array = pop_value(); - if (array == null_type()) return NULL; + if (array == null_type()) return nullptr; assert(array->is_type_array_klass(), "must be prim array type"); return array->as_type_array_klass(); } @@ -501,8 +501,8 @@ public: int _index; Block* _succ; public: - SuccIter() : _pred(NULL), _index(-1), _succ(NULL) {} - SuccIter(Block* pred) : _pred(pred), _index(-1), _succ(NULL) { next(); } + SuccIter() : _pred(nullptr), _index(-1), _succ(nullptr) {} + SuccIter(Block* pred) : _pred(pred), _index(-1), _succ(nullptr) { next(); } int index() { return _index; } Block* pred() { return _pred; } // Return predecessor bool done() { return _index < 0; } // Finished? @@ -590,7 +590,7 @@ public: assert(is_loop_head(), "only loop heads"); // Find outermost loop with same loop head Loop* lp = loop(); - while (lp->parent() != NULL) { + while (lp->parent() != nullptr) { if (lp->parent()->head() != lp->head()) break; lp = lp->parent(); } @@ -604,7 +604,7 @@ public: StateVector* state, JsrSet* jsrs); GrowableArray* successors() { - assert(_successors != NULL, "must be filled in"); + assert(_successors != nullptr, "must be filled in"); return _successors; } @@ -615,7 +615,7 @@ public: // Get the exceptional successors for this Block. GrowableArray* exceptions() { - if (_exceptions == NULL) { + if (_exceptions == nullptr) { compute_exceptions(); } return _exceptions; @@ -624,7 +624,7 @@ public: // Get the exception klasses corresponding to the // exceptional successors for this Block. GrowableArray* exc_klasses() { - if (_exc_klasses == NULL) { + if (_exc_klasses == nullptr) { compute_exceptions(); } return _exc_klasses; @@ -697,7 +697,7 @@ public: Block* looping_succ(Loop* lp); // Successor inside of loop bool is_single_entry_loop_head() const { if (!is_loop_head()) return false; - for (Loop* lp = loop(); lp != NULL && lp->head() == this; lp = lp->parent()) + for (Loop* lp = loop(); lp != nullptr && lp->head() == this; lp = lp->parent()) if (lp->is_irreducible()) return false; return true; } @@ -723,7 +723,7 @@ public: public: Loop(Block* head, Block* tail) : - _parent(NULL), _sibling(NULL), _child(NULL), + _parent(nullptr), _sibling(nullptr), _child(nullptr), _head(head), _tail(tail), _irreducible(false), _def_locals(), _profiled_count(-1) {} @@ -773,7 +773,7 @@ public: Loop* _current; public: PreorderLoops(Loop* root) : _root(root), _current(root) {} - bool done() { return _current == NULL; } // Finished iterating? + bool done() { return _current == nullptr; } // Finished iterating? void next(); // Advance to next loop Loop* current() { return _current; } // Return current loop. }; @@ -818,11 +818,11 @@ public: int backedge_copy_count(int ciBlockIndex, JsrSet* jsrs) const; // Return an existing block containing bci which has a JsrSet compatible - // with jsrs, or NULL if there is none. + // with jsrs, or null if there is none. Block* existing_block_at(int bci, JsrSet* set) { return block_at(bci, set, no_create); } // Tell whether the flow analysis has encountered an error of some sort. - bool failing() { return env()->failing() || _failure_reason != NULL; } + bool failing() { return env()->failing() || _failure_reason != nullptr; } // Reason this compilation is failing, such as "too many basic blocks". const char* failure_reason() { return _failure_reason; } @@ -831,7 +831,7 @@ public: void record_failure(const char* reason); // Return the block of a given pre-order number. - int have_block_count() const { return _block_map != NULL; } + int have_block_count() const { return _block_map != nullptr; } int block_count() const { assert(have_block_count(), ""); return _next_pre_order; } Block* pre_order_at(int po) const { assert(0 <= po && po < block_count(), "out of bounds"); @@ -853,7 +853,7 @@ private: int _next_pre_order; // Are there more blocks on the work list? - bool work_list_empty() { return _work_list == NULL; } + bool work_list_empty() { return _work_list == nullptr; } // Get the next basic block from our work list. Block* work_list_next(); diff --git a/src/hotspot/share/ci/ciUtilities.cpp b/src/hotspot/share/ci/ciUtilities.cpp index b66b22b2265..931a1c75d60 100644 --- a/src/hotspot/share/ci/ciUtilities.cpp +++ b/src/hotspot/share/ci/ciUtilities.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -36,7 +36,7 @@ // basictype_to_str const char* basictype_to_str(BasicType t) { const char* str = type2name(t); - if (str == NULL) return "illegal"; + if (str == nullptr) return "illegal"; return str; }