From bcb340da091e3287da8d2ecfcd017ebcc6613cae Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Tue, 23 Jan 2024 08:49:46 +0000 Subject: [PATCH] 8324286: Fix backsliding on use of nullptr instead of NULL Reviewed-by: jsjolen, coleenp, jwaters --- src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp | 6 +++--- src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp | 6 +++--- src/hotspot/cpu/s390/templateTable_s390.cpp | 4 ++-- src/hotspot/os/aix/os_aix.cpp | 4 ++-- src/hotspot/os/linux/os_linux.cpp | 2 +- src/hotspot/share/cds/filemap.cpp | 2 +- src/hotspot/share/prims/whitebox.cpp | 6 +++--- src/hotspot/share/runtime/os.hpp | 4 ++-- src/hotspot/share/services/heapDumper.cpp | 4 ++-- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp index 7b9784ec47a24..8910fba97a558 100644 --- a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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,10 +111,10 @@ void C2_MacroAssembler::fast_lock(Register objectReg, Register boxReg, Register // Handle existing monitor. bind(object_has_monitor); - // The object's monitor m is unlocked iff m->owner == NULL, + // The object's monitor m is unlocked iff m->owner == nullptr, // otherwise m->owner may contain a thread or a stack address. // - // Try to CAS m->owner from NULL to current thread. + // Try to CAS m->owner from null to current thread. add(tmp, disp_hdr, (in_bytes(ObjectMonitor::owner_offset())-markWord::monitor_value)); cmpxchg(tmp, zr, rthread, Assembler::xword, /*acquire*/ true, /*release*/ true, /*weak*/ false, tmp3Reg); // Sets flags for result diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp index 0617c37687ffa..e19b2f2cff532 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -121,10 +121,10 @@ void C2_MacroAssembler::fast_lock(Register objectReg, Register boxReg, // Handle existing monitor. bind(object_has_monitor); - // The object's monitor m is unlocked iff m->owner == NULL, + // The object's monitor m is unlocked iff m->owner == nullptr, // otherwise m->owner may contain a thread or a stack address. // - // Try to CAS m->owner from NULL to current thread. + // Try to CAS m->owner from null to current thread. add(tmp, disp_hdr, (in_bytes(ObjectMonitor::owner_offset()) - markWord::monitor_value)); cmpxchg(/*memory address*/tmp, /*expected value*/zr, /*new value*/xthread, Assembler::int64, Assembler::aq, Assembler::rl, /*result*/flag); // cas succeeds if flag == zr(expected) diff --git a/src/hotspot/cpu/s390/templateTable_s390.cpp b/src/hotspot/cpu/s390/templateTable_s390.cpp index 62d62a9842f83..1ab60959c0dcf 100644 --- a/src/hotspot/cpu/s390/templateTable_s390.cpp +++ b/src/hotspot/cpu/s390/templateTable_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -2868,7 +2868,7 @@ void TemplateTable::jvmti_post_field_mod(Register cache, __ z_lgr(fieldEntry, cache); if (is_static) { - // Life is simple. NULL the object pointer. + // Life is simple. Null the object pointer. __ clear_reg(obj, true, false); // Don't set CC. } else { // Life is harder. The stack holds the value on top, followed by diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp index adaab8914a7fc..a4aa662744eef 100644 --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -1584,7 +1584,7 @@ static char* reserve_shmated_memory (size_t bytes, char* requested_addr) { // Now attach the shared segment. // Note that we deliberately *don't* pass SHM_RND. The contract of os::attempt_reserve_memory_at() - - // which invokes this function with a request address != NULL - is to map at the specified address + // which invokes this function with a request address != nullptr - is to map at the specified address // excactly, or to fail. If the caller passed us an address that is not usable (aka not a valid segment // boundary), shmat should not round down the address, or think up a completely new one. // (In places where this matters, e.g. when reserving the heap, we take care of passing segment-aligned diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index df0ddbfed7dd3..266040dcd2236 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -4136,7 +4136,7 @@ char* os::pd_attempt_reserve_memory_at(char* requested_addr, size_t bytes, bool size_t os::vm_min_address() { // Determined by sysctl vm.mmap_min_addr. It exists as a safety zone to prevent - // NULL pointer dereferences. + // null pointer dereferences. // Most distros set this value to 64 KB. It *can* be zero, but rarely is. Here, // we impose a minimum value if vm.mmap_min_addr is too low, for increased protection. static size_t value = 0; diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp index c2bfec3dfeb18..5a0bf2e61b5d0 100644 --- a/src/hotspot/share/cds/filemap.cpp +++ b/src/hotspot/share/cds/filemap.cpp @@ -2156,7 +2156,7 @@ bool FileMapInfo::map_heap_region_impl() { if (_heap_pointers_need_patching) { char* bitmap_base = map_bitmap_region(); - if (bitmap_base == NULL) { + if (bitmap_base == nullptr) { log_info(cds)("CDS heap cannot be used because bitmap region cannot be mapped"); dealloc_heap_region(); unmap_region(MetaspaceShared::hp); diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index d70c775937fd0..92badfe0d8d75 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, 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 @@ -1890,7 +1890,7 @@ WB_END WB_ENTRY(jint, WB_getFieldCPIndex(JNIEnv* env, jobject wb, jclass klass, jint index)) InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass))); ConstantPool* cp = ik->constants(); - if (cp->cache() == NULL) { + if (cp->cache() == nullptr) { return -1; } return cp->resolved_field_entry_at(index)->constant_pool_index(); @@ -1908,7 +1908,7 @@ WB_END WB_ENTRY(jint, WB_getMethodCPIndex(JNIEnv* env, jobject wb, jclass klass, jint index)) InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass))); ConstantPool* cp = ik->constants(); - if (cp->cache() == NULL) { + if (cp->cache() == nullptr) { return -1; } return cp->resolved_method_entry_at(index)->constant_pool_index(); diff --git a/src/hotspot/share/runtime/os.hpp b/src/hotspot/share/runtime/os.hpp index f93328f52700b..d93c8f0969dfe 100644 --- a/src/hotspot/share/runtime/os.hpp +++ b/src/hotspot/share/runtime/os.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, 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 @@ -191,7 +191,7 @@ class os: AllStatic { static PageSizes _page_sizes; // The default value for os::vm_min_address() unless the platform knows better. This value - // is chosen to give us reasonable protection against NULL pointer dereferences while being + // is chosen to give us reasonable protection against null pointer dereferences while being // low enough to leave most of the valuable low-4gb address space open. static constexpr size_t _vm_min_address_default = 16 * M; diff --git a/src/hotspot/share/services/heapDumper.cpp b/src/hotspot/share/services/heapDumper.cpp index add86b338deef..656d6e2f1abcf 100644 --- a/src/hotspot/share/services/heapDumper.cpp +++ b/src/hotspot/share/services/heapDumper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, Alibaba Group Holding Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -680,7 +680,7 @@ DumpWriter::~DumpWriter(){ if (_tmp_buffer != nullptr) { os::free(_tmp_buffer); } - if (_writer != NULL) { + if (_writer != nullptr) { delete _writer; } _bytes_written = -1;