--- old/src/hotspot/share/gc/z/zObjectAllocator.cpp 2019-11-19 19:37:22.792833176 +0100 +++ new/src/hotspot/share/gc/z/zObjectAllocator.cpp 2019-11-19 19:37:22.317817535 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -25,6 +25,7 @@ #include "gc/z/zCollectedHeap.hpp" #include "gc/z/zGlobals.hpp" #include "gc/z/zHeap.inline.hpp" +#include "gc/z/zHeuristics.hpp" #include "gc/z/zObjectAllocator.hpp" #include "gc/z/zPage.inline.hpp" #include "gc/z/zStat.hpp" @@ -43,12 +44,21 @@ static const ZStatCounter ZCounterUndoObjectAllocationFailed("Memory", "Undo Object Allocation Failed", ZStatUnitOpsPerSecond); ZObjectAllocator::ZObjectAllocator() : + _per_cpu_shared_small_page(ZHeuristics::per_cpu_shared_small_page()), _used(0), _undone(0), _shared_medium_page(NULL), _shared_small_page(NULL), _worker_small_page(NULL) {} +ZPage** ZObjectAllocator::shared_small_page_addr() { + return _per_cpu_shared_small_page ? _shared_small_page.addr() : _shared_small_page.addr(0); +} + +ZPage* const* ZObjectAllocator::shared_small_page_addr() const { + return _per_cpu_shared_small_page ? _shared_small_page.addr() : _shared_small_page.addr(0); +} + ZPage* ZObjectAllocator::alloc_page(uint8_t type, size_t size, ZAllocationFlags flags) { ZPage* const page = ZHeap::heap()->alloc_page(type, size, flags); if (page != NULL) { @@ -72,7 +82,7 @@ size_t size, ZAllocationFlags flags) { uintptr_t addr = 0; - ZPage* page = *shared_page; + ZPage* page = OrderAccess::load_acquire(shared_page); if (page != NULL) { addr = page->alloc_object_atomic(size); @@ -142,7 +152,7 @@ // Non-worker small page allocation can never use the reserve flags.set_no_reserve(); - return alloc_object_in_shared_page(_shared_small_page.addr(), ZPageTypeSmall, ZPageSizeSmall, size, flags); + return alloc_object_in_shared_page(shared_small_page_addr(), ZPageTypeSmall, ZPageSizeSmall, size, flags); } uintptr_t ZObjectAllocator::alloc_small_object_from_worker(size_t size, ZAllocationFlags flags) { @@ -294,7 +304,7 @@ size_t ZObjectAllocator::remaining() const { assert(ZThread::is_java(), "Should be a Java thread"); - ZPage* page = _shared_small_page.get(); + const ZPage* const page = OrderAccess::load_acquire(shared_small_page_addr()); if (page != NULL) { return page->remaining(); }