8202863: Rename OopStorage inner collection classes

Rename BlockArray, BlockList, BlockEntry

Reviewed-by: coleenp
This commit is contained in:
Kim Barrett 2018-05-22 03:46:52 -04:00
parent e30f2aee4f
commit 66b0c9fe9c
5 changed files with 136 additions and 136 deletions

View file

@ -45,24 +45,24 @@
#include "utilities/ostream.hpp"
#include "utilities/spinYield.hpp"
OopStorage::BlockEntry::BlockEntry() : _prev(NULL), _next(NULL) {}
OopStorage::AllocateEntry::AllocateEntry() : _prev(NULL), _next(NULL) {}
OopStorage::BlockEntry::~BlockEntry() {
OopStorage::AllocateEntry::~AllocateEntry() {
assert(_prev == NULL, "deleting attached block");
assert(_next == NULL, "deleting attached block");
}
OopStorage::BlockList::BlockList(const BlockEntry& (*get_entry)(const Block& block)) :
OopStorage::AllocateList::AllocateList(const AllocateEntry& (*get_entry)(const Block& block)) :
_head(NULL), _tail(NULL), _get_entry(get_entry)
{}
OopStorage::BlockList::~BlockList() {
OopStorage::AllocateList::~AllocateList() {
// ~OopStorage() empties its lists before destroying them.
assert(_head == NULL, "deleting non-empty block list");
assert(_tail == NULL, "deleting non-empty block list");
}
void OopStorage::BlockList::push_front(const Block& block) {
void OopStorage::AllocateList::push_front(const Block& block) {
const Block* old = _head;
if (old == NULL) {
assert(_tail == NULL, "invariant");
@ -74,7 +74,7 @@ void OopStorage::BlockList::push_front(const Block& block) {
}
}
void OopStorage::BlockList::push_back(const Block& block) {
void OopStorage::AllocateList::push_back(const Block& block) {
const Block* old = _tail;
if (old == NULL) {
assert(_head == NULL, "invariant");
@ -86,8 +86,8 @@ void OopStorage::BlockList::push_back(const Block& block) {
}
}
void OopStorage::BlockList::unlink(const Block& block) {
const BlockEntry& block_entry = _get_entry(block);
void OopStorage::AllocateList::unlink(const Block& block) {
const AllocateEntry& block_entry = _get_entry(block);
const Block* prev_blk = block_entry._prev;
const Block* next_blk = block_entry._next;
block_entry._prev = NULL;
@ -110,52 +110,52 @@ void OopStorage::BlockList::unlink(const Block& block) {
}
}
OopStorage::BlockArray::BlockArray(size_t size) :
OopStorage::ActiveArray::ActiveArray(size_t size) :
_size(size),
_block_count(0),
_refcount(0)
{}
OopStorage::BlockArray::~BlockArray() {
OopStorage::ActiveArray::~ActiveArray() {
assert(_refcount == 0, "precondition");
}
OopStorage::BlockArray* OopStorage::BlockArray::create(size_t size, AllocFailType alloc_fail) {
OopStorage::ActiveArray* OopStorage::ActiveArray::create(size_t size, AllocFailType alloc_fail) {
size_t size_in_bytes = blocks_offset() + sizeof(Block*) * size;
void* mem = NEW_C_HEAP_ARRAY3(char, size_in_bytes, mtGC, CURRENT_PC, alloc_fail);
if (mem == NULL) return NULL;
return new (mem) BlockArray(size);
return new (mem) ActiveArray(size);
}
void OopStorage::BlockArray::destroy(BlockArray* ba) {
ba->~BlockArray();
void OopStorage::ActiveArray::destroy(ActiveArray* ba) {
ba->~ActiveArray();
FREE_C_HEAP_ARRAY(char, ba);
}
size_t OopStorage::BlockArray::size() const {
size_t OopStorage::ActiveArray::size() const {
return _size;
}
size_t OopStorage::BlockArray::block_count() const {
size_t OopStorage::ActiveArray::block_count() const {
return _block_count;
}
size_t OopStorage::BlockArray::block_count_acquire() const {
size_t OopStorage::ActiveArray::block_count_acquire() const {
return OrderAccess::load_acquire(&_block_count);
}
void OopStorage::BlockArray::increment_refcount() const {
void OopStorage::ActiveArray::increment_refcount() const {
int new_value = Atomic::add(1, &_refcount);
assert(new_value >= 1, "negative refcount %d", new_value - 1);
}
bool OopStorage::BlockArray::decrement_refcount() const {
bool OopStorage::ActiveArray::decrement_refcount() const {
int new_value = Atomic::sub(1, &_refcount);
assert(new_value >= 0, "negative refcount %d", new_value);
return new_value == 0;
}
bool OopStorage::BlockArray::push(Block* block) {
bool OopStorage::ActiveArray::push(Block* block) {
size_t index = _block_count;
if (index < _size) {
block->set_active_index(index);
@ -169,7 +169,7 @@ bool OopStorage::BlockArray::push(Block* block) {
}
}
void OopStorage::BlockArray::remove(Block* block) {
void OopStorage::ActiveArray::remove(Block* block) {
assert(_block_count > 0, "array is empty");
size_t index = block->active_index();
assert(*block_ptr(index) == block, "block not present");
@ -180,7 +180,7 @@ void OopStorage::BlockArray::remove(Block* block) {
_block_count = last_index;
}
void OopStorage::BlockArray::copy_from(const BlockArray* from) {
void OopStorage::ActiveArray::copy_from(const ActiveArray* from) {
assert(_block_count == 0, "array must be empty");
size_t count = from->_block_count;
assert(count <= _size, "precondition");
@ -232,7 +232,7 @@ OopStorage::Block::~Block() {
const_cast<OopStorage* volatile&>(_owner) = NULL;
}
const OopStorage::BlockEntry& OopStorage::Block::get_allocate_entry(const Block& block) {
const OopStorage::AllocateEntry& OopStorage::Block::get_allocate_entry(const Block& block) {
return block._allocate_entry;
}
@ -489,11 +489,11 @@ oop* OopStorage::allocate() {
// indicate allocation failure.
bool OopStorage::expand_active_array() {
assert_lock_strong(_allocate_mutex);
BlockArray* old_array = _active_array;
ActiveArray* old_array = _active_array;
size_t new_size = 2 * old_array->size();
log_info(oopstorage, blocks)("%s: expand active array " SIZE_FORMAT,
name(), new_size);
BlockArray* new_array = BlockArray::create(new_size, AllocFailStrategy::RETURN_NULL);
ActiveArray* new_array = ActiveArray::create(new_size, AllocFailStrategy::RETURN_NULL);
if (new_array == NULL) return false;
new_array->copy_from(old_array);
replace_active_array(new_array);
@ -547,7 +547,7 @@ void OopStorage::ProtectActive::write_synchronize() {
// to account for the new reference. The assignment is atomic wrto
// obtain_active_array; once this function returns, it is safe for the
// caller to relinquish the old array.
void OopStorage::replace_active_array(BlockArray* new_array) {
void OopStorage::replace_active_array(ActiveArray* new_array) {
// Caller has the old array that is the current value of _active_array.
// Update new_array refcount to account for the new reference.
new_array->increment_refcount();
@ -565,25 +565,25 @@ void OopStorage::replace_active_array(BlockArray* new_array) {
// even if an allocate operation expands and replaces the value of
// _active_array. The caller must relinquish the array when done
// using it.
OopStorage::BlockArray* OopStorage::obtain_active_array() const {
OopStorage::ActiveArray* OopStorage::obtain_active_array() const {
uint enter_value = _protect_active.read_enter();
BlockArray* result = OrderAccess::load_acquire(&_active_array);
ActiveArray* result = OrderAccess::load_acquire(&_active_array);
result->increment_refcount();
_protect_active.read_exit(enter_value);
return result;
}
// Decrement refcount of array and destroy if refcount is zero.
void OopStorage::relinquish_block_array(BlockArray* array) const {
void OopStorage::relinquish_block_array(ActiveArray* array) const {
if (array->decrement_refcount()) {
assert(array != _active_array, "invariant");
BlockArray::destroy(array);
ActiveArray::destroy(array);
}
}
class OopStorage::WithActiveArray : public StackObj {
const OopStorage* _storage;
BlockArray* _active_array;
ActiveArray* _active_array;
public:
WithActiveArray(const OopStorage* storage) :
@ -595,7 +595,7 @@ public:
_storage->relinquish_block_array(_active_array);
}
BlockArray& active_array() const {
ActiveArray& active_array() const {
return *_active_array;
}
};
@ -768,7 +768,7 @@ OopStorage::OopStorage(const char* name,
Mutex* allocate_mutex,
Mutex* active_mutex) :
_name(dup_name(name)),
_active_array(BlockArray::create(initial_active_array_size)),
_active_array(ActiveArray::create(initial_active_array_size)),
_allocate_list(&Block::get_allocate_entry),
_deferred_updates(NULL),
_allocate_mutex(allocate_mutex),
@ -806,7 +806,7 @@ OopStorage::~OopStorage() {
block = _active_array->at(--i);
Block::delete_block(*block);
}
BlockArray::destroy(_active_array);
ActiveArray::destroy(_active_array);
FREE_C_HEAP_ARRAY(char, _name);
}
@ -895,9 +895,9 @@ size_t OopStorage::block_count() const {
size_t OopStorage::total_memory_usage() const {
size_t total_size = sizeof(OopStorage);
total_size += strlen(name()) + 1;
total_size += sizeof(BlockArray);
total_size += sizeof(ActiveArray);
WithActiveArray wab(this);
const BlockArray& blocks = wab.active_array();
const ActiveArray& blocks = wab.active_array();
// Count access is racy, but don't care.
total_size += blocks.block_count() * Block::allocation_size();
total_size += blocks.size() * sizeof(Block*);
@ -925,7 +925,7 @@ OopStorage::BasicParState::BasicParState(const OopStorage* storage,
// Get the block count *after* iteration state updated, so concurrent
// empty block deletion is suppressed and can't reduce the count. But
// ensure the count we use was written after the block with that count
// was fully initialized; see BlockArray::push.
// was fully initialized; see ActiveArray::push.
_block_count = _active_array->block_count_acquire();
}

View file

@ -171,22 +171,22 @@ public:
// version 12 rejects it.
NOT_AIX( private: )
class Block; // Fixed-size array of oops, plus bookkeeping.
class BlockArray; // Array of Blocks, plus bookkeeping.
class BlockEntry; // Provides BlockList links in a Block.
class ActiveArray; // Array of Blocks, plus bookkeeping.
class AllocateEntry; // Provides AllocateList links in a Block.
// Doubly-linked list of Blocks.
class BlockList {
class AllocateList {
const Block* _head;
const Block* _tail;
const BlockEntry& (*_get_entry)(const Block& block);
const AllocateEntry& (*_get_entry)(const Block& block);
// Noncopyable.
BlockList(const BlockList&);
BlockList& operator=(const BlockList&);
AllocateList(const AllocateList&);
AllocateList& operator=(const AllocateList&);
public:
BlockList(const BlockEntry& (*get_entry)(const Block& block));
~BlockList();
AllocateList(const AllocateEntry& (*get_entry)(const Block& block));
~AllocateList();
Block* head();
Block* tail();
@ -219,8 +219,8 @@ NOT_AIX( private: )
private:
const char* _name;
BlockArray* _active_array;
BlockList _allocate_list;
ActiveArray* _active_array;
AllocateList _allocate_list;
Block* volatile _deferred_updates;
Mutex* _allocate_mutex;
@ -241,9 +241,9 @@ private:
// Managing _active_array.
bool expand_active_array();
void replace_active_array(BlockArray* new_array);
BlockArray* obtain_active_array() const;
void relinquish_block_array(BlockArray* array) const;
void replace_active_array(ActiveArray* new_array);
ActiveArray* obtain_active_array() const;
void relinquish_block_array(ActiveArray* array) const;
class WithActiveArray; // RAII helper for active array access.
template<typename F, typename Storage>

View file

@ -37,7 +37,7 @@
// Array of all active blocks. Refcounted for lock-free reclaim of
// old array when a new array is allocated for expansion.
class OopStorage::BlockArray {
class OopStorage::ActiveArray {
friend class OopStorage::TestAccess;
size_t _size;
@ -45,12 +45,12 @@ class OopStorage::BlockArray {
mutable volatile int _refcount;
// Block* _blocks[1]; // Pseudo flexible array member.
BlockArray(size_t size);
~BlockArray();
ActiveArray(size_t size);
~ActiveArray();
// Noncopyable
BlockArray(const BlockArray&);
BlockArray& operator=(const BlockArray&);
ActiveArray(const ActiveArray&);
ActiveArray& operator=(const ActiveArray&);
static size_t blocks_offset();
Block* const* base_ptr() const;
@ -59,8 +59,8 @@ class OopStorage::BlockArray {
Block** block_ptr(size_t index);
public:
static BlockArray* create(size_t size, AllocFailType alloc_fail = AllocFailStrategy::EXIT_OOM);
static void destroy(BlockArray* ba);
static ActiveArray* create(size_t size, AllocFailType alloc_fail = AllocFailStrategy::EXIT_OOM);
static void destroy(ActiveArray* ba);
inline Block* at(size_t i) const;
@ -82,35 +82,35 @@ public:
// precondition: block must be present at its active_index element.
void remove(Block* block);
void copy_from(const BlockArray* from);
void copy_from(const ActiveArray* from);
};
inline size_t OopStorage::BlockArray::blocks_offset() {
return align_up(sizeof(BlockArray), sizeof(Block*));
inline size_t OopStorage::ActiveArray::blocks_offset() {
return align_up(sizeof(ActiveArray), sizeof(Block*));
}
inline OopStorage::Block* const* OopStorage::BlockArray::base_ptr() const {
inline OopStorage::Block* const* OopStorage::ActiveArray::base_ptr() const {
const void* ptr = reinterpret_cast<const char*>(this) + blocks_offset();
return reinterpret_cast<Block* const*>(ptr);
}
inline OopStorage::Block* const* OopStorage::BlockArray::block_ptr(size_t index) const {
inline OopStorage::Block* const* OopStorage::ActiveArray::block_ptr(size_t index) const {
return base_ptr() + index;
}
inline OopStorage::Block** OopStorage::BlockArray::block_ptr(size_t index) {
inline OopStorage::Block** OopStorage::ActiveArray::block_ptr(size_t index) {
return const_cast<Block**>(base_ptr() + index);
}
inline OopStorage::Block* OopStorage::BlockArray::at(size_t index) const {
inline OopStorage::Block* OopStorage::ActiveArray::at(size_t index) const {
assert(index < _block_count, "precondition");
return *block_ptr(index);
}
// A Block has an embedded BlockEntry to provide the links between
// Blocks in a BlockList.
class OopStorage::BlockEntry {
friend class OopStorage::BlockList;
// A Block has an embedded AllocateEntry to provide the links between
// Blocks in a AllocateList.
class OopStorage::AllocateEntry {
friend class OopStorage::AllocateList;
// Members are mutable, and we deal exclusively with pointers to
// const, to make const blocks easier to use; a block being const
@ -119,12 +119,12 @@ class OopStorage::BlockEntry {
mutable const Block* _next;
// Noncopyable.
BlockEntry(const BlockEntry&);
BlockEntry& operator=(const BlockEntry&);
AllocateEntry(const AllocateEntry&);
AllocateEntry& operator=(const AllocateEntry&);
public:
BlockEntry();
~BlockEntry();
AllocateEntry();
~AllocateEntry();
};
// Fixed-sized array of oops, plus bookkeeping data.
@ -140,7 +140,7 @@ class OopStorage::Block /* No base class, to avoid messing up alignment. */ {
const OopStorage* _owner;
void* _memory; // Unaligned storage containing block.
size_t _active_index;
BlockEntry _allocate_entry;
AllocateEntry _allocate_entry;
Block* volatile _deferred_updates_next;
volatile uintx _release_refcount;
@ -158,7 +158,7 @@ class OopStorage::Block /* No base class, to avoid messing up alignment. */ {
Block& operator=(const Block&);
public:
static const BlockEntry& get_allocate_entry(const Block& block);
static const AllocateEntry& get_allocate_entry(const Block& block);
static size_t allocation_size();
static size_t allocation_alignment_shift();
@ -197,35 +197,35 @@ public:
template<typename F> bool iterate(F f) const;
}; // class Block
inline OopStorage::Block* OopStorage::BlockList::head() {
inline OopStorage::Block* OopStorage::AllocateList::head() {
return const_cast<Block*>(_head);
}
inline OopStorage::Block* OopStorage::BlockList::tail() {
inline OopStorage::Block* OopStorage::AllocateList::tail() {
return const_cast<Block*>(_tail);
}
inline const OopStorage::Block* OopStorage::BlockList::chead() const {
inline const OopStorage::Block* OopStorage::AllocateList::chead() const {
return _head;
}
inline const OopStorage::Block* OopStorage::BlockList::ctail() const {
inline const OopStorage::Block* OopStorage::AllocateList::ctail() const {
return _tail;
}
inline OopStorage::Block* OopStorage::BlockList::prev(Block& block) {
inline OopStorage::Block* OopStorage::AllocateList::prev(Block& block) {
return const_cast<Block*>(_get_entry(block)._prev);
}
inline OopStorage::Block* OopStorage::BlockList::next(Block& block) {
inline OopStorage::Block* OopStorage::AllocateList::next(Block& block) {
return const_cast<Block*>(_get_entry(block)._next);
}
inline const OopStorage::Block* OopStorage::BlockList::prev(const Block& block) const {
inline const OopStorage::Block* OopStorage::AllocateList::prev(const Block& block) const {
return _get_entry(block)._prev;
}
inline const OopStorage::Block* OopStorage::BlockList::next(const Block& block) const {
inline const OopStorage::Block* OopStorage::AllocateList::next(const Block& block) const {
return _get_entry(block)._next;
}
@ -357,7 +357,7 @@ inline bool OopStorage::iterate_impl(F f, Storage* storage) {
// Propagate const/non-const iteration to the block layer, by using
// const or non-const blocks as corresponding to Storage.
typedef typename Conditional<IsConst<Storage>::value, const Block*, Block*>::type BlockPtr;
BlockArray* blocks = storage->_active_array;
ActiveArray* blocks = storage->_active_array;
size_t limit = blocks->block_count();
for (size_t i = 0; i < limit; ++i) {
BlockPtr block = blocks->at(i);

View file

@ -36,8 +36,8 @@
//
// Concurrent Iteration
//
// Iteration involves the _active_array (a BlockArray), which contains all of
// the blocks owned by a storage object.
// Iteration involves the _active_array (an ActiveArray), which contains all
// of the blocks owned by a storage object.
//
// At most one concurrent ParState can exist at a time for a given storage
// object.
@ -140,7 +140,7 @@
class OopStorage::BasicParState {
const OopStorage* _storage;
BlockArray* _active_array;
ActiveArray* _active_array;
size_t _block_count;
volatile size_t _next_block;
uint _estimated_thread_count;

View file

@ -52,18 +52,18 @@
class OopStorage::TestAccess : public AllStatic {
public:
typedef OopStorage::Block Block;
typedef OopStorage::BlockList BlockList;
typedef OopStorage::BlockArray BlockArray;
typedef OopStorage::AllocateList AllocateList;
typedef OopStorage::ActiveArray ActiveArray;
static BlockArray& active_array(const OopStorage& storage) {
static ActiveArray& active_array(const OopStorage& storage) {
return *storage._active_array;
}
static BlockList& allocate_list(OopStorage& storage) {
static AllocateList& allocate_list(OopStorage& storage) {
return storage._allocate_list;
}
static const BlockList& allocate_list(const OopStorage& storage) {
static const AllocateList& allocate_list(const OopStorage& storage) {
return storage._allocate_list;
}
@ -98,7 +98,7 @@ public:
return Block::allocation_size();
}
static void block_array_set_block_count(BlockArray* blocks, size_t count) {
static void block_array_set_block_count(ActiveArray* blocks, size_t count) {
blocks->_block_count = count;
}
};
@ -109,13 +109,13 @@ typedef OopStorage::TestAccess TestAccess;
// building with precompiled headers, or for consistency with that
// workaround. There really should be an opto namespace.
typedef TestAccess::Block OopBlock;
typedef TestAccess::BlockList OopBlockList;
typedef TestAccess::BlockArray OopBlockArray;
typedef TestAccess::AllocateList AllocateList;
typedef TestAccess::ActiveArray ActiveArray;
// Using EXPECT_EQ can't use NULL directly. Otherwise AIX build breaks.
const OopBlock* const NULL_BLOCK = NULL;
static size_t list_length(const OopBlockList& list) {
static size_t list_length(const AllocateList& list) {
size_t result = 0;
for (const OopBlock* block = list.chead();
block != NULL;
@ -125,7 +125,7 @@ static size_t list_length(const OopBlockList& list) {
return result;
}
static void clear_list(OopBlockList& list) {
static void clear_list(AllocateList& list) {
OopBlock* next;
for (OopBlock* block = list.head(); block != NULL; block = next) {
next = list.next(*block);
@ -133,7 +133,7 @@ static void clear_list(OopBlockList& list) {
}
}
static bool is_list_empty(const OopBlockList& list) {
static bool is_list_empty(const AllocateList& list) {
return list.chead() == NULL;
}
@ -155,7 +155,7 @@ static void release_entry(OopStorage& storage, oop* entry, bool process_deferred
}
static size_t empty_block_count(const OopStorage& storage) {
const OopBlockList& list = TestAccess::allocate_list(storage);
const AllocateList& list = TestAccess::allocate_list(storage);
size_t count = 0;
for (const OopBlock* block = list.ctail();
(block != NULL) && block->is_empty();
@ -169,7 +169,7 @@ static size_t active_count(const OopStorage& storage) {
}
static OopBlock* active_head(const OopStorage& storage) {
OopBlockArray& ba = TestAccess::active_array(storage);
ActiveArray& ba = TestAccess::active_array(storage);
size_t count = ba.block_count();
if (count == 0) {
return NULL;
@ -246,7 +246,7 @@ private:
static bool is_allocate_list_sorted(const OopStorage& storage) {
// The allocate_list isn't strictly sorted. Rather, all empty
// blocks are segregated to the end of the list.
const OopBlockList& list = TestAccess::allocate_list(storage);
const AllocateList& list = TestAccess::allocate_list(storage);
const OopBlock* block = list.ctail();
for ( ; (block != NULL) && block->is_empty(); block = list.prev(*block)) {}
for ( ; block != NULL; block = list.prev(*block)) {
@ -259,7 +259,7 @@ static bool is_allocate_list_sorted(const OopStorage& storage) {
static size_t total_allocation_count(const OopStorage& storage) {
size_t total_count = 0;
const OopBlockArray& ba = TestAccess::active_array(storage);
const ActiveArray& ba = TestAccess::active_array(storage);
size_t limit = active_count(storage);
for (size_t i = 0; i < limit; ++i) {
total_count += TestAccess::block_allocation_count(*ba.at(i));
@ -309,7 +309,7 @@ TEST_VM_F(OopStorageTest, allocation_count) {
static const size_t max_entries = 1000;
oop* entries[max_entries];
OopBlockList& allocate_list = TestAccess::allocate_list(_storage);
AllocateList& allocate_list = TestAccess::allocate_list(_storage);
EXPECT_EQ(0u, active_count(_storage));
EXPECT_EQ(0u, _storage.block_count());
@ -354,7 +354,7 @@ TEST_VM_F(OopStorageTest, allocate_many) {
static const size_t max_entries = 1000;
oop* entries[max_entries];
OopBlockList& allocate_list = TestAccess::allocate_list(_storage);
AllocateList& allocate_list = TestAccess::allocate_list(_storage);
EXPECT_EQ(0u, empty_block_count(_storage));
@ -420,7 +420,7 @@ TEST_VM_F(OopStorageTestWithAllocation, random_release) {
EXPECT_EQ(0u, empty_block_count(_storage));
OopBlockList& allocate_list = TestAccess::allocate_list(_storage);
AllocateList& allocate_list = TestAccess::allocate_list(_storage);
EXPECT_EQ(_max_entries, total_allocation_count(_storage));
EXPECT_GE(1u, list_length(allocate_list));
@ -450,7 +450,7 @@ TEST_VM_F(OopStorageTestWithAllocation, random_allocate_release) {
EXPECT_EQ(0u, empty_block_count(_storage));
OopBlockList& allocate_list = TestAccess::allocate_list(_storage);
AllocateList& allocate_list = TestAccess::allocate_list(_storage);
EXPECT_EQ(_max_entries, total_allocation_count(_storage));
EXPECT_GE(1u, list_length(allocate_list));
@ -1200,10 +1200,10 @@ private:
const size_t OopStorageBlockCollectionTest::nvalues;
const void* const OopStorageBlockCollectionTest::_pseudo_owner[] = {};
class OopStorageBlockListTest : public OopStorageBlockCollectionTest {};
class OopStorageAllocateListTest : public OopStorageBlockCollectionTest {};
TEST_F(OopStorageBlockListTest, empty_list) {
OopBlockList list(&OopBlock::get_allocate_entry);
TEST_F(OopStorageAllocateListTest, empty_list) {
AllocateList list(&OopBlock::get_allocate_entry);
EXPECT_TRUE(is_list_empty(list));
EXPECT_EQ(NULL_BLOCK, list.head());
@ -1211,8 +1211,8 @@ TEST_F(OopStorageBlockListTest, empty_list) {
EXPECT_EQ(NULL_BLOCK, list.ctail());
}
TEST_F(OopStorageBlockListTest, push_back) {
OopBlockList list(&OopBlock::get_allocate_entry);
TEST_F(OopStorageAllocateListTest, push_back) {
AllocateList list(&OopBlock::get_allocate_entry);
for (size_t i = 0; i < nvalues; ++i) {
list.push_back(*values[i]);
@ -1241,8 +1241,8 @@ TEST_F(OopStorageBlockListTest, push_back) {
clear_list(list);
}
TEST_F(OopStorageBlockListTest, push_front) {
OopBlockList list(&OopBlock::get_allocate_entry);
TEST_F(OopStorageAllocateListTest, push_front) {
AllocateList list(&OopBlock::get_allocate_entry);
for (size_t i = 0; i < nvalues; ++i) {
list.push_front(*values[i]);
@ -1271,22 +1271,22 @@ TEST_F(OopStorageBlockListTest, push_front) {
clear_list(list);
}
class OopStorageBlockListTestWithList : public OopStorageBlockListTest {
class OopStorageAllocateListTestWithList : public OopStorageAllocateListTest {
public:
OopStorageBlockListTestWithList() : list(&OopBlock::get_allocate_entry) {
OopStorageAllocateListTestWithList() : list(&OopBlock::get_allocate_entry) {
for (size_t i = 0; i < nvalues; ++i) {
list.push_back(*values[i]);
}
}
~OopStorageBlockListTestWithList() {
~OopStorageAllocateListTestWithList() {
clear_list(list);
}
OopBlockList list;
AllocateList list;
};
TEST_F(OopStorageBlockListTestWithList, unlink_front) {
TEST_F(OopStorageAllocateListTestWithList, unlink_front) {
EXPECT_EQ(list.chead(), values[0]);
EXPECT_EQ(list.ctail(), values[nvalues - 1]);
@ -1304,7 +1304,7 @@ TEST_F(OopStorageBlockListTestWithList, unlink_front) {
EXPECT_EQ(NULL_BLOCK, block);
}
TEST_F(OopStorageBlockListTestWithList, unlink_back) {
TEST_F(OopStorageAllocateListTestWithList, unlink_back) {
EXPECT_EQ(list.chead(), values[0]);
list.unlink(*values[nvalues - 1]);
@ -1321,7 +1321,7 @@ TEST_F(OopStorageBlockListTestWithList, unlink_back) {
EXPECT_EQ(NULL_BLOCK, block);
}
TEST_F(OopStorageBlockListTestWithList, unlink_middle) {
TEST_F(OopStorageAllocateListTestWithList, unlink_middle) {
EXPECT_EQ(list.chead(), values[0]);
size_t index = nvalues / 2;
@ -1344,8 +1344,8 @@ TEST_F(OopStorageBlockListTestWithList, unlink_middle) {
EXPECT_EQ(NULL_BLOCK, block);
}
TEST_F(OopStorageBlockListTest, single) {
OopBlockList list(&OopBlock::get_allocate_entry);
TEST_F(OopStorageAllocateListTest, single) {
AllocateList list(&OopBlock::get_allocate_entry);
list.push_back(*values[0]);
EXPECT_EQ(NULL_BLOCK, list.next(*values[0]));
@ -1360,10 +1360,10 @@ TEST_F(OopStorageBlockListTest, single) {
EXPECT_EQ(NULL_BLOCK, list.ctail());
}
class OopStorageBlockArrayTest : public OopStorageBlockCollectionTest {};
class OopStorageActiveArrayTest : public OopStorageBlockCollectionTest {};
TEST_F(OopStorageBlockArrayTest, empty_array) {
OopBlockArray* a = OopBlockArray::create(nvalues);
TEST_F(OopStorageActiveArrayTest, empty_array) {
ActiveArray* a = ActiveArray::create(nvalues);
EXPECT_EQ(nvalues, a->size());
EXPECT_EQ(0u, a->block_count_acquire());
@ -1375,11 +1375,11 @@ TEST_F(OopStorageBlockArrayTest, empty_array) {
EXPECT_FALSE(a->decrement_refcount());
EXPECT_TRUE(a->decrement_refcount());
OopBlockArray::destroy(a);
ActiveArray::destroy(a);
}
TEST_F(OopStorageBlockArrayTest, push) {
OopBlockArray* a = OopBlockArray::create(nvalues - 1);
TEST_F(OopStorageActiveArrayTest, push) {
ActiveArray* a = ActiveArray::create(nvalues - 1);
for (size_t i = 0; i < nvalues - 1; ++i) {
EXPECT_TRUE(a->push(values[i]));
@ -1389,26 +1389,26 @@ TEST_F(OopStorageBlockArrayTest, push) {
EXPECT_FALSE(a->push(values[nvalues - 1]));
TestAccess::block_array_set_block_count(a, 0);
OopBlockArray::destroy(a);
ActiveArray::destroy(a);
}
class OopStorageBlockArrayTestWithArray : public OopStorageBlockArrayTest {
class OopStorageActiveArrayTestWithArray : public OopStorageActiveArrayTest {
public:
OopStorageBlockArrayTestWithArray() : a(OopBlockArray::create(nvalues)) {
OopStorageActiveArrayTestWithArray() : a(ActiveArray::create(nvalues)) {
for (size_t i = 0; i < nvalues; ++i) {
a->push(values[i]);
}
}
~OopStorageBlockArrayTestWithArray() {
~OopStorageActiveArrayTestWithArray() {
TestAccess::block_array_set_block_count(a, 0);
OopBlockArray::destroy(a);
ActiveArray::destroy(a);
}
OopBlockArray* a;
ActiveArray* a;
};
TEST_F(OopStorageBlockArrayTestWithArray, remove0) {
TEST_F(OopStorageActiveArrayTestWithArray, remove0) {
a->remove(values[0]);
EXPECT_EQ(nvalues - 1, a->block_count_acquire());
EXPECT_EQ(values[nvalues - 1], a->at(0));
@ -1417,7 +1417,7 @@ TEST_F(OopStorageBlockArrayTestWithArray, remove0) {
}
}
TEST_F(OopStorageBlockArrayTestWithArray, remove3) {
TEST_F(OopStorageActiveArrayTestWithArray, remove3) {
a->remove(values[3]);
EXPECT_EQ(nvalues - 1, a->block_count_acquire());
for (size_t i = 0; i < 3; ++i) {
@ -1429,7 +1429,7 @@ TEST_F(OopStorageBlockArrayTestWithArray, remove3) {
}
}
TEST_F(OopStorageBlockArrayTestWithArray, remove_last) {
TEST_F(OopStorageActiveArrayTestWithArray, remove_last) {
a->remove(values[nvalues - 1]);
EXPECT_EQ(nvalues - 1, a->block_count_acquire());
for (size_t i = 0; i < nvalues - 1; ++i) {