mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
Stack allocate instances of HeapRegionRemSetIterator during RSet scanning. Reviewed-by: brutisso, jwilhelm
This commit is contained in:
parent
c47ec9b4ca
commit
eafc00bc25
8 changed files with 38 additions and 92 deletions
|
@ -1955,13 +1955,6 @@ G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* policy_) :
|
||||||
int n_rem_sets = HeapRegionRemSet::num_par_rem_sets();
|
int n_rem_sets = HeapRegionRemSet::num_par_rem_sets();
|
||||||
assert(n_rem_sets > 0, "Invariant.");
|
assert(n_rem_sets > 0, "Invariant.");
|
||||||
|
|
||||||
HeapRegionRemSetIterator** iter_arr =
|
|
||||||
NEW_C_HEAP_ARRAY(HeapRegionRemSetIterator*, n_queues, mtGC);
|
|
||||||
for (int i = 0; i < n_queues; i++) {
|
|
||||||
iter_arr[i] = new HeapRegionRemSetIterator();
|
|
||||||
}
|
|
||||||
_rem_set_iterator = iter_arr;
|
|
||||||
|
|
||||||
_worker_cset_start_region = NEW_C_HEAP_ARRAY(HeapRegion*, n_queues, mtGC);
|
_worker_cset_start_region = NEW_C_HEAP_ARRAY(HeapRegion*, n_queues, mtGC);
|
||||||
_worker_cset_start_region_time_stamp = NEW_C_HEAP_ARRAY(unsigned int, n_queues, mtGC);
|
_worker_cset_start_region_time_stamp = NEW_C_HEAP_ARRAY(unsigned int, n_queues, mtGC);
|
||||||
|
|
||||||
|
|
|
@ -786,9 +786,6 @@ protected:
|
||||||
// concurrently after the collection.
|
// concurrently after the collection.
|
||||||
DirtyCardQueueSet _dirty_card_queue_set;
|
DirtyCardQueueSet _dirty_card_queue_set;
|
||||||
|
|
||||||
// The Heap Region Rem Set Iterator.
|
|
||||||
HeapRegionRemSetIterator** _rem_set_iterator;
|
|
||||||
|
|
||||||
// The closure used to refine a single card.
|
// The closure used to refine a single card.
|
||||||
RefineCardTableEntryClosure* _refine_cte_cl;
|
RefineCardTableEntryClosure* _refine_cte_cl;
|
||||||
|
|
||||||
|
@ -1113,15 +1110,6 @@ public:
|
||||||
G1RemSet* g1_rem_set() const { return _g1_rem_set; }
|
G1RemSet* g1_rem_set() const { return _g1_rem_set; }
|
||||||
ModRefBarrierSet* mr_bs() const { return _mr_bs; }
|
ModRefBarrierSet* mr_bs() const { return _mr_bs; }
|
||||||
|
|
||||||
// The rem set iterator.
|
|
||||||
HeapRegionRemSetIterator* rem_set_iterator(int i) {
|
|
||||||
return _rem_set_iterator[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
HeapRegionRemSetIterator* rem_set_iterator() {
|
|
||||||
return _rem_set_iterator[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned get_gc_time_stamp() {
|
unsigned get_gc_time_stamp() {
|
||||||
return _gc_time_stamp;
|
return _gc_time_stamp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,14 +169,13 @@ public:
|
||||||
// _try_claimed || r->claim_iter()
|
// _try_claimed || r->claim_iter()
|
||||||
// is true: either we're supposed to work on claimed-but-not-complete
|
// is true: either we're supposed to work on claimed-but-not-complete
|
||||||
// regions, or we successfully claimed the region.
|
// regions, or we successfully claimed the region.
|
||||||
HeapRegionRemSetIterator* iter = _g1h->rem_set_iterator(_worker_i);
|
HeapRegionRemSetIterator iter(hrrs);
|
||||||
hrrs->init_iterator(iter);
|
|
||||||
size_t card_index;
|
size_t card_index;
|
||||||
|
|
||||||
// We claim cards in block so as to recude the contention. The block size is determined by
|
// We claim cards in block so as to recude the contention. The block size is determined by
|
||||||
// the G1RSetScanBlockSize parameter.
|
// the G1RSetScanBlockSize parameter.
|
||||||
size_t jump_to_card = hrrs->iter_claimed_next(_block_size);
|
size_t jump_to_card = hrrs->iter_claimed_next(_block_size);
|
||||||
for (size_t current_card = 0; iter->has_next(card_index); current_card++) {
|
for (size_t current_card = 0; iter.has_next(card_index); current_card++) {
|
||||||
if (current_card >= jump_to_card + _block_size) {
|
if (current_card >= jump_to_card + _block_size) {
|
||||||
jump_to_card = hrrs->iter_claimed_next(_block_size);
|
jump_to_card = hrrs->iter_claimed_next(_block_size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -877,14 +877,9 @@ bool HeapRegionRemSet::iter_is_complete() {
|
||||||
return _iter_state == Complete;
|
return _iter_state == Complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeapRegionRemSet::init_iterator(HeapRegionRemSetIterator* iter) const {
|
|
||||||
iter->initialize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef PRODUCT
|
#ifndef PRODUCT
|
||||||
void HeapRegionRemSet::print() const {
|
void HeapRegionRemSet::print() const {
|
||||||
HeapRegionRemSetIterator iter;
|
HeapRegionRemSetIterator iter(this);
|
||||||
init_iterator(&iter);
|
|
||||||
size_t card_index;
|
size_t card_index;
|
||||||
while (iter.has_next(card_index)) {
|
while (iter.has_next(card_index)) {
|
||||||
HeapWord* card_start =
|
HeapWord* card_start =
|
||||||
|
@ -928,35 +923,23 @@ void HeapRegionRemSet::scrub(CardTableModRefBS* ctbs,
|
||||||
|
|
||||||
//-------------------- Iteration --------------------
|
//-------------------- Iteration --------------------
|
||||||
|
|
||||||
HeapRegionRemSetIterator::
|
HeapRegionRemSetIterator:: HeapRegionRemSetIterator(const HeapRegionRemSet* hrrs) :
|
||||||
HeapRegionRemSetIterator() :
|
_hrrs(hrrs),
|
||||||
_hrrs(NULL),
|
|
||||||
_g1h(G1CollectedHeap::heap()),
|
_g1h(G1CollectedHeap::heap()),
|
||||||
_bosa(NULL),
|
_coarse_map(&hrrs->_other_regions._coarse_map),
|
||||||
_sparse_iter() { }
|
_fine_grain_regions(hrrs->_other_regions._fine_grain_regions),
|
||||||
|
_bosa(hrrs->bosa()),
|
||||||
void HeapRegionRemSetIterator::initialize(const HeapRegionRemSet* hrrs) {
|
_is(Sparse),
|
||||||
_hrrs = hrrs;
|
|
||||||
_coarse_map = &_hrrs->_other_regions._coarse_map;
|
|
||||||
_fine_grain_regions = _hrrs->_other_regions._fine_grain_regions;
|
|
||||||
_bosa = _hrrs->bosa();
|
|
||||||
|
|
||||||
_is = Sparse;
|
|
||||||
// Set these values so that we increment to the first region.
|
// Set these values so that we increment to the first region.
|
||||||
_coarse_cur_region_index = -1;
|
_coarse_cur_region_index(-1),
|
||||||
_coarse_cur_region_cur_card = (HeapRegion::CardsPerRegion-1);
|
_coarse_cur_region_cur_card(HeapRegion::CardsPerRegion-1),
|
||||||
|
_cur_region_cur_card(0),
|
||||||
_cur_region_cur_card = 0;
|
_fine_array_index(-1),
|
||||||
|
_fine_cur_prt(NULL),
|
||||||
_fine_array_index = -1;
|
_n_yielded_coarse(0),
|
||||||
_fine_cur_prt = NULL;
|
_n_yielded_fine(0),
|
||||||
|
_n_yielded_sparse(0),
|
||||||
_n_yielded_coarse = 0;
|
_sparse_iter(&hrrs->_other_regions._sparse_table) {}
|
||||||
_n_yielded_fine = 0;
|
|
||||||
_n_yielded_sparse = 0;
|
|
||||||
|
|
||||||
_sparse_iter.init(&hrrs->_other_regions._sparse_table);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HeapRegionRemSetIterator::coarse_has_next(size_t& card_index) {
|
bool HeapRegionRemSetIterator::coarse_has_next(size_t& card_index) {
|
||||||
if (_hrrs->_other_regions._n_coarse_entries == 0) return false;
|
if (_hrrs->_other_regions._n_coarse_entries == 0) return false;
|
||||||
|
@ -1209,8 +1192,7 @@ void HeapRegionRemSet::test() {
|
||||||
hrrs->add_reference((OopOrNarrowOopStar)hr5->bottom());
|
hrrs->add_reference((OopOrNarrowOopStar)hr5->bottom());
|
||||||
|
|
||||||
// Now, does iteration yield these three?
|
// Now, does iteration yield these three?
|
||||||
HeapRegionRemSetIterator iter;
|
HeapRegionRemSetIterator iter(hrrs);
|
||||||
hrrs->init_iterator(&iter);
|
|
||||||
size_t sum = 0;
|
size_t sum = 0;
|
||||||
size_t card_index;
|
size_t card_index;
|
||||||
while (iter.has_next(card_index)) {
|
while (iter.has_next(card_index)) {
|
||||||
|
|
|
@ -281,9 +281,6 @@ public:
|
||||||
return (_iter_state == Unclaimed) && (_iter_claimed == 0);
|
return (_iter_state == Unclaimed) && (_iter_claimed == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the given iterator to iterate over this rem set.
|
|
||||||
void init_iterator(HeapRegionRemSetIterator* iter) const;
|
|
||||||
|
|
||||||
// The actual # of bytes this hr_remset takes up.
|
// The actual # of bytes this hr_remset takes up.
|
||||||
size_t mem_size() {
|
size_t mem_size() {
|
||||||
return _other_regions.mem_size()
|
return _other_regions.mem_size()
|
||||||
|
@ -345,9 +342,9 @@ public:
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class HeapRegionRemSetIterator : public CHeapObj<mtGC> {
|
class HeapRegionRemSetIterator : public StackObj {
|
||||||
|
|
||||||
// The region over which we're iterating.
|
// The region RSet over which we're iterating.
|
||||||
const HeapRegionRemSet* _hrrs;
|
const HeapRegionRemSet* _hrrs;
|
||||||
|
|
||||||
// Local caching of HRRS fields.
|
// Local caching of HRRS fields.
|
||||||
|
@ -362,8 +359,10 @@ class HeapRegionRemSetIterator : public CHeapObj<mtGC> {
|
||||||
size_t _n_yielded_coarse;
|
size_t _n_yielded_coarse;
|
||||||
size_t _n_yielded_sparse;
|
size_t _n_yielded_sparse;
|
||||||
|
|
||||||
// If true we're iterating over the coarse table; if false the fine
|
// Indicates what granularity of table that we're currently iterating over.
|
||||||
// table.
|
// We start iterating over the sparse table, progress to the fine grain
|
||||||
|
// table, and then finish with the coarse table.
|
||||||
|
// See HeapRegionRemSetIterator::has_next().
|
||||||
enum IterState {
|
enum IterState {
|
||||||
Sparse,
|
Sparse,
|
||||||
Fine,
|
Fine,
|
||||||
|
@ -403,9 +402,7 @@ class HeapRegionRemSetIterator : public CHeapObj<mtGC> {
|
||||||
public:
|
public:
|
||||||
// We require an iterator to be initialized before use, so the
|
// We require an iterator to be initialized before use, so the
|
||||||
// constructor does little.
|
// constructor does little.
|
||||||
HeapRegionRemSetIterator();
|
HeapRegionRemSetIterator(const HeapRegionRemSet* hrrs);
|
||||||
|
|
||||||
void initialize(const HeapRegionRemSet* hrrs);
|
|
||||||
|
|
||||||
// If there remains one or more cards to be yielded, returns true and
|
// If there remains one or more cards to be yielded, returns true and
|
||||||
// sets "card_index" to one of those cards (which is then considered
|
// sets "card_index" to one of those cards (which is then considered
|
||||||
|
|
|
@ -35,10 +35,6 @@
|
||||||
|
|
||||||
#define UNROLL_CARD_LOOPS 1
|
#define UNROLL_CARD_LOOPS 1
|
||||||
|
|
||||||
void SparsePRT::init_iterator(SparsePRTIter* sprt_iter) {
|
|
||||||
sprt_iter->init(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SparsePRTEntry::init(RegionIdx_t region_ind) {
|
void SparsePRTEntry::init(RegionIdx_t region_ind) {
|
||||||
_region_ind = region_ind;
|
_region_ind = region_ind;
|
||||||
_next_index = NullEntry;
|
_next_index = NullEntry;
|
||||||
|
|
|
@ -192,18 +192,11 @@ class RSHashTableIter VALUE_OBJ_CLASS_SPEC {
|
||||||
size_t compute_card_ind(CardIdx_t ci);
|
size_t compute_card_ind(CardIdx_t ci);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RSHashTableIter() :
|
RSHashTableIter(RSHashTable* rsht) :
|
||||||
_tbl_ind(RSHashTable::NullEntry),
|
_tbl_ind(RSHashTable::NullEntry), // So that first increment gets to 0.
|
||||||
_bl_ind(RSHashTable::NullEntry),
|
_bl_ind(RSHashTable::NullEntry),
|
||||||
_card_ind((SparsePRTEntry::cards_num() - 1)),
|
_card_ind((SparsePRTEntry::cards_num() - 1)),
|
||||||
_rsht(NULL) {}
|
_rsht(rsht) {}
|
||||||
|
|
||||||
void init(RSHashTable* rsht) {
|
|
||||||
_rsht = rsht;
|
|
||||||
_tbl_ind = -1; // So that first increment gets to 0.
|
|
||||||
_bl_ind = RSHashTable::NullEntry;
|
|
||||||
_card_ind = (SparsePRTEntry::cards_num() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool has_next(size_t& card_index);
|
bool has_next(size_t& card_index);
|
||||||
};
|
};
|
||||||
|
@ -284,8 +277,6 @@ public:
|
||||||
static void cleanup_all();
|
static void cleanup_all();
|
||||||
RSHashTable* cur() const { return _cur; }
|
RSHashTable* cur() const { return _cur; }
|
||||||
|
|
||||||
void init_iterator(SparsePRTIter* sprt_iter);
|
|
||||||
|
|
||||||
static void add_to_expanded_list(SparsePRT* sprt);
|
static void add_to_expanded_list(SparsePRT* sprt);
|
||||||
static SparsePRT* get_from_expanded_list();
|
static SparsePRT* get_from_expanded_list();
|
||||||
|
|
||||||
|
@ -321,9 +312,9 @@ public:
|
||||||
|
|
||||||
class SparsePRTIter: public RSHashTableIter {
|
class SparsePRTIter: public RSHashTableIter {
|
||||||
public:
|
public:
|
||||||
void init(const SparsePRT* sprt) {
|
SparsePRTIter(const SparsePRT* sprt) :
|
||||||
RSHashTableIter::init(sprt->cur());
|
RSHashTableIter(sprt->cur()) {}
|
||||||
}
|
|
||||||
bool has_next(size_t& card_index) {
|
bool has_next(size_t& card_index) {
|
||||||
return RSHashTableIter::has_next(card_index);
|
return RSHashTableIter::has_next(card_index);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue