8241771: Remove dead code in SparsePRT

Reviewed-by: sjohanss, tschatzl
This commit is contained in:
Claes Redestad 2020-03-28 21:08:32 +01:00
parent 98e6be7cc2
commit 253ccad50a
2 changed files with 3 additions and 108 deletions

View File

@ -30,7 +30,6 @@
#include "gc/shared/cardTableBarrierSet.hpp"
#include "gc/shared/space.inline.hpp"
#include "memory/allocation.inline.hpp"
#include "runtime/mutexLocker.hpp"
// Check that the size of the SparsePRTEntry is evenly divisible by the maximum
// member type to avoid SIGBUS when accessing them.
@ -87,17 +86,15 @@ void SparsePRTEntry::copy_cards(SparsePRTEntry* e) const {
float RSHashTable::TableOccupancyFactor = 0.5f;
RSHashTable::RSHashTable(size_t capacity) :
_num_entries(0),
_num_entries((capacity * TableOccupancyFactor) + 1),
_capacity(capacity),
_capacity_mask(capacity-1),
_capacity_mask(capacity - 1),
_occupied_entries(0),
_entries(NULL),
_entries((SparsePRTEntry*)NEW_C_HEAP_ARRAY(char, _num_entries * SparsePRTEntry::size(), mtGC)),
_buckets(NEW_C_HEAP_ARRAY(int, capacity, mtGC)),
_free_region(0),
_free_list(NullEntry)
{
_num_entries = (capacity * TableOccupancyFactor) + 1;
_entries = (SparsePRTEntry*)NEW_C_HEAP_ARRAY(char, _num_entries * SparsePRTEntry::size(), mtGC);
clear();
}
@ -208,61 +205,6 @@ void RSHashTable::add_entry(SparsePRTEntry* e) {
assert(e2->num_valid_cards() > 0, "Postcondition.");
}
CardIdx_t RSHashTableIter::find_first_card_in_list() {
while (_bl_ind != RSHashTable::NullEntry) {
SparsePRTEntry* sparse_entry = _rsht->entry(_bl_ind);
if (sparse_entry->num_valid_cards() > 0) {
return sparse_entry->card(0);
} else {
_bl_ind = sparse_entry->next_index();
}
}
// Otherwise, none found:
return NoCardFound;
}
size_t RSHashTableIter::compute_card_ind(CardIdx_t ci) {
return (_rsht->entry(_bl_ind)->r_ind() * HeapRegion::CardsPerRegion) + ci;
}
bool RSHashTableIter::has_next(size_t& card_index) {
_card_ind++;
if (_bl_ind >= 0) {
SparsePRTEntry* e = _rsht->entry(_bl_ind);
if (_card_ind < e->num_valid_cards()) {
CardIdx_t ci = e->card(_card_ind);
card_index = compute_card_ind(ci);
return true;
}
}
// Otherwise, must find the next valid entry.
_card_ind = 0;
if (_bl_ind != RSHashTable::NullEntry) {
_bl_ind = _rsht->entry(_bl_ind)->next_index();
CardIdx_t ci = find_first_card_in_list();
if (ci != NoCardFound) {
card_index = compute_card_ind(ci);
return true;
}
}
// If we didn't return above, must go to the next non-null table index.
_tbl_ind++;
while ((size_t)_tbl_ind < _rsht->capacity()) {
_bl_ind = _rsht->_buckets[_tbl_ind];
CardIdx_t ci = find_first_card_in_list();
if (ci != NoCardFound) {
card_index = compute_card_ind(ci);
return true;
}
// Otherwise, try next entry.
_tbl_ind++;
}
// Otherwise, there were no entry.
return false;
}
bool RSHashTableBucketIter::has_next(SparsePRTEntry*& entry) {
while (_bl_ind == RSHashTable::NullEntry) {
if (_tbl_ind == (int)_rsht->capacity() - 1) {

View File

@ -35,14 +35,12 @@
class RSHashTable;
class SparsePRTEntry;
class SparsePRTIter;
// Sparse remembered set for a heap region (the "owning" region). Maps
// indices of other regions to short sequences of cards in the other region
// that might contain pointers into the owner region.
// Concurrent access to a SparsePRT must be serialized by some external mutex.
class SparsePRT {
friend class SparsePRTIter;
friend class SparsePRTBucketIter;
RSHashTable* _table;
@ -119,7 +117,6 @@ public:
RegionIdx_t r_ind() const { return _region_ind; }
bool valid_entry() const { return r_ind() >= 0; }
void set_r_ind(RegionIdx_t rind) { _region_ind = rind; }
int next_index() const { return _next_index; }
int* next_index_addr() { return &_next_index; }
@ -147,7 +144,6 @@ public:
class RSHashTable : public CHeapObj<mtGC> {
friend class RSHashTableIter;
friend class RSHashTableBucketIter;
// Inverse maximum hash table occupancy used.
@ -158,7 +154,6 @@ class RSHashTable : public CHeapObj<mtGC> {
size_t _capacity;
size_t _capacity_mask;
size_t _occupied_entries;
size_t _occupied_cards;
SparsePRTEntry* _entries;
int* _buckets;
@ -206,7 +201,6 @@ public:
size_t capacity() const { return _capacity; }
size_t capacity_mask() const { return _capacity_mask; }
size_t occupied_entries() const { return _occupied_entries; }
size_t mem_size() const;
// The number of SparsePRTEntry instances available.
size_t num_entries() const { return _num_entries; }
@ -219,37 +213,6 @@ public:
void print();
};
// This is embedded in HRRS iterator.
class RSHashTableIter {
// Return value indicating "invalid/no card".
static const int NoCardFound = -1;
int _tbl_ind; // [-1, 0.._rsht->_capacity)
int _bl_ind; // [-1, 0.._rsht->_capacity)
short _card_ind; // [0..SparsePRTEntry::cards_num())
RSHashTable* _rsht;
// If the bucket list pointed to by _bl_ind contains a card, sets
// _bl_ind to the index of that entry,
// Returns the card found if there is, otherwise returns InvalidCard.
CardIdx_t find_first_card_in_list();
// Computes the proper card index for the card whose offset in the
// current region (as indicated by _bl_ind) is "ci".
// This is subject to errors when there is iteration concurrent with
// modification, but these errors should be benign.
size_t compute_card_ind(CardIdx_t ci);
public:
RSHashTableIter(RSHashTable* rsht) :
_tbl_ind(RSHashTable::NullEntry), // So that first increment gets to 0.
_bl_ind(RSHashTable::NullEntry),
_card_ind((SparsePRTEntry::cards_num() - 1)),
_rsht(rsht) {}
bool has_next(size_t& card_index);
};
// This is embedded in HRRS iterator.
class RSHashTableBucketIter {
int _tbl_ind; // [-1, 0.._rsht->_capacity)
@ -266,16 +229,6 @@ public:
bool has_next(SparsePRTEntry*& entry);
};
class SparsePRTIter: public RSHashTableIter {
public:
SparsePRTIter(const SparsePRT* sprt) :
RSHashTableIter(sprt->_table) { }
bool has_next(size_t& card_index) {
return RSHashTableIter::has_next(card_index);
}
};
class SparsePRTBucketIter: public RSHashTableBucketIter {
public:
SparsePRTBucketIter(const SparsePRT* sprt) :