8240668: G1 list of all PerRegionTable does not have to be a double linkedlist any more

Reviewed-by: kbarrett, tschatzl
This commit is contained in:
Ivan Walulya 2020-03-10 10:19:34 +01:00
parent 43e0165eea
commit d49eb0d9a7
3 changed files with 3 additions and 54 deletions

@ -102,60 +102,20 @@ void OtherRegionsTable::link_to_all(PerRegionTable* prt) {
// We always append to the beginning of the list for convenience;
// the order of entries in this list does not matter.
if (_first_all_fine_prts != NULL) {
assert(_first_all_fine_prts->prev() == NULL, "invariant");
_first_all_fine_prts->set_prev(prt);
prt->set_next(_first_all_fine_prts);
} else {
// this is the first element we insert. Adjust the "last" pointer
_last_all_fine_prts = prt;
assert(prt->next() == NULL, "just checking");
}
// the new element is always the first element without a predecessor
prt->set_prev(NULL);
_first_all_fine_prts = prt;
assert(prt->prev() == NULL, "just checking");
assert(_first_all_fine_prts == prt, "just checking");
assert((_first_all_fine_prts == NULL && _last_all_fine_prts == NULL) ||
(_first_all_fine_prts != NULL && _last_all_fine_prts != NULL),
"just checking");
assert(_last_all_fine_prts == NULL || _last_all_fine_prts->next() == NULL,
"just checking");
assert(_first_all_fine_prts == NULL || _first_all_fine_prts->prev() == NULL,
"just checking");
}
void OtherRegionsTable::unlink_from_all(PerRegionTable* prt) {
if (prt->prev() != NULL) {
assert(_first_all_fine_prts != prt, "just checking");
prt->prev()->set_next(prt->next());
// removing the last element in the list?
if (_last_all_fine_prts == prt) {
_last_all_fine_prts = prt->prev();
}
} else {
assert(_first_all_fine_prts == prt, "just checking");
_first_all_fine_prts = prt->next();
// list is empty now?
if (_first_all_fine_prts == NULL) {
_last_all_fine_prts = NULL;
}
}
if (prt->next() != NULL) {
prt->next()->set_prev(prt->prev());
}
prt->set_next(NULL);
prt->set_prev(NULL);
assert((_first_all_fine_prts == NULL && _last_all_fine_prts == NULL) ||
(_first_all_fine_prts != NULL && _last_all_fine_prts != NULL),
"just checking");
assert(_last_all_fine_prts == NULL || _last_all_fine_prts->next() == NULL,
"just checking");
assert(_first_all_fine_prts == NULL || _first_all_fine_prts->prev() == NULL,
"just checking");
}
CardIdx_t OtherRegionsTable::card_within_region(OopOrNarrowOopStar within_region, HeapRegion* hr) {

@ -81,8 +81,8 @@ class OtherRegionsTable {
PerRegionTable** _fine_grain_regions;
size_t _n_fine_entries;
// The fine grain remembered sets are doubly linked together using
// their 'next' and 'prev' fields.
// The fine grain remembered sets are linked together using
// their 'next' fields.
// This allows fast bulk freeing of all the fine grain remembered
// set entries, and fast finding of all of them without iterating
// over the _fine_grain_regions table.
@ -113,8 +113,6 @@ class OtherRegionsTable {
// link/add the given fine grain remembered set into the "all" list
void link_to_all(PerRegionTable * prt);
// unlink/remove the given fine grain remembered set into the "all" list
void unlink_from_all(PerRegionTable * prt);
bool contains_reference_locked(OopOrNarrowOopStar from) const;
@ -167,9 +165,6 @@ class PerRegionTable: public CHeapObj<mtGC> {
// next pointer for free/allocated 'all' list
PerRegionTable* _next;
// prev pointer for the allocated 'all' list
PerRegionTable* _prev;
// next pointer in collision list
PerRegionTable * _collision_list_next;
@ -181,7 +176,7 @@ protected:
_hr(hr),
_bm(HeapRegion::CardsPerRegion, mtGC),
_occupied(0),
_next(NULL), _prev(NULL),
_next(NULL),
_collision_list_next(NULL)
{}
@ -243,16 +238,11 @@ public:
PerRegionTable* next() const { return _next; }
void set_next(PerRegionTable* next) { _next = next; }
PerRegionTable* prev() const { return _prev; }
void set_prev(PerRegionTable* prev) { _prev = prev; }
// Accessor and Modification routines for the pointer for the
// singly linked collision list that links the PRTs within the
// OtherRegionsTable::_fine_grain_regions hash table.
//
// It might be useful to also make the collision list doubly linked
// to avoid iteration over the collisions list during scrubbing/deletion.
// OTOH there might not be many collisions.
PerRegionTable* collision_list_next() const {
return _collision_list_next;

@ -62,7 +62,6 @@ inline bool PerRegionTable::add_reference(OopOrNarrowOopStar from) {
inline void PerRegionTable::init(HeapRegion* hr, bool clear_links_to_all_list) {
if (clear_links_to_all_list) {
set_next(NULL);
set_prev(NULL);
}
_collision_list_next = NULL;
_occupied = 0;