8272576: G1: Use more accurate integer type for collection set length

Reviewed-by: iwalulya, sjohanss
This commit is contained in:
Albert Mingkun Yang 2021-08-19 09:56:32 +00:00
parent 82b2f21d17
commit ab41812951
2 changed files with 8 additions and 8 deletions

View File

@ -89,7 +89,7 @@ void G1CollectionSet::init_region_lengths(uint eden_cset_region_length,
_survivor_region_length = survivor_cset_region_length;
assert((size_t) young_region_length() == _collection_set_cur_length,
"Young region length %u should match collection set length " SIZE_FORMAT, young_region_length(), _collection_set_cur_length);
"Young region length %u should match collection set length %u", young_region_length(), _collection_set_cur_length);
_old_region_length = 0;
free_optional_regions();
@ -130,8 +130,8 @@ void G1CollectionSet::add_old_region(HeapRegion* hr) {
assert(!hr->in_collection_set(), "should not already be in the collection set");
_g1h->register_old_region_with_region_attr(hr);
assert(_collection_set_cur_length < _collection_set_max_length, "Collection set now larger than maximum size.");
_collection_set_regions[_collection_set_cur_length++] = hr->hrm_index();
assert(_collection_set_cur_length <= _collection_set_max_length, "Collection set now larger than maximum size.");
_bytes_used_before += hr->used();
_recorded_rs_length += hr->rem_set()->occupied();
@ -153,7 +153,7 @@ void G1CollectionSet::start_incremental_building() {
assert(_collection_set_cur_length == 0, "Collection set must be empty before starting a new collection set.");
assert(_inc_build_state == Inactive, "Precondition");
#ifdef ASSERT
for (size_t i = 0; i < _collection_set_max_length; i++) {
for (uint i = 0; i < _collection_set_max_length; i++) {
_inc_collection_set_stats[i].reset();
}
#endif
@ -326,15 +326,15 @@ void G1CollectionSet::add_young_region_common(HeapRegion* hr) {
// We use UINT_MAX as "invalid" marker in verification.
assert(_collection_set_cur_length < (UINT_MAX - 1),
"Collection set is too large with " SIZE_FORMAT " entries", _collection_set_cur_length);
hr->set_young_index_in_cset((uint)_collection_set_cur_length + 1);
"Collection set is too large with %u entries", _collection_set_cur_length);
hr->set_young_index_in_cset(_collection_set_cur_length + 1);
assert(_collection_set_cur_length < _collection_set_max_length, "Collection set larger than maximum allowed.");
_collection_set_regions[_collection_set_cur_length] = hr->hrm_index();
// Concurrent readers must observe the store of the value in the array before an
// update to the length field.
OrderAccess::storestore();
_collection_set_cur_length++;
assert(_collection_set_cur_length <= _collection_set_max_length, "Collection set larger than maximum allowed.");
}
void G1CollectionSet::add_survivor_regions(HeapRegion* hr) {

View File

@ -147,8 +147,8 @@ class G1CollectionSet {
// concurrent readers. This means we are good with using storestore and loadload
// barriers on the writer and reader respectively only.
uint* _collection_set_regions;
volatile size_t _collection_set_cur_length;
size_t _collection_set_max_length;
volatile uint _collection_set_cur_length;
uint _collection_set_max_length;
// When doing mixed collections we can add old regions to the collection set, which
// will be collected only if there is enough time. We call these optional regions.