< prev index next >
src/hotspot/share/gc/z/zObjectAllocator.cpp
Print this page
@@ -1,7 +1,7 @@
/*
- * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -23,10 +23,11 @@
#include "precompiled.hpp"
#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"
#include "gc/z/zThread.inline.hpp"
#include "gc/z/zUtils.inline.hpp"
@@ -41,16 +42,25 @@
static const ZStatCounter ZCounterUndoObjectAllocationSucceeded("Memory", "Undo Object Allocation Succeeded", ZStatUnitOpsPerSecond);
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) {
// Increment used bytes
Atomic::add(size, _used.addr());
@@ -70,11 +80,11 @@
uint8_t page_type,
size_t page_size,
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);
}
@@ -140,11 +150,11 @@
"Should be a Java, VM or Runtime worker thread");
// 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) {
assert(ZThread::is_worker(), "Should be a worker thread");
@@ -292,11 +302,11 @@
}
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();
}
return 0;
< prev index next >