Skip to content

Commit 4ea6abf

Browse files
author
Kim Barrett
committed
8264324: Simplify allocation list management in OopStorage::reduce_deferred_updates
Reviewed-by: tschatzl, ayang
1 parent 8735259 commit 4ea6abf

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

src/hotspot/share/gc/shared/oopStorage.cpp

+22-19
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ void OopStorage::AllocationList::unlink(const Block& block) {
111111
}
112112
}
113113

114+
bool OopStorage::AllocationList::contains(const Block& block) const {
115+
return (next(block) != NULL) || (ctail() == &block);
116+
}
117+
114118
OopStorage::ActiveArray::ActiveArray(size_t size) :
115119
_size(size),
116120
_block_count(0),
@@ -245,8 +249,8 @@ size_t OopStorage::Block::allocation_alignment_shift() {
245249
return exact_log2(block_alignment);
246250
}
247251

248-
inline bool is_full_bitmask(uintx bitmask) { return ~bitmask == 0; }
249-
inline bool is_empty_bitmask(uintx bitmask) { return bitmask == 0; }
252+
static inline bool is_full_bitmask(uintx bitmask) { return ~bitmask == 0; }
253+
static inline bool is_empty_bitmask(uintx bitmask) { return bitmask == 0; }
250254

251255
bool OopStorage::Block::is_full() const {
252256
return is_full_bitmask(allocated_bitmask());
@@ -667,32 +671,31 @@ bool OopStorage::reduce_deferred_updates() {
667671
// bitmask state here while blocking a release() operation from recording
668672
// the deferred update needed for its bitmask change.
669673
OrderAccess::fence();
670-
// Process popped block.
674+
// Make list state consistent with bitmask state.
671675
uintx allocated = block->allocated_bitmask();
672-
673-
// Make membership in list consistent with bitmask state.
674-
if ((_allocation_list.ctail() != NULL) &&
675-
((_allocation_list.ctail() == block) ||
676-
(_allocation_list.next(*block) != NULL))) {
677-
// Block is in the _allocation_list.
678-
assert(!is_full_bitmask(allocated), "invariant");
679-
} else if (!is_full_bitmask(allocated)) {
680-
// Block is not in the _allocation_list, but now should be.
681-
_allocation_list.push_front(*block);
682-
} // Else block is full and not in list, which is correct.
683-
684-
// Move empty block to end of list, for possible deletion.
685-
if (is_empty_bitmask(allocated)) {
686-
_allocation_list.unlink(*block);
676+
if (is_full_bitmask(allocated)) {
677+
// If full then it shouldn't be in the list, and should stay that way.
678+
assert(!_allocation_list.contains(*block), "invariant");
679+
} else if (_allocation_list.contains(*block)) {
680+
// Block is in list. If empty, move to the end for possible deletion.
681+
if (is_empty_bitmask(allocated)) {
682+
_allocation_list.unlink(*block);
683+
_allocation_list.push_back(*block);
684+
}
685+
} else if (is_empty_bitmask(allocated)) {
686+
// Block is empty and not in list. Add to back for possible deletion.
687687
_allocation_list.push_back(*block);
688+
} else {
689+
// Block is neither full nor empty, and not in list. Add to front.
690+
_allocation_list.push_front(*block);
688691
}
689692

690693
log_trace(oopstorage, blocks)("%s: processed deferred update " PTR_FORMAT,
691694
name(), p2i(block));
692695
return true; // Processed one pending update.
693696
}
694697

695-
inline void check_release_entry(const oop* entry) {
698+
static inline void check_release_entry(const oop* entry) {
696699
assert(entry != NULL, "Releasing NULL");
697700
assert(*entry == NULL, "Releasing uncleared entry: " PTR_FORMAT, p2i(entry));
698701
}

src/hotspot/share/gc/shared/oopStorage.hpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ class OopStorage {
212212
class ActiveArray; // Array of Blocks, plus bookkeeping.
213213
class AllocationListEntry; // Provides AllocationList links in a Block.
214214

215-
// Doubly-linked list of Blocks.
215+
// Doubly-linked list of Blocks. For all operations with a block
216+
// argument, the block must be from the list's OopStorage.
216217
class AllocationList {
217218
const Block* _head;
218219
const Block* _tail;
@@ -237,6 +238,8 @@ class OopStorage {
237238
void push_front(const Block& block);
238239
void push_back(const Block& block);
239240
void unlink(const Block& block);
241+
242+
bool contains(const Block& block) const;
240243
};
241244

242245
private:

0 commit comments

Comments
 (0)