Skip to content

Commit

Permalink
Review - use explicit null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
kstefanj committed Sep 9, 2024
1 parent 6737ce0 commit fd5ad8b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
18 changes: 9 additions & 9 deletions src/hotspot/share/gc/z/zObjectAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,17 @@ void ZObjectAllocator::undo_alloc_page(ZPage* page) {
ZHeap::heap()->undo_alloc_page(page);
}

zaddress ZObjectAllocator::alloc_object_in_page_atomic(ZPage* page, size_t size) {
if (page == nullptr) {
return zaddress::null;
}
return page->alloc_object_atomic(size);
}

zaddress ZObjectAllocator::alloc_object_in_shared_page(ZPage** shared_page,
ZPageType page_type,
size_t page_size,
size_t size,
ZAllocationFlags flags) {
zaddress addr = zaddress::null;
ZPage* page = Atomic::load_acquire(shared_page);
zaddress addr = alloc_object_in_page_atomic(page, size);

if (page != nullptr) {
addr = page->alloc_object_atomic(size);
}

if (is_null(addr)) {
// Allocate new page
Expand Down Expand Up @@ -133,10 +130,13 @@ zaddress ZObjectAllocator::alloc_object_in_shared_page(ZPage** shared_page,

zaddress ZObjectAllocator::alloc_object_in_medium_page(size_t size,
ZAllocationFlags flags) {
zaddress addr = zaddress::null;
ZPage** shared_medium_page = _shared_medium_page.addr();
ZPage* page = Atomic::load_acquire(shared_medium_page);

zaddress addr = alloc_object_in_page_atomic(page, size);
if (page != nullptr) {
addr = page->alloc_object_atomic(size);
}

if (is_null(addr)) {
// When a new medium page is required, we synchronize the allocation
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/gc/z/zObjectAllocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class ZObjectAllocator {
zaddress alloc_medium_object(size_t size, ZAllocationFlags flags);
zaddress alloc_small_object(size_t size, ZAllocationFlags flags);
zaddress alloc_object(size_t size, ZAllocationFlags flags);
zaddress alloc_object_in_page_atomic(ZPage* page, size_t size);

public:
ZObjectAllocator(ZPageAge age);
Expand Down

0 comments on commit fd5ad8b

Please sign in to comment.