Skip to content
Permalink
Browse files
8240668: G1 list of all PerRegionTable does not have to be a double l…
…inkedlist any more

Reviewed-by: kbarrett, tschatzl
  • Loading branch information
Ivan Walulya committed Mar 10, 2020
1 parent 43e0165 commit d49eb0d9a7a9cb53c8d44b8b8b8d7cdf6aa62662
Showing with 3 additions and 54 deletions.
  1. +0 −40 src/hotspot/share/gc/g1/heapRegionRemSet.cpp
  2. +3 −13 src/hotspot/share/gc/g1/heapRegionRemSet.hpp
  3. +0 −1 src/hotspot/share/gc/g1/heapRegionRemSet.inline.hpp
@@ -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 @@ class PerRegionTable: public CHeapObj<mtGC> {
_hr(hr),
_bm(HeapRegion::CardsPerRegion, mtGC),
_occupied(0),
_next(NULL), _prev(NULL),
_next(NULL),
_collision_list_next(NULL)
{}

@@ -243,16 +238,11 @@ class PerRegionTable: public CHeapObj<mtGC> {

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;

0 comments on commit d49eb0d

Please sign in to comment.