From 1e76ba0cd0de38da6fc2b8147627496ee2f2837b Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Wed, 15 Nov 2023 01:09:09 +0000 Subject: [PATCH] 8319439: Move BufferNode from PtrQueue files to new files Reviewed-by: tschatzl, iwalulya --- src/hotspot/share/gc/g1/g1BarrierSet.hpp | 3 +- .../share/gc/g1/g1CardTableEntryClosure.hpp | 2 +- src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp | 1 + src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp | 1 + .../share/gc/g1/g1RedirtyCardsQueue.cpp | 1 + .../share/gc/g1/g1RedirtyCardsQueue.hpp | 3 +- src/hotspot/share/gc/g1/g1RemSet.cpp | 2 +- .../share/gc/g1/g1SATBMarkQueueSet.hpp | 3 +- .../gc/g1/g1YoungGCPostEvacuateTasks.cpp | 1 + .../share/gc/g1/jvmFlagConstraintsG1.cpp | 3 +- src/hotspot/share/gc/shared/bufferNode.cpp | 71 +++++++++ src/hotspot/share/gc/shared/bufferNode.hpp | 139 ++++++++++++++++++ src/hotspot/share/gc/shared/ptrQueue.cpp | 44 +----- src/hotspot/share/gc/shared/ptrQueue.hpp | 109 +------------- .../gc/shenandoah/shenandoahBarrierSet.hpp | 1 + .../shenandoah/shenandoahSATBMarkQueueSet.hpp | 1 + ...cator.cpp => test_bufferNodeAllocator.cpp} | 6 +- 17 files changed, 231 insertions(+), 160 deletions(-) create mode 100644 src/hotspot/share/gc/shared/bufferNode.cpp create mode 100644 src/hotspot/share/gc/shared/bufferNode.hpp rename test/hotspot/gtest/gc/shared/{test_ptrQueueBufferAllocator.cpp => test_bufferNodeAllocator.cpp} (98%) diff --git a/src/hotspot/share/gc/g1/g1BarrierSet.hpp b/src/hotspot/share/gc/g1/g1BarrierSet.hpp index c925b01826b..f641fabf7c3 100644 --- a/src/hotspot/share/gc/g1/g1BarrierSet.hpp +++ b/src/hotspot/share/gc/g1/g1BarrierSet.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -29,6 +29,7 @@ #include "gc/g1/g1SATBMarkQueueSet.hpp" #include "gc/shared/cardTable.hpp" #include "gc/shared/cardTableBarrierSet.hpp" +#include "gc/shared/bufferNode.hpp" class G1CardTable; diff --git a/src/hotspot/share/gc/g1/g1CardTableEntryClosure.hpp b/src/hotspot/share/gc/g1/g1CardTableEntryClosure.hpp index 660ccbf1c0f..8fe0d7752eb 100644 --- a/src/hotspot/share/gc/g1/g1CardTableEntryClosure.hpp +++ b/src/hotspot/share/gc/g1/g1CardTableEntryClosure.hpp @@ -25,8 +25,8 @@ #ifndef SHARE_GC_G1_G1CARDTABLEENTRYCLOSURE_HPP #define SHARE_GC_G1_G1CARDTABLEENTRYCLOSURE_HPP +#include "gc/shared/bufferNode.hpp" #include "gc/shared/cardTable.hpp" -#include "gc/shared/ptrQueue.hpp" #include "memory/allocation.hpp" // A closure class for processing card table entries. Note that we don't diff --git a/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp b/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp index e34927c0b0a..93ff09134bf 100644 --- a/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp +++ b/src/hotspot/share/gc/g1/g1DirtyCardQueue.cpp @@ -34,6 +34,7 @@ #include "gc/g1/g1RemSet.hpp" #include "gc/g1/g1ThreadLocalData.hpp" #include "gc/g1/heapRegionRemSet.inline.hpp" +#include "gc/shared/bufferNode.hpp" #include "gc/shared/bufferNodeList.hpp" #include "gc/shared/suspendibleThreadSet.hpp" #include "memory/iterator.hpp" diff --git a/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp b/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp index 191fcf974f7..bf25e3828d1 100644 --- a/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp +++ b/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp @@ -28,6 +28,7 @@ #include "gc/g1/g1FreeIdSet.hpp" #include "gc/g1/g1CardTable.hpp" #include "gc/g1/g1ConcurrentRefineStats.hpp" +#include "gc/shared/bufferNode.hpp" #include "gc/shared/bufferNodeList.hpp" #include "gc/shared/ptrQueue.hpp" #include "memory/allocation.hpp" diff --git a/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.cpp b/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.cpp index 216024615e2..a264fb436c6 100644 --- a/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.cpp +++ b/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "gc/g1/g1RedirtyCardsQueue.hpp" +#include "gc/shared/bufferNode.hpp" #include "runtime/atomic.hpp" #include "utilities/debug.hpp" #include "utilities/macros.hpp" diff --git a/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.hpp b/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.hpp index b464d377298..f270e31f772 100644 --- a/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.hpp +++ b/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -25,6 +25,7 @@ #ifndef SHARE_GC_G1_G1REDIRTYCARDSQUEUE_HPP #define SHARE_GC_G1_G1REDIRTYCARDSQUEUE_HPP +#include "gc/shared/bufferNode.hpp" #include "gc/shared/bufferNodeList.hpp" #include "gc/shared/ptrQueue.hpp" #include "memory/padded.hpp" diff --git a/src/hotspot/share/gc/g1/g1RemSet.cpp b/src/hotspot/share/gc/g1/g1RemSet.cpp index 0bc34d1e558..2ff7e835d33 100644 --- a/src/hotspot/share/gc/g1/g1RemSet.cpp +++ b/src/hotspot/share/gc/g1/g1RemSet.cpp @@ -43,9 +43,9 @@ #include "gc/g1/heapRegion.inline.hpp" #include "gc/g1/heapRegionManager.inline.hpp" #include "gc/g1/heapRegionRemSet.inline.hpp" +#include "gc/shared/bufferNode.hpp" #include "gc/shared/bufferNodeList.hpp" #include "gc/shared/gcTraceTime.inline.hpp" -#include "gc/shared/ptrQueue.hpp" #include "jfr/jfrEvents.hpp" #include "memory/iterator.hpp" #include "memory/resourceArea.hpp" diff --git a/src/hotspot/share/gc/g1/g1SATBMarkQueueSet.hpp b/src/hotspot/share/gc/g1/g1SATBMarkQueueSet.hpp index 5533d6cdfed..4db9313805a 100644 --- a/src/hotspot/share/gc/g1/g1SATBMarkQueueSet.hpp +++ b/src/hotspot/share/gc/g1/g1SATBMarkQueueSet.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -25,6 +25,7 @@ #ifndef SHARE_GC_G1_G1SATBMARKQUEUESET_HPP #define SHARE_GC_G1_G1SATBMARKQUEUESET_HPP +#include "gc/shared/bufferNode.hpp" #include "gc/shared/satbMarkQueue.hpp" class Monitor; diff --git a/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp b/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp index 6e1d1cdd3be..d47f0e86c30 100644 --- a/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp +++ b/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp @@ -40,6 +40,7 @@ #include "gc/g1/g1YoungGCPostEvacuateTasks.hpp" #include "gc/g1/heapRegion.inline.hpp" #include "gc/g1/heapRegionRemSet.inline.hpp" +#include "gc/shared/bufferNode.hpp" #include "gc/shared/preservedMarks.inline.hpp" #include "jfr/jfrEvents.hpp" #include "oops/access.inline.hpp" diff --git a/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp b/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp index 79811b33a1d..b04c02a3fc9 100644 --- a/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp +++ b/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "gc/g1/heapRegionBounds.inline.hpp" #include "gc/g1/jvmFlagConstraintsG1.hpp" +#include "gc/shared/bufferNode.hpp" #include "gc/shared/ptrQueue.hpp" #include "runtime/globals_extension.hpp" #include "utilities/globalDefinitions.hpp" diff --git a/src/hotspot/share/gc/shared/bufferNode.cpp b/src/hotspot/share/gc/shared/bufferNode.cpp new file mode 100644 index 00000000000..9baa812c56e --- /dev/null +++ b/src/hotspot/share/gc/shared/bufferNode.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "gc/shared/bufferNode.hpp" +#include "utilities/debug.hpp" +#include "memory/allocation.inline.hpp" + +#include + +BufferNode::AllocatorConfig::AllocatorConfig(size_t size) + : _buffer_capacity(size) +{ + assert(size >= 1, "Invalid buffer capacity %zu", size); + assert(size <= max_size(), "Invalid buffer capacity %zu", size); +} + +void* BufferNode::AllocatorConfig::allocate() { + size_t byte_size = buffer_capacity() * sizeof(void*); + return NEW_C_HEAP_ARRAY(char, buffer_offset() + byte_size, mtGC); +} + +void BufferNode::AllocatorConfig::deallocate(void* node) { + assert(node != nullptr, "precondition"); + FREE_C_HEAP_ARRAY(char, node); +} + +BufferNode::Allocator::Allocator(const char* name, size_t buffer_capacity) : + _config(buffer_capacity), + _free_list(name, &_config) +{} + +size_t BufferNode::Allocator::free_count() const { + return _free_list.free_count(); +} + +BufferNode* BufferNode::Allocator::allocate() { + auto internal_capacity = static_cast(buffer_capacity()); + return ::new (_free_list.allocate()) BufferNode(internal_capacity); +} + +void BufferNode::Allocator::release(BufferNode* node) { + assert(node != nullptr, "precondition"); + assert(node->next() == nullptr, "precondition"); + assert(node->capacity() == buffer_capacity(), + "Wrong size %zu, expected %zu", node->capacity(), buffer_capacity()); + node->~BufferNode(); + _free_list.release(node); +} + diff --git a/src/hotspot/share/gc/shared/bufferNode.hpp b/src/hotspot/share/gc/shared/bufferNode.hpp new file mode 100644 index 00000000000..6f09dc0aa6e --- /dev/null +++ b/src/hotspot/share/gc/shared/bufferNode.hpp @@ -0,0 +1,139 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_GC_SHARED_BUFFERNODE_HPP +#define SHARE_GC_SHARED_BUFFERNODE_HPP + +#include "gc/shared/freeListAllocator.hpp" +#include "utilities/debug.hpp" +#include "utilities/globalDefinitions.hpp" +#include "utilities/lockFreeStack.hpp" +#include "utilities/macros.hpp" + +#include + +class BufferNode { + using InternalSizeType = LP64_ONLY(uint32_t) NOT_LP64(uint16_t); + static_assert(sizeof(InternalSizeType) <= sizeof(size_t), "assumption"); + + InternalSizeType _index; + InternalSizeType _capacity; + BufferNode* volatile _next; + void* _buffer[1]; // Pseudo flexible array member. + + BufferNode(InternalSizeType capacity) + : _index(capacity), _capacity(capacity), _next(nullptr) + {} + + ~BufferNode() = default; + + NONCOPYABLE(BufferNode); + + static size_t buffer_offset() { + return offset_of(BufferNode, _buffer); + } + +public: + static constexpr size_t max_size() { + return std::numeric_limits::max(); + } + + static BufferNode* volatile* next_ptr(BufferNode& bn) { return &bn._next; } + typedef LockFreeStack Stack; + + BufferNode* next() const { return _next; } + void set_next(BufferNode* n) { _next = n; } + size_t index() const { return _index; } + + void set_index(size_t i) { + assert(i <= capacity(), "precondition"); + _index = static_cast(i); + } + + size_t capacity() const { return _capacity; } + + bool is_empty() const { return index() == capacity(); } + size_t size() const { return capacity() - index(); } + + // Return the BufferNode containing the buffer, WITHOUT setting its index. + static BufferNode* make_node_from_buffer(void** buffer) { + char* base = reinterpret_cast(buffer) - buffer_offset(); + return reinterpret_cast(base); + } + + // Return the BufferNode containing the buffer, after setting its index. + static BufferNode* make_node_from_buffer(void** buffer, size_t index) { + BufferNode* node = make_node_from_buffer(buffer); + node->set_index(index); + return node; + } + + // Return the buffer for node. + static void** make_buffer_from_node(BufferNode *node) { + // &_buffer[0] might lead to index out of bounds warnings. + return reinterpret_cast( + reinterpret_cast(node) + buffer_offset()); + } + + class AllocatorConfig; + class Allocator; // Free-list based allocator. + class TestSupport; // Unit test support. +}; + +// We use BufferNode::AllocatorConfig to set the allocation options for the +// FreeListAllocator. +class BufferNode::AllocatorConfig : public FreeListConfig { + const size_t _buffer_capacity; + +public: + explicit AllocatorConfig(size_t size); + + ~AllocatorConfig() = default; + + void* allocate() override; + + void deallocate(void* node) override; + + size_t buffer_capacity() const { return _buffer_capacity; } +}; + +class BufferNode::Allocator { + friend class TestSupport; + + AllocatorConfig _config; + FreeListAllocator _free_list; + + NONCOPYABLE(Allocator); + +public: + Allocator(const char* name, size_t buffer_capacity); + ~Allocator() = default; + + size_t buffer_capacity() const { return _config.buffer_capacity(); } + size_t free_count() const; + BufferNode* allocate(); + void release(BufferNode* node); +}; + +#endif // SHARE_GC_SHARED_BUFFERNODE_HPP diff --git a/src/hotspot/share/gc/shared/ptrQueue.cpp b/src/hotspot/share/gc/shared/ptrQueue.cpp index 20cc1b944ea..9723db83912 100644 --- a/src/hotspot/share/gc/shared/ptrQueue.cpp +++ b/src/hotspot/share/gc/shared/ptrQueue.cpp @@ -23,10 +23,8 @@ */ #include "precompiled.hpp" +#include "gc/shared/bufferNode.hpp" #include "gc/shared/ptrQueue.hpp" -#include "memory/allocation.inline.hpp" - -#include PtrQueue::PtrQueue(PtrQueueSet* qset) : _index(0), @@ -45,46 +43,6 @@ size_t PtrQueue::current_capacity() const { } } -BufferNode::AllocatorConfig::AllocatorConfig(size_t size) - : _buffer_capacity(size) -{ - assert(size >= 1, "Invalid buffer capacity %zu", size); - assert(size <= max_size(), "Invalid buffer capacity %zu", size); -} - -void* BufferNode::AllocatorConfig::allocate() { - size_t byte_size = buffer_capacity() * sizeof(void*); - return NEW_C_HEAP_ARRAY(char, buffer_offset() + byte_size, mtGC); -} - -void BufferNode::AllocatorConfig::deallocate(void* node) { - assert(node != nullptr, "precondition"); - FREE_C_HEAP_ARRAY(char, node); -} - -BufferNode::Allocator::Allocator(const char* name, size_t buffer_capacity) : - _config(buffer_capacity), - _free_list(name, &_config) -{} - -size_t BufferNode::Allocator::free_count() const { - return _free_list.free_count(); -} - -BufferNode* BufferNode::Allocator::allocate() { - auto internal_capacity = static_cast(buffer_capacity()); - return ::new (_free_list.allocate()) BufferNode(internal_capacity); -} - -void BufferNode::Allocator::release(BufferNode* node) { - assert(node != nullptr, "precondition"); - assert(node->next() == nullptr, "precondition"); - assert(node->capacity() == buffer_capacity(), - "Wrong size %zu, expected %zu", node->capacity(), buffer_capacity()); - node->~BufferNode(); - _free_list.release(node); -} - PtrQueueSet::PtrQueueSet(BufferNode::Allocator* allocator) : _allocator(allocator) {} diff --git a/src/hotspot/share/gc/shared/ptrQueue.hpp b/src/hotspot/share/gc/shared/ptrQueue.hpp index 69a12c547f5..8aa5e16d40b 100644 --- a/src/hotspot/share/gc/shared/ptrQueue.hpp +++ b/src/hotspot/share/gc/shared/ptrQueue.hpp @@ -25,21 +25,17 @@ #ifndef SHARE_GC_SHARED_PTRQUEUE_HPP #define SHARE_GC_SHARED_PTRQUEUE_HPP -#include "gc/shared/freeListAllocator.hpp" -#include "memory/padded.hpp" +#include "gc/shared/bufferNode.hpp" #include "utilities/align.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" -#include "utilities/lockFreeStack.hpp" #include "utilities/sizes.hpp" -#include // There are various techniques that require threads to be able to log // addresses. For example, a generational write barrier might log // the addresses of modified old-generation objects. This type supports // this operation. -class BufferNode; class PtrQueueSet; class PtrQueue { friend class VMStructs; @@ -111,109 +107,6 @@ protected: static ByteSize byte_width_of_buf() { return in_ByteSize(_element_size); } }; -class BufferNode { - using InternalSizeType = LP64_ONLY(uint32_t) NOT_LP64(uint16_t); - static_assert(sizeof(InternalSizeType) <= sizeof(size_t), "assumption"); - - InternalSizeType _index; - InternalSizeType _capacity; - BufferNode* volatile _next; - void* _buffer[1]; // Pseudo flexible array member. - - BufferNode(InternalSizeType capacity) - : _index(capacity), _capacity(capacity), _next(nullptr) - {} - - ~BufferNode() = default; - - NONCOPYABLE(BufferNode); - - static size_t buffer_offset() { - return offset_of(BufferNode, _buffer); - } - -public: - static constexpr size_t max_size() { - return std::numeric_limits::max(); - } - - static BufferNode* volatile* next_ptr(BufferNode& bn) { return &bn._next; } - typedef LockFreeStack Stack; - - BufferNode* next() const { return _next; } - void set_next(BufferNode* n) { _next = n; } - size_t index() const { return _index; } - - void set_index(size_t i) { - assert(i <= capacity(), "precondition"); - _index = static_cast(i); - } - - size_t capacity() const { return _capacity; } - - bool is_empty() const { return index() == capacity(); } - size_t size() const { return capacity() - index(); } - - // Return the BufferNode containing the buffer, WITHOUT setting its index. - static BufferNode* make_node_from_buffer(void** buffer) { - char* base = reinterpret_cast(buffer) - buffer_offset(); - return reinterpret_cast(base); - } - - // Return the BufferNode containing the buffer, after setting its index. - static BufferNode* make_node_from_buffer(void** buffer, size_t index) { - BufferNode* node = make_node_from_buffer(buffer); - node->set_index(index); - return node; - } - - // Return the buffer for node. - static void** make_buffer_from_node(BufferNode *node) { - // &_buffer[0] might lead to index out of bounds warnings. - return reinterpret_cast( - reinterpret_cast(node) + buffer_offset()); - } - - class AllocatorConfig; - class Allocator; // Free-list based allocator. - class TestSupport; // Unit test support. -}; - -// We use BufferNode::AllocatorConfig to set the allocation options for the -// FreeListAllocator. -class BufferNode::AllocatorConfig : public FreeListConfig { - const size_t _buffer_capacity; - -public: - explicit AllocatorConfig(size_t size); - - ~AllocatorConfig() = default; - - void* allocate() override; - - void deallocate(void* node) override; - - size_t buffer_capacity() const { return _buffer_capacity; } -}; - -class BufferNode::Allocator { - friend class TestSupport; - - AllocatorConfig _config; - FreeListAllocator _free_list; - - NONCOPYABLE(Allocator); - -public: - Allocator(const char* name, size_t buffer_capacity); - ~Allocator() = default; - - size_t buffer_capacity() const { return _config.buffer_capacity(); } - size_t free_count() const; - BufferNode* allocate(); - void release(BufferNode* node); -}; - // A PtrQueueSet represents resources common to a set of pointer queues. // In particular, the individual queues allocate buffers from this shared // set, and return completed buffers to the set. diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp index 1d4dd7b9e3e..beb6ae492b8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp @@ -26,6 +26,7 @@ #define SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSET_HPP #include "gc/shared/barrierSet.hpp" +#include "gc/shared/bufferNode.hpp" #include "gc/shenandoah/shenandoahSATBMarkQueueSet.hpp" class ShenandoahHeap; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahSATBMarkQueueSet.hpp b/src/hotspot/share/gc/shenandoah/shenandoahSATBMarkQueueSet.hpp index 9e4984a325f..bda7e9b9545 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahSATBMarkQueueSet.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahSATBMarkQueueSet.hpp @@ -25,6 +25,7 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHSATBMARKQUEUESET_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHSATBMARKQUEUESET_HPP +#include "gc/shared/bufferNode.hpp" #include "gc/shared/satbMarkQueue.hpp" #include "gc/shenandoah/shenandoahHeap.hpp" #include "runtime/javaThread.hpp" diff --git a/test/hotspot/gtest/gc/shared/test_ptrQueueBufferAllocator.cpp b/test/hotspot/gtest/gc/shared/test_bufferNodeAllocator.cpp similarity index 98% rename from test/hotspot/gtest/gc/shared/test_ptrQueueBufferAllocator.cpp rename to test/hotspot/gtest/gc/shared/test_bufferNodeAllocator.cpp index dd4bf693e49..38e7b152024 100644 --- a/test/hotspot/gtest/gc/shared/test_ptrQueueBufferAllocator.cpp +++ b/test/hotspot/gtest/gc/shared/test_bufferNodeAllocator.cpp @@ -23,7 +23,7 @@ */ #include "precompiled.hpp" -#include "gc/shared/ptrQueue.hpp" +#include "gc/shared/bufferNode.hpp" #include "memory/allocation.hpp" #include "runtime/atomic.hpp" #include "runtime/interfaceSupport.inline.hpp" @@ -51,7 +51,7 @@ typedef BufferNode::TestSupport::AllocatorThread AllocatorThread; typedef BufferNode::TestSupport::ProcessorThread ProcessorThread; // Some basic testing of BufferNode::Allocator. -TEST_VM(PtrQueueBufferAllocatorTest, test) { +TEST_VM(BufferNodeAllocatorTest, test) { const size_t buffer_capacity = 256; BufferNode::Allocator allocator("Test Buffer Allocator", buffer_capacity); ASSERT_EQ(buffer_capacity, allocator.buffer_capacity()); @@ -233,7 +233,7 @@ static void run_test(BufferNode::Allocator* allocator, CompletedList* cbl) { tty->print_cr("allocator free count: " SIZE_FORMAT, allocator->free_count()); } -TEST_VM(PtrQueueBufferAllocatorTest, stress_free_list_allocator) { +TEST_VM(BufferNodeAllocatorTest, stress_free_list_allocator) { const size_t buffer_capacity = 1024; BufferNode::Allocator allocator("Test Allocator", buffer_capacity); CompletedList completed;