8277789: G1: G1CardSetConfiguration prefixes num_ and max_ used interchangeably

Reviewed-by: mli, tschatzl
This commit is contained in:
Ivan Walulya 2021-11-29 13:10:06 +00:00
parent 614c6e61fa
commit ad51d06925
5 changed files with 51 additions and 53 deletions

View File

@ -135,8 +135,8 @@ void G1Arguments::initialize_card_set_configuration() {
uint region_size_log_mb = (uint)MAX2(HeapRegion::LogOfHRGrainBytes - LOG_M, 0); uint region_size_log_mb = (uint)MAX2(HeapRegion::LogOfHRGrainBytes - LOG_M, 0);
if (FLAG_IS_DEFAULT(G1RemSetArrayOfCardsEntries)) { if (FLAG_IS_DEFAULT(G1RemSetArrayOfCardsEntries)) {
uint num_cards_in_inline_ptr = G1CardSetConfiguration::num_cards_in_inline_ptr(HeapRegion::LogOfHRGrainBytes - CardTable::card_shift); uint max_cards_in_inline_ptr = G1CardSetConfiguration::max_cards_in_inline_ptr(HeapRegion::LogOfHRGrainBytes - CardTable::card_shift);
FLAG_SET_ERGO(G1RemSetArrayOfCardsEntries, MAX2(num_cards_in_inline_ptr * 2, FLAG_SET_ERGO(G1RemSetArrayOfCardsEntries, MAX2(max_cards_in_inline_ptr * 2,
G1RemSetArrayOfCardsEntriesBase * (1u << (region_size_log_mb + 1)))); G1RemSetArrayOfCardsEntriesBase * (1u << (region_size_log_mb + 1))));
} }

View File

@ -57,7 +57,7 @@ static uint default_log2_card_region_per_region() {
G1CardSetConfiguration::G1CardSetConfiguration() : G1CardSetConfiguration::G1CardSetConfiguration() :
G1CardSetConfiguration(HeapRegion::LogCardsPerRegion, /* inline_ptr_bits_per_card */ G1CardSetConfiguration(HeapRegion::LogCardsPerRegion, /* inline_ptr_bits_per_card */
G1RemSetArrayOfCardsEntries, /* num_cards_in_array */ G1RemSetArrayOfCardsEntries, /* max_cards_in_array */
(double)G1RemSetCoarsenHowlBitmapToHowlFullPercent / 100, /* cards_in_bitmap_threshold_percent */ (double)G1RemSetCoarsenHowlBitmapToHowlFullPercent / 100, /* cards_in_bitmap_threshold_percent */
G1RemSetHowlNumBuckets, /* num_buckets_in_howl */ G1RemSetHowlNumBuckets, /* num_buckets_in_howl */
(double)G1RemSetCoarsenHowlToFullPercent / 100, /* cards_in_howl_threshold_percent */ (double)G1RemSetCoarsenHowlToFullPercent / 100, /* cards_in_howl_threshold_percent */
@ -68,17 +68,17 @@ G1CardSetConfiguration::G1CardSetConfiguration() :
"inconsistent heap region virtualization setup"); "inconsistent heap region virtualization setup");
} }
G1CardSetConfiguration::G1CardSetConfiguration(uint num_cards_in_array, G1CardSetConfiguration::G1CardSetConfiguration(uint max_cards_in_array,
double cards_in_bitmap_threshold_percent, double cards_in_bitmap_threshold_percent,
uint max_buckets_in_howl, uint max_buckets_in_howl,
double cards_in_howl_threshold_percent, double cards_in_howl_threshold_percent,
uint max_cards_in_card_set, uint max_cards_in_card_set,
uint log2_card_region_per_region) : uint log2_card_region_per_region) :
G1CardSetConfiguration(log2i_exact(max_cards_in_card_set), /* inline_ptr_bits_per_card */ G1CardSetConfiguration(log2i_exact(max_cards_in_card_set), /* inline_ptr_bits_per_card */
num_cards_in_array, /* num_cards_in_array */ max_cards_in_array, /* max_cards_in_array */
cards_in_bitmap_threshold_percent, /* cards_in_bitmap_threshold_percent */ cards_in_bitmap_threshold_percent, /* cards_in_bitmap_threshold_percent */
G1CardSetHowl::num_buckets(max_cards_in_card_set, /* num_buckets_in_howl */ G1CardSetHowl::num_buckets(max_cards_in_card_set, /* num_buckets_in_howl */
num_cards_in_array, max_cards_in_array,
max_buckets_in_howl), max_buckets_in_howl),
cards_in_howl_threshold_percent, /* cards_in_howl_threshold_percent */ cards_in_howl_threshold_percent, /* cards_in_howl_threshold_percent */
max_cards_in_card_set, /* max_cards_in_cardset */ max_cards_in_card_set, /* max_cards_in_cardset */
@ -86,21 +86,21 @@ G1CardSetConfiguration::G1CardSetConfiguration(uint num_cards_in_array,
{ } { }
G1CardSetConfiguration::G1CardSetConfiguration(uint inline_ptr_bits_per_card, G1CardSetConfiguration::G1CardSetConfiguration(uint inline_ptr_bits_per_card,
uint num_cards_in_array, uint max_cards_in_array,
double cards_in_bitmap_threshold_percent, double cards_in_bitmap_threshold_percent,
uint num_buckets_in_howl, uint num_buckets_in_howl,
double cards_in_howl_threshold_percent, double cards_in_howl_threshold_percent,
uint max_cards_in_card_set, uint max_cards_in_card_set,
uint log2_card_regions_per_heap_region) : uint log2_card_regions_per_heap_region) :
_inline_ptr_bits_per_card(inline_ptr_bits_per_card), _inline_ptr_bits_per_card(inline_ptr_bits_per_card),
_num_cards_in_array(num_cards_in_array), _max_cards_in_array(max_cards_in_array),
_num_buckets_in_howl(num_buckets_in_howl), _num_buckets_in_howl(num_buckets_in_howl),
_max_cards_in_card_set(max_cards_in_card_set), _max_cards_in_card_set(max_cards_in_card_set),
_cards_in_howl_threshold(max_cards_in_card_set * cards_in_howl_threshold_percent), _cards_in_howl_threshold(max_cards_in_card_set * cards_in_howl_threshold_percent),
_num_cards_in_howl_bitmap(G1CardSetHowl::bitmap_size(_max_cards_in_card_set, _num_buckets_in_howl)), _max_cards_in_howl_bitmap(G1CardSetHowl::bitmap_size(_max_cards_in_card_set, _num_buckets_in_howl)),
_cards_in_howl_bitmap_threshold(_num_cards_in_howl_bitmap * cards_in_bitmap_threshold_percent), _cards_in_howl_bitmap_threshold(_max_cards_in_howl_bitmap * cards_in_bitmap_threshold_percent),
_log2_num_cards_in_howl_bitmap(log2i_exact(_num_cards_in_howl_bitmap)), _log2_max_cards_in_howl_bitmap(log2i_exact(_max_cards_in_howl_bitmap)),
_bitmap_hash_mask(~(~(0) << _log2_num_cards_in_howl_bitmap)), _bitmap_hash_mask(~(~(0) << _log2_max_cards_in_howl_bitmap)),
_log2_card_regions_per_heap_region(log2_card_regions_per_heap_region), _log2_card_regions_per_heap_region(log2_card_regions_per_heap_region),
_log2_cards_per_card_region(log2i_exact(_max_cards_in_card_set) - _log2_card_regions_per_heap_region) { _log2_cards_per_card_region(log2i_exact(_max_cards_in_card_set) - _log2_card_regions_per_heap_region) {
@ -118,8 +118,8 @@ G1CardSetConfiguration::~G1CardSetConfiguration() {
void G1CardSetConfiguration::init_card_set_alloc_options() { void G1CardSetConfiguration::init_card_set_alloc_options() {
_card_set_alloc_options = NEW_C_HEAP_ARRAY(G1CardSetAllocOptions, num_mem_object_types(), mtGC); _card_set_alloc_options = NEW_C_HEAP_ARRAY(G1CardSetAllocOptions, num_mem_object_types(), mtGC);
new (&_card_set_alloc_options[0]) G1CardSetAllocOptions((uint)CardSetHash::get_node_size()); new (&_card_set_alloc_options[0]) G1CardSetAllocOptions((uint)CardSetHash::get_node_size());
new (&_card_set_alloc_options[1]) G1CardSetAllocOptions((uint)G1CardSetArray::size_in_bytes(_num_cards_in_array), 2, 256); new (&_card_set_alloc_options[1]) G1CardSetAllocOptions((uint)G1CardSetArray::size_in_bytes(_max_cards_in_array), 2, 256);
new (&_card_set_alloc_options[2]) G1CardSetAllocOptions((uint)G1CardSetBitMap::size_in_bytes(_num_cards_in_howl_bitmap), 2, 256); new (&_card_set_alloc_options[2]) G1CardSetAllocOptions((uint)G1CardSetBitMap::size_in_bytes(_max_cards_in_howl_bitmap), 2, 256);
new (&_card_set_alloc_options[3]) G1CardSetAllocOptions((uint)G1CardSetHowl::size_in_bytes(_num_buckets_in_howl), 2, 256); new (&_card_set_alloc_options[3]) G1CardSetAllocOptions((uint)G1CardSetHowl::size_in_bytes(_num_buckets_in_howl), 2, 256);
} }
@ -130,19 +130,19 @@ void G1CardSetConfiguration::log_configuration() {
"Howl #buckets %u coarsen threshold %u " "Howl #buckets %u coarsen threshold %u "
"Howl Bitmap #elems %u size %zu coarsen threshold %u " "Howl Bitmap #elems %u size %zu coarsen threshold %u "
"Card regions per heap region %u cards per card region %u", "Card regions per heap region %u cards per card region %u",
num_cards_in_inline_ptr(), sizeof(void*), max_cards_in_inline_ptr(), sizeof(void*),
num_cards_in_array(), G1CardSetArray::size_in_bytes(num_cards_in_array()), max_cards_in_array(), G1CardSetArray::size_in_bytes(max_cards_in_array()),
num_buckets_in_howl(), cards_in_howl_threshold(), num_buckets_in_howl(), cards_in_howl_threshold(),
num_cards_in_howl_bitmap(), G1CardSetBitMap::size_in_bytes(num_cards_in_howl_bitmap()), cards_in_howl_bitmap_threshold(), max_cards_in_howl_bitmap(), G1CardSetBitMap::size_in_bytes(max_cards_in_howl_bitmap()), cards_in_howl_bitmap_threshold(),
(uint)1 << log2_card_regions_per_heap_region(), (uint)1 << log2_card_regions_per_heap_region(),
(uint)1 << log2_cards_per_card_region()); (uint)1 << log2_cards_per_card_region());
} }
uint G1CardSetConfiguration::num_cards_in_inline_ptr() const { uint G1CardSetConfiguration::max_cards_in_inline_ptr() const {
return num_cards_in_inline_ptr(_inline_ptr_bits_per_card); return max_cards_in_inline_ptr(_inline_ptr_bits_per_card);
} }
uint G1CardSetConfiguration::num_cards_in_inline_ptr(uint bits_per_card) { uint G1CardSetConfiguration::max_cards_in_inline_ptr(uint bits_per_card) {
return G1CardSetInlinePtr::max_cards_in_inline_ptr(bits_per_card); return G1CardSetInlinePtr::max_cards_in_inline_ptr(bits_per_card);
} }
@ -508,19 +508,19 @@ G1AddCardResult G1CardSet::add_to_howl(CardSetPtr parent_card_set,
G1AddCardResult G1CardSet::add_to_bitmap(CardSetPtr card_set, uint card_in_region) { G1AddCardResult G1CardSet::add_to_bitmap(CardSetPtr card_set, uint card_in_region) {
G1CardSetBitMap* bitmap = card_set_ptr<G1CardSetBitMap>(card_set); G1CardSetBitMap* bitmap = card_set_ptr<G1CardSetBitMap>(card_set);
uint card_offset = _config->howl_bitmap_offset(card_in_region); uint card_offset = _config->howl_bitmap_offset(card_in_region);
return bitmap->add(card_offset, _config->cards_in_howl_bitmap_threshold(), _config->num_cards_in_howl_bitmap()); return bitmap->add(card_offset, _config->cards_in_howl_bitmap_threshold(), _config->max_cards_in_howl_bitmap());
} }
G1AddCardResult G1CardSet::add_to_inline_ptr(CardSetPtr volatile* card_set_addr, CardSetPtr card_set, uint card_in_region) { G1AddCardResult G1CardSet::add_to_inline_ptr(CardSetPtr volatile* card_set_addr, CardSetPtr card_set, uint card_in_region) {
G1CardSetInlinePtr value(card_set_addr, card_set); G1CardSetInlinePtr value(card_set_addr, card_set);
return value.add(card_in_region, _config->inline_ptr_bits_per_card(), _config->num_cards_in_inline_ptr()); return value.add(card_in_region, _config->inline_ptr_bits_per_card(), _config->max_cards_in_inline_ptr());
} }
G1CardSet::CardSetPtr G1CardSet::create_coarsened_array_of_cards(uint card_in_region, bool within_howl) { G1CardSet::CardSetPtr G1CardSet::create_coarsened_array_of_cards(uint card_in_region, bool within_howl) {
uint8_t* data = nullptr; uint8_t* data = nullptr;
CardSetPtr new_card_set; CardSetPtr new_card_set;
if (within_howl) { if (within_howl) {
uint const size_in_bits = _config->num_cards_in_howl_bitmap(); uint const size_in_bits = _config->max_cards_in_howl_bitmap();
uint card_offset = _config->howl_bitmap_offset(card_in_region); uint card_offset = _config->howl_bitmap_offset(card_in_region);
data = allocate_mem_object(CardSetBitMap); data = allocate_mem_object(CardSetBitMap);
new (data) G1CardSetBitMap(card_offset, size_in_bits); new (data) G1CardSetBitMap(card_offset, size_in_bits);
@ -549,7 +549,7 @@ bool G1CardSet::coarsen_card_set(volatile CardSetPtr* card_set_addr,
break; break;
} }
case CardSetInlinePtr: { case CardSetInlinePtr: {
uint const size = _config->num_cards_in_array(); uint const size = _config->max_cards_in_array();
uint8_t* data = allocate_mem_object(CardSetArrayOfCards); uint8_t* data = allocate_mem_object(CardSetArrayOfCards);
new (data) G1CardSetArray(card_in_region, size); new (data) G1CardSetArray(card_in_region, size);
new_card_set = make_card_set_ptr(data, CardSetArrayOfCards); new_card_set = make_card_set_ptr(data, CardSetArrayOfCards);
@ -626,7 +626,7 @@ void G1CardSet::transfer_cards_in_howl(CardSetPtr parent_card_set,
G1TransferCard iter(this, card_region); G1TransferCard iter(this, card_region);
iterate_cards_during_transfer(source_card_set, iter); iterate_cards_during_transfer(source_card_set, iter);
} else { } else {
uint diff = _config->num_cards_in_howl_bitmap() - card_set_ptr<G1CardSetBitMap>(source_card_set)->num_bits_set(); uint diff = _config->max_cards_in_howl_bitmap() - card_set_ptr<G1CardSetBitMap>(source_card_set)->num_bits_set();
// Need to correct for that the Full remembered set occupies more cards than the // Need to correct for that the Full remembered set occupies more cards than the
// bitmap before. // bitmap before.
@ -755,7 +755,7 @@ bool G1CardSet::contains_card(uint card_region, uint card_in_region) {
return ptr.contains(card_in_region, _config->inline_ptr_bits_per_card()); return ptr.contains(card_in_region, _config->inline_ptr_bits_per_card());
} }
case CardSetArrayOfCards : return card_set_ptr<G1CardSetArray>(card_set)->contains(card_in_region); case CardSetArrayOfCards : return card_set_ptr<G1CardSetArray>(card_set)->contains(card_in_region);
case CardSetBitMap: return card_set_ptr<G1CardSetBitMap>(card_set)->contains(card_in_region, _config->num_cards_in_howl_bitmap()); case CardSetBitMap: return card_set_ptr<G1CardSetBitMap>(card_set)->contains(card_in_region, _config->max_cards_in_howl_bitmap());
case CardSetHowl: { case CardSetHowl: {
G1CardSetHowl* howling_array = card_set_ptr<G1CardSetHowl>(card_set); G1CardSetHowl* howling_array = card_set_ptr<G1CardSetHowl>(card_set);

View File

@ -50,13 +50,13 @@ class G1CardSetConfiguration {
// regions covered by this card set. // regions covered by this card set.
uint _inline_ptr_bits_per_card; uint _inline_ptr_bits_per_card;
uint _num_cards_in_array; uint _max_cards_in_array;
uint _num_buckets_in_howl; uint _num_buckets_in_howl;
uint _max_cards_in_card_set; uint _max_cards_in_card_set;
uint _cards_in_howl_threshold; uint _cards_in_howl_threshold;
uint _num_cards_in_howl_bitmap; uint _max_cards_in_howl_bitmap;
uint _cards_in_howl_bitmap_threshold; uint _cards_in_howl_bitmap_threshold;
uint _log2_num_cards_in_howl_bitmap; uint _log2_max_cards_in_howl_bitmap;
size_t _bitmap_hash_mask; size_t _bitmap_hash_mask;
uint _log2_card_regions_per_heap_region; uint _log2_card_regions_per_heap_region;
uint _log2_cards_per_card_region; uint _log2_cards_per_card_region;
@ -64,7 +64,7 @@ class G1CardSetConfiguration {
G1CardSetAllocOptions* _card_set_alloc_options; G1CardSetAllocOptions* _card_set_alloc_options;
G1CardSetConfiguration(uint inline_ptr_bits_per_card, G1CardSetConfiguration(uint inline_ptr_bits_per_card,
uint num_cards_in_array, uint max_cards_in_array,
double cards_in_bitmap_threshold_percent, double cards_in_bitmap_threshold_percent,
uint num_buckets_in_howl, uint num_buckets_in_howl,
double cards_in_howl_threshold_percent, double cards_in_howl_threshold_percent,
@ -79,7 +79,7 @@ public:
G1CardSetConfiguration(); G1CardSetConfiguration();
// Initialize card set configuration from parameters. // Initialize card set configuration from parameters.
// Testing only. // Testing only.
G1CardSetConfiguration(uint num_cards_in_array, G1CardSetConfiguration(uint max_cards_in_array,
double cards_in_bitmap_threshold_percent, double cards_in_bitmap_threshold_percent,
uint max_buckets_in_howl, uint max_buckets_in_howl,
double cards_in_howl_threshold_percent, double cards_in_howl_threshold_percent,
@ -90,21 +90,19 @@ public:
// Inline pointer configuration // Inline pointer configuration
uint inline_ptr_bits_per_card() const { return _inline_ptr_bits_per_card; } uint inline_ptr_bits_per_card() const { return _inline_ptr_bits_per_card; }
uint num_cards_in_inline_ptr() const; uint max_cards_in_inline_ptr() const;
static uint num_cards_in_inline_ptr(uint bits_per_card); static uint max_cards_in_inline_ptr(uint bits_per_card);
// Array of Cards configuration // Array of Cards configuration
bool use_cards_in_array() const { return _num_cards_in_array != 0; } // Unused for now // Maximum number of cards in "Array of Cards" set; 0 to disable.
// Number of cards in "Array of Cards" set; 0 to disable.
// Always coarsen to next level if full, so no specific threshold. // Always coarsen to next level if full, so no specific threshold.
uint num_cards_in_array() const { return _num_cards_in_array; } uint max_cards_in_array() const { return _max_cards_in_array; }
// Bitmap within Howl card set container configuration // Bitmap within Howl card set container configuration
bool use_cards_in_howl_bitmap() const { return _num_cards_in_howl_bitmap != 0; } // Unused for now uint max_cards_in_howl_bitmap() const { return _max_cards_in_howl_bitmap; }
uint num_cards_in_howl_bitmap() const { return _num_cards_in_howl_bitmap; }
// (Approximate) Number of cards in bitmap to coarsen Howl Bitmap to Howl Full. // (Approximate) Number of cards in bitmap to coarsen Howl Bitmap to Howl Full.
uint cards_in_howl_bitmap_threshold() const { return _cards_in_howl_bitmap_threshold; } uint cards_in_howl_bitmap_threshold() const { return _cards_in_howl_bitmap_threshold; }
uint log2_num_cards_in_howl_bitmap() const {return _log2_num_cards_in_howl_bitmap;} uint log2_max_cards_in_howl_bitmap() const {return _log2_max_cards_in_howl_bitmap;}
// Howl card set container configuration // Howl card set container configuration
uint num_buckets_in_howl() const { return _num_buckets_in_howl; } uint num_buckets_in_howl() const { return _num_buckets_in_howl; }
@ -112,7 +110,7 @@ public:
uint cards_in_howl_threshold() const { return _cards_in_howl_threshold; } uint cards_in_howl_threshold() const { return _cards_in_howl_threshold; }
uint howl_bitmap_offset(uint card_idx) const { return card_idx & _bitmap_hash_mask; } uint howl_bitmap_offset(uint card_idx) const { return card_idx & _bitmap_hash_mask; }
// Given a card index, return the bucket in the array of card sets. // Given a card index, return the bucket in the array of card sets.
uint howl_bucket_index(uint card_idx) { return card_idx >> _log2_num_cards_in_howl_bitmap; } uint howl_bucket_index(uint card_idx) { return card_idx >> _log2_max_cards_in_howl_bitmap; }
// Full card configuration // Full card configuration
// Maximum number of cards in a non-full card set for a single region. Card sets // Maximum number of cards in a non-full card set for a single region. Card sets

View File

@ -252,14 +252,14 @@ inline void G1CardSetBitMap::iterate(CardVisitor& found, size_t size_in_bits, ui
inline G1CardSetHowl::G1CardSetHowl(EntryCountType card_in_region, G1CardSetConfiguration* config) : inline G1CardSetHowl::G1CardSetHowl(EntryCountType card_in_region, G1CardSetConfiguration* config) :
G1CardSetContainer(), G1CardSetContainer(),
_num_entries((config->num_cards_in_array() + 1)) /* Card Transfer will not increment _num_entries */ { _num_entries((config->max_cards_in_array() + 1)) /* Card Transfer will not increment _num_entries */ {
EntryCountType num_buckets = config->num_buckets_in_howl(); EntryCountType num_buckets = config->num_buckets_in_howl();
EntryCountType bucket = config->howl_bucket_index(card_in_region); EntryCountType bucket = config->howl_bucket_index(card_in_region);
for (uint i = 0; i < num_buckets; ++i) { for (uint i = 0; i < num_buckets; ++i) {
_buckets[i] = G1CardSetInlinePtr(); _buckets[i] = G1CardSetInlinePtr();
if (i == bucket) { if (i == bucket) {
G1CardSetInlinePtr value(&_buckets[i], _buckets[i]); G1CardSetInlinePtr value(&_buckets[i], _buckets[i]);
value.add(card_in_region, config->inline_ptr_bits_per_card(), config->num_cards_in_inline_ptr()); value.add(card_in_region, config->inline_ptr_bits_per_card(), config->max_cards_in_inline_ptr());
} }
} }
} }
@ -275,7 +275,7 @@ inline bool G1CardSetHowl::contains(uint card_idx, G1CardSetConfiguration* confi
} }
case G1CardSet::CardSetBitMap: { case G1CardSet::CardSetBitMap: {
uint card_offset = config->howl_bitmap_offset(card_idx); uint card_offset = config->howl_bitmap_offset(card_idx);
return G1CardSet::card_set_ptr<G1CardSetBitMap>(card_set)->contains(card_offset, config->num_cards_in_howl_bitmap()); return G1CardSet::card_set_ptr<G1CardSetBitMap>(card_set)->contains(card_offset, config->max_cards_in_howl_bitmap());
} }
case G1CardSet::CardSetInlinePtr: { case G1CardSet::CardSetInlinePtr: {
G1CardSetInlinePtr ptr(card_set); G1CardSetInlinePtr ptr(card_set);
@ -321,28 +321,28 @@ inline void G1CardSetHowl::iterate_cardset(CardSetPtr const card_set, uint index
} }
case G1CardSet::CardSetBitMap: { case G1CardSet::CardSetBitMap: {
if (found.start_iterate(G1GCPhaseTimes::MergeRSHowlBitmap)) { if (found.start_iterate(G1GCPhaseTimes::MergeRSHowlBitmap)) {
uint offset = index << config->log2_num_cards_in_howl_bitmap(); uint offset = index << config->log2_max_cards_in_howl_bitmap();
G1CardSet::card_set_ptr<G1CardSetBitMap>(card_set)->iterate(found, config->num_cards_in_howl_bitmap(), offset); G1CardSet::card_set_ptr<G1CardSetBitMap>(card_set)->iterate(found, config->max_cards_in_howl_bitmap(), offset);
} }
return; return;
} }
case G1CardSet::CardSetHowl: { // actually FullCardSet case G1CardSet::CardSetHowl: { // actually FullCardSet
assert(card_set == G1CardSet::FullCardSet, "Must be"); assert(card_set == G1CardSet::FullCardSet, "Must be");
if (found.start_iterate(G1GCPhaseTimes::MergeRSHowlFull)) { if (found.start_iterate(G1GCPhaseTimes::MergeRSHowlFull)) {
uint offset = index << config->log2_num_cards_in_howl_bitmap(); uint offset = index << config->log2_max_cards_in_howl_bitmap();
found(offset, config->num_cards_in_howl_bitmap()); found(offset, config->max_cards_in_howl_bitmap());
} }
return; return;
} }
} }
} }
inline G1CardSetHowl::EntryCountType G1CardSetHowl::num_buckets(size_t size_in_bits, size_t num_cards_in_array, size_t max_num_buckets) { inline G1CardSetHowl::EntryCountType G1CardSetHowl::num_buckets(size_t size_in_bits, size_t max_cards_in_array, size_t max_num_buckets) {
size_t size_bitmap_bytes = BitMap::calc_size_in_words(size_in_bits) * BytesPerWord; size_t size_bitmap_bytes = BitMap::calc_size_in_words(size_in_bits) * BytesPerWord;
// Ensure that in the worst case arrays consume half the memory size // Ensure that in the worst case arrays consume half the memory size
// of storing the entire bitmap // of storing the entire bitmap
size_t max_size_arrays_bytes = size_bitmap_bytes / 2; size_t max_size_arrays_bytes = size_bitmap_bytes / 2;
size_t size_array_bytes = num_cards_in_array * sizeof(G1CardSetArray::EntryDataType); size_t size_array_bytes = max_cards_in_array * sizeof(G1CardSetArray::EntryDataType);
size_t num_arrays = max_size_arrays_bytes / size_array_bytes; size_t num_arrays = max_size_arrays_bytes / size_array_bytes;
// We use shifts and masks for indexing the array. So round down to the next // We use shifts and masks for indexing the array. So round down to the next
// power of two to not use more than expected memory. // power of two to not use more than expected memory.

View File

@ -345,17 +345,17 @@ void G1CardSetTest::cardset_basic_test() {
ASSERT_TRUE(count == card_set.occupied()); ASSERT_TRUE(count == card_set.occupied());
} }
G1AddCardResult res = card_set.add_card(99, config.num_cards_in_howl_bitmap() - 1); G1AddCardResult res = card_set.add_card(99, config.max_cards_in_howl_bitmap() - 1);
// Adding above card should have coarsened Bitmap -> Full. // Adding above card should have coarsened Bitmap -> Full.
ASSERT_TRUE(res == Added); ASSERT_TRUE(res == Added);
ASSERT_TRUE(config.num_cards_in_howl_bitmap() == card_set.occupied()); ASSERT_TRUE(config.max_cards_in_howl_bitmap() == card_set.occupied());
res = card_set.add_card(99, config.num_cards_in_howl_bitmap() - 2); res = card_set.add_card(99, config.max_cards_in_howl_bitmap() - 2);
ASSERT_TRUE(res == Found); ASSERT_TRUE(res == Found);
uint threshold = config.cards_in_howl_threshold(); uint threshold = config.cards_in_howl_threshold();
uint adjusted_threshold = config.cards_in_howl_bitmap_threshold() * config.num_buckets_in_howl(); uint adjusted_threshold = config.cards_in_howl_bitmap_threshold() * config.num_buckets_in_howl();
i = config.num_cards_in_howl_bitmap(); i = config.max_cards_in_howl_bitmap();
count = i; count = i;
for (; i < threshold; i++) { for (; i < threshold; i++) {
G1AddCardResult res = card_set.add_card(99, i); G1AddCardResult res = card_set.add_card(99, i);