Skip to content

Commit

Permalink
8324286: Fix backsliding on use of nullptr instead of NULL
Browse files Browse the repository at this point in the history
Reviewed-by: jsjolen, coleenp, jwaters
  • Loading branch information
Kim Barrett committed Jan 23, 2024
1 parent 3696765 commit bcb340d
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/s390/templateTable_s390.cpp
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/os/aix/os_aix.cpp
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/cds/filemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/prims/whitebox.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/runtime/os.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/services/heapDumper.cpp
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bcb340d

Please sign in to comment.