From 6daff6b26946748360d59a12e9069a08ab5ca06d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Sj=C3=B6len?= Date: Thu, 2 Feb 2023 09:23:48 +0000 Subject: [PATCH] 8301502: Replace NULL with nullptr in os_cpu/bsd_x86 Reviewed-by: tschatzl, dholmes --- .../os_cpu/bsd_x86/javaThread_bsd_x86.cpp | 10 ++--- src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp | 42 +++++++++---------- .../os_cpu/bsd_x86/vm_version_bsd_x86.cpp | 4 +- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/hotspot/os_cpu/bsd_x86/javaThread_bsd_x86.cpp b/src/hotspot/os_cpu/bsd_x86/javaThread_bsd_x86.cpp index 90793839facd1..c636d147768d0 100644 --- a/src/hotspot/os_cpu/bsd_x86/javaThread_bsd_x86.cpp +++ b/src/hotspot/os_cpu/bsd_x86/javaThread_bsd_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -28,7 +28,7 @@ frame JavaThread::pd_last_frame() { assert(has_last_Java_frame(), "must have last_Java_sp() when suspended"); - vmassert(_anchor.last_Java_pc() != NULL, "not walkable"); + vmassert(_anchor.last_Java_pc() != nullptr, "not walkable"); return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc()); } @@ -61,7 +61,7 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) intptr_t* ret_fp; intptr_t* ret_sp; address addr = os::fetch_frame_from_context(uc, &ret_sp, &ret_fp); - if (addr == NULL || ret_sp == NULL ) { + if (addr == nullptr || ret_sp == nullptr ) { // ucontext wasn't useful return false; } @@ -69,8 +69,8 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) frame ret_frame(ret_sp, ret_fp, addr); if (!ret_frame.safe_for_sender(this)) { #if COMPILER2_OR_JVMCI - // C2 and JVMCI use ebp as a general register see if NULL fp helps - frame ret_frame2(ret_sp, NULL, addr); + // C2 and JVMCI use ebp as a general register see if null fp helps + frame ret_frame2(ret_sp, nullptr, addr); if (!ret_frame2.safe_for_sender(this)) { // nothing else to try if the frame isn't good return false; diff --git a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp b/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp index b5839300ef97c..6adbaa88b4003 100644 --- a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp +++ b/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.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 @@ -317,14 +317,14 @@ address os::fetch_frame_from_context(const void* ucVoid, address epc; const ucontext_t* uc = (const ucontext_t*)ucVoid; - if (uc != NULL) { + if (uc != nullptr) { epc = os::Posix::ucontext_get_pc(uc); if (ret_sp) *ret_sp = os::Bsd::ucontext_get_sp(uc); if (ret_fp) *ret_fp = os::Bsd::ucontext_get_fp(uc); } else { - epc = NULL; - if (ret_sp) *ret_sp = (intptr_t *)NULL; - if (ret_fp) *ret_fp = (intptr_t *)NULL; + epc = nullptr; + if (ret_sp) *ret_sp = (intptr_t *)nullptr; + if (ret_fp) *ret_fp = (intptr_t *)nullptr; } return epc; @@ -391,12 +391,12 @@ enum { bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info, ucontext_t* uc, JavaThread* thread) { // decide if this trap can be handled by a stub - address stub = NULL; + address stub = nullptr; - address pc = NULL; + address pc = nullptr; //%note os_trap_1 - if (info != NULL && uc != NULL && thread != NULL) { + if (info != nullptr && uc != nullptr && thread != nullptr) { pc = (address) os::Posix::ucontext_get_pc(uc); // Handle ALL stack overflow variations here @@ -422,7 +422,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info, // check is not required on other platforms, because on other // platforms we check for SIGSEGV only or SIGBUS only, where here // we have to check for both SIGSEGV and SIGBUS. - if (thread->thread_state() == _thread_in_Java && stub == NULL) { + if (thread->thread_state() == _thread_in_Java && stub == nullptr) { // Java thread running in Java code => find exception handler if any // a fault inside compiled code, the interpreter, or a stub @@ -431,8 +431,8 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info, #if defined(__APPLE__) // 32-bit Darwin reports a SIGBUS for nearly all memory access exceptions. // 64-bit Darwin may also use a SIGBUS (seen with compressed oops). - // Catching SIGBUS here prevents the implicit SIGBUS NULL check below from - // being called, so only do so if the implicit NULL check is not necessary. + // Catching SIGBUS here prevents the implicit SIGBUS null check below from + // being called, so only do so if the implicit null check is not necessary. } else if (sig == SIGBUS && !MacroAssembler::uses_implicit_null_check(info->si_addr)) { #else } else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) { @@ -441,9 +441,9 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info, // here if the underlying file has been truncated. // Do not crash the VM in such a case. CodeBlob* cb = CodeCache::find_blob(pc); - CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; + CompiledMethod* nm = (cb != nullptr) ? cb->as_compiled_method_or_null() : nullptr; bool is_unsafe_arraycopy = thread->doing_unsafe_access() && UnsafeCopyMemory::contains_pc(pc); - if ((nm != NULL && nm->has_unsafe_access()) || is_unsafe_arraycopy) { + if ((nm != nullptr && nm->has_unsafe_access()) || is_unsafe_arraycopy) { address next_pc = Assembler::locate_next_instruction(pc); if (is_unsafe_arraycopy) { next_pc = UnsafeCopyMemory::page_error_continue_pc(pc); @@ -552,7 +552,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info, // the si_code for this condition may change in the future. // Furthermore, a false-positive should be harmless. if (UnguardOnExecutionViolation > 0 && - stub == NULL && + stub == nullptr && (sig == SIGSEGV || sig == SIGBUS) && uc->context_trapno == trap_page_fault) { int page_size = os::vm_page_size(); @@ -615,9 +615,9 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info, } #endif // !AMD64 - if (stub != NULL) { + if (stub != nullptr) { // save all thread context in case we need to restore it - if (thread != NULL) thread->set_saved_exception_pc(pc); + if (thread != nullptr) thread->set_saved_exception_pc(pc); os::Posix::ucontext_set_pc(uc, stub); return true; @@ -640,7 +640,7 @@ juint os::cpu_microcode_revision() { juint result = 0; char data[8]; size_t sz = sizeof(data); - int ret = sysctlbyname("machdep.cpu.microcode_version", data, &sz, NULL, 0); + int ret = sysctlbyname("machdep.cpu.microcode_version", data, &sz, nullptr, 0); if (ret == 0) { if (sz == 4) result = *((juint*)data); if (sz == 8) result = *((juint*)data + 1); // upper 32-bits @@ -729,7 +729,7 @@ static void current_stack_region(address * bottom, size_t * size) { if ((*size) < (DEFAULT_MAIN_THREAD_STACK_PAGES * (size_t)getpagesize())) { char kern_osrelease[256]; size_t kern_osrelease_size = sizeof(kern_osrelease); - int ret = sysctlbyname("kern.osrelease", kern_osrelease, &kern_osrelease_size, NULL, 0); + int ret = sysctlbyname("kern.osrelease", kern_osrelease, &kern_osrelease_size, nullptr, 0); if (ret == 0) { // get the major number, atoi will ignore the minor amd micro portions of the version string if (atoi(kern_osrelease) >= OS_X_10_9_0_KERNEL_MAJOR_VERSION) { @@ -792,7 +792,7 @@ size_t os::current_stack_size() { // helper functions for fatal error handler void os::print_context(outputStream *st, const void *context) { - if (context == NULL) return; + if (context == nullptr) return; const ucontext_t *uc = (const ucontext_t*)context; @@ -842,7 +842,7 @@ void os::print_context(outputStream *st, const void *context) { } void os::print_tos_pc(outputStream *st, const void *context) { - if (context == NULL) return; + if (context == nullptr) return; const ucontext_t* uc = (const ucontext_t*)context; @@ -859,7 +859,7 @@ void os::print_tos_pc(outputStream *st, const void *context) { } void os::print_register_info(outputStream *st, const void *context) { - if (context == NULL) return; + if (context == nullptr) return; const ucontext_t *uc = (const ucontext_t*)context; diff --git a/src/hotspot/os_cpu/bsd_x86/vm_version_bsd_x86.cpp b/src/hotspot/os_cpu/bsd_x86/vm_version_bsd_x86.cpp index 05cb7ef99c337..3455a845eb97f 100644 --- a/src/hotspot/os_cpu/bsd_x86/vm_version_bsd_x86.cpp +++ b/src/hotspot/os_cpu/bsd_x86/vm_version_bsd_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2019, 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 @@ -35,7 +35,7 @@ bool VM_Version::is_cpu_emulated() { int ret = 0; size_t size = sizeof(ret); // Is this process being ran in Rosetta (i.e. emulation) mode on macOS? - if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) == -1) { + if (sysctlbyname("sysctl.proc_translated", &ret, &size, nullptr, 0) == -1) { // errno == ENOENT is a valid response, but anything else is a real error if (errno != ENOENT) { warning("unable to lookup sysctl.proc_translated");