8204097: Simplify OopStorage::AllocateList block entry access

Removed obsolete support for blocks being in multiple lists.

Reviewed-by: coleenp, tschatzl
This commit is contained in:
Kim Barrett 2018-06-11 22:35:07 -04:00
parent d51c1b87d2
commit d3e96fdd91
4 changed files with 27 additions and 30 deletions

View file

@ -52,9 +52,7 @@ OopStorage::AllocateEntry::~AllocateEntry() {
assert(_next == NULL, "deleting attached block"); assert(_next == NULL, "deleting attached block");
} }
OopStorage::AllocateList::AllocateList(const AllocateEntry& (*get_entry)(const Block& block)) : OopStorage::AllocateList::AllocateList() : _head(NULL), _tail(NULL) {}
_head(NULL), _tail(NULL), _get_entry(get_entry)
{}
OopStorage::AllocateList::~AllocateList() { OopStorage::AllocateList::~AllocateList() {
// ~OopStorage() empties its lists before destroying them. // ~OopStorage() empties its lists before destroying them.
@ -68,8 +66,8 @@ void OopStorage::AllocateList::push_front(const Block& block) {
assert(_tail == NULL, "invariant"); assert(_tail == NULL, "invariant");
_head = _tail = █ _head = _tail = █
} else { } else {
_get_entry(block)._next = old; block.allocate_entry()._next = old;
_get_entry(*old)._prev = █ old->allocate_entry()._prev = █
_head = █ _head = █
} }
} }
@ -80,14 +78,14 @@ void OopStorage::AllocateList::push_back(const Block& block) {
assert(_head == NULL, "invariant"); assert(_head == NULL, "invariant");
_head = _tail = █ _head = _tail = █
} else { } else {
_get_entry(*old)._next = █ old->allocate_entry()._next = █
_get_entry(block)._prev = old; block.allocate_entry()._prev = old;
_tail = █ _tail = █
} }
} }
void OopStorage::AllocateList::unlink(const Block& block) { void OopStorage::AllocateList::unlink(const Block& block) {
const AllocateEntry& block_entry = _get_entry(block); const AllocateEntry& block_entry = block.allocate_entry();
const Block* prev_blk = block_entry._prev; const Block* prev_blk = block_entry._prev;
const Block* next_blk = block_entry._next; const Block* next_blk = block_entry._next;
block_entry._prev = NULL; block_entry._prev = NULL;
@ -98,15 +96,15 @@ void OopStorage::AllocateList::unlink(const Block& block) {
_head = _tail = NULL; _head = _tail = NULL;
} else if (prev_blk == NULL) { } else if (prev_blk == NULL) {
assert(_head == &block, "invariant"); assert(_head == &block, "invariant");
_get_entry(*next_blk)._prev = NULL; next_blk->allocate_entry()._prev = NULL;
_head = next_blk; _head = next_blk;
} else if (next_blk == NULL) { } else if (next_blk == NULL) {
assert(_tail == &block, "invariant"); assert(_tail == &block, "invariant");
_get_entry(*prev_blk)._next = NULL; prev_blk->allocate_entry()._next = NULL;
_tail = prev_blk; _tail = prev_blk;
} else { } else {
_get_entry(*next_blk)._prev = prev_blk; next_blk->allocate_entry()._prev = prev_blk;
_get_entry(*prev_blk)._next = next_blk; prev_blk->allocate_entry()._next = next_blk;
} }
} }
@ -232,10 +230,6 @@ OopStorage::Block::~Block() {
const_cast<OopStorage* volatile&>(_owner) = NULL; const_cast<OopStorage* volatile&>(_owner) = NULL;
} }
const OopStorage::AllocateEntry& OopStorage::Block::get_allocate_entry(const Block& block) {
return block._allocate_entry;
}
size_t OopStorage::Block::allocation_size() { size_t OopStorage::Block::allocation_size() {
// _data must be first member, so aligning Block aligns _data. // _data must be first member, so aligning Block aligns _data.
STATIC_ASSERT(_data_pos == 0); STATIC_ASSERT(_data_pos == 0);
@ -769,7 +763,7 @@ OopStorage::OopStorage(const char* name,
Mutex* active_mutex) : Mutex* active_mutex) :
_name(dup_name(name)), _name(dup_name(name)),
_active_array(ActiveArray::create(initial_active_array_size)), _active_array(ActiveArray::create(initial_active_array_size)),
_allocate_list(&Block::get_allocate_entry), _allocate_list(),
_deferred_updates(NULL), _deferred_updates(NULL),
_allocate_mutex(allocate_mutex), _allocate_mutex(allocate_mutex),
_active_mutex(active_mutex), _active_mutex(active_mutex),

View file

@ -178,14 +178,13 @@ NOT_AIX( private: )
class AllocateList { class AllocateList {
const Block* _head; const Block* _head;
const Block* _tail; const Block* _tail;
const AllocateEntry& (*_get_entry)(const Block& block);
// Noncopyable. // Noncopyable.
AllocateList(const AllocateList&); AllocateList(const AllocateList&);
AllocateList& operator=(const AllocateList&); AllocateList& operator=(const AllocateList&);
public: public:
AllocateList(const AllocateEntry& (*get_entry)(const Block& block)); AllocateList();
~AllocateList(); ~AllocateList();
Block* head(); Block* head();

View file

@ -158,7 +158,7 @@ class OopStorage::Block /* No base class, to avoid messing up alignment. */ {
Block& operator=(const Block&); Block& operator=(const Block&);
public: public:
static const AllocateEntry& get_allocate_entry(const Block& block); const AllocateEntry& allocate_entry() const;
static size_t allocation_size(); static size_t allocation_size();
static size_t allocation_alignment_shift(); static size_t allocation_alignment_shift();
@ -214,19 +214,19 @@ inline const OopStorage::Block* OopStorage::AllocateList::ctail() const {
} }
inline OopStorage::Block* OopStorage::AllocateList::prev(Block& block) { inline OopStorage::Block* OopStorage::AllocateList::prev(Block& block) {
return const_cast<Block*>(_get_entry(block)._prev); return const_cast<Block*>(block.allocate_entry()._prev);
} }
inline OopStorage::Block* OopStorage::AllocateList::next(Block& block) { inline OopStorage::Block* OopStorage::AllocateList::next(Block& block) {
return const_cast<Block*>(_get_entry(block)._next); return const_cast<Block*>(block.allocate_entry()._next);
} }
inline const OopStorage::Block* OopStorage::AllocateList::prev(const Block& block) const { inline const OopStorage::Block* OopStorage::AllocateList::prev(const Block& block) const {
return _get_entry(block)._prev; return block.allocate_entry()._prev;
} }
inline const OopStorage::Block* OopStorage::AllocateList::next(const Block& block) const { inline const OopStorage::Block* OopStorage::AllocateList::next(const Block& block) const {
return _get_entry(block)._next; return block.allocate_entry()._next;
} }
template<typename Closure> template<typename Closure>
@ -296,7 +296,11 @@ inline OopStorage::SkipNullFn<F> OopStorage::skip_null_fn(F f) {
return SkipNullFn<F>(f); return SkipNullFn<F>(f);
} }
// Inline Block accesses for use in iteration inner loop. // Inline Block accesses for use in iteration loops.
inline const OopStorage::AllocateEntry& OopStorage::Block::allocate_entry() const {
return _allocate_entry;
}
inline void OopStorage::Block::check_index(unsigned index) const { inline void OopStorage::Block::check_index(unsigned index) const {
assert(index < ARRAY_SIZE(_data), "Index out of bounds: %u", index); assert(index < ARRAY_SIZE(_data), "Index out of bounds: %u", index);

View file

@ -1203,7 +1203,7 @@ const void* const OopStorageBlockCollectionTest::_pseudo_owner[] = {};
class OopStorageAllocateListTest : public OopStorageBlockCollectionTest {}; class OopStorageAllocateListTest : public OopStorageBlockCollectionTest {};
TEST_F(OopStorageAllocateListTest, empty_list) { TEST_F(OopStorageAllocateListTest, empty_list) {
AllocateList list(&OopBlock::get_allocate_entry); AllocateList list;
EXPECT_TRUE(is_list_empty(list)); EXPECT_TRUE(is_list_empty(list));
EXPECT_EQ(NULL_BLOCK, list.head()); EXPECT_EQ(NULL_BLOCK, list.head());
@ -1212,7 +1212,7 @@ TEST_F(OopStorageAllocateListTest, empty_list) {
} }
TEST_F(OopStorageAllocateListTest, push_back) { TEST_F(OopStorageAllocateListTest, push_back) {
AllocateList list(&OopBlock::get_allocate_entry); AllocateList list;
for (size_t i = 0; i < nvalues; ++i) { for (size_t i = 0; i < nvalues; ++i) {
list.push_back(*values[i]); list.push_back(*values[i]);
@ -1242,7 +1242,7 @@ TEST_F(OopStorageAllocateListTest, push_back) {
} }
TEST_F(OopStorageAllocateListTest, push_front) { TEST_F(OopStorageAllocateListTest, push_front) {
AllocateList list(&OopBlock::get_allocate_entry); AllocateList list;
for (size_t i = 0; i < nvalues; ++i) { for (size_t i = 0; i < nvalues; ++i) {
list.push_front(*values[i]); list.push_front(*values[i]);
@ -1273,7 +1273,7 @@ TEST_F(OopStorageAllocateListTest, push_front) {
class OopStorageAllocateListTestWithList : public OopStorageAllocateListTest { class OopStorageAllocateListTestWithList : public OopStorageAllocateListTest {
public: public:
OopStorageAllocateListTestWithList() : list(&OopBlock::get_allocate_entry) { OopStorageAllocateListTestWithList() : list() {
for (size_t i = 0; i < nvalues; ++i) { for (size_t i = 0; i < nvalues; ++i) {
list.push_back(*values[i]); list.push_back(*values[i]);
} }
@ -1345,7 +1345,7 @@ TEST_F(OopStorageAllocateListTestWithList, unlink_middle) {
} }
TEST_F(OopStorageAllocateListTest, single) { TEST_F(OopStorageAllocateListTest, single) {
AllocateList list(&OopBlock::get_allocate_entry); AllocateList list;
list.push_back(*values[0]); list.push_back(*values[0]);
EXPECT_EQ(NULL_BLOCK, list.next(*values[0])); EXPECT_EQ(NULL_BLOCK, list.next(*values[0]));