Skip to content

Commit ab41812

Browse files
committed
8272576: G1: Use more accurate integer type for collection set length
Reviewed-by: iwalulya, sjohanss
1 parent 82b2f21 commit ab41812

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/hotspot/share/gc/g1/g1CollectionSet.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void G1CollectionSet::init_region_lengths(uint eden_cset_region_length,
8989
_survivor_region_length = survivor_cset_region_length;
9090

9191
assert((size_t) young_region_length() == _collection_set_cur_length,
92-
"Young region length %u should match collection set length " SIZE_FORMAT, young_region_length(), _collection_set_cur_length);
92+
"Young region length %u should match collection set length %u", young_region_length(), _collection_set_cur_length);
9393

9494
_old_region_length = 0;
9595
free_optional_regions();
@@ -130,8 +130,8 @@ void G1CollectionSet::add_old_region(HeapRegion* hr) {
130130
assert(!hr->in_collection_set(), "should not already be in the collection set");
131131
_g1h->register_old_region_with_region_attr(hr);
132132

133+
assert(_collection_set_cur_length < _collection_set_max_length, "Collection set now larger than maximum size.");
133134
_collection_set_regions[_collection_set_cur_length++] = hr->hrm_index();
134-
assert(_collection_set_cur_length <= _collection_set_max_length, "Collection set now larger than maximum size.");
135135

136136
_bytes_used_before += hr->used();
137137
_recorded_rs_length += hr->rem_set()->occupied();
@@ -153,7 +153,7 @@ void G1CollectionSet::start_incremental_building() {
153153
assert(_collection_set_cur_length == 0, "Collection set must be empty before starting a new collection set.");
154154
assert(_inc_build_state == Inactive, "Precondition");
155155
#ifdef ASSERT
156-
for (size_t i = 0; i < _collection_set_max_length; i++) {
156+
for (uint i = 0; i < _collection_set_max_length; i++) {
157157
_inc_collection_set_stats[i].reset();
158158
}
159159
#endif
@@ -326,15 +326,15 @@ void G1CollectionSet::add_young_region_common(HeapRegion* hr) {
326326

327327
// We use UINT_MAX as "invalid" marker in verification.
328328
assert(_collection_set_cur_length < (UINT_MAX - 1),
329-
"Collection set is too large with " SIZE_FORMAT " entries", _collection_set_cur_length);
330-
hr->set_young_index_in_cset((uint)_collection_set_cur_length + 1);
329+
"Collection set is too large with %u entries", _collection_set_cur_length);
330+
hr->set_young_index_in_cset(_collection_set_cur_length + 1);
331331

332+
assert(_collection_set_cur_length < _collection_set_max_length, "Collection set larger than maximum allowed.");
332333
_collection_set_regions[_collection_set_cur_length] = hr->hrm_index();
333334
// Concurrent readers must observe the store of the value in the array before an
334335
// update to the length field.
335336
OrderAccess::storestore();
336337
_collection_set_cur_length++;
337-
assert(_collection_set_cur_length <= _collection_set_max_length, "Collection set larger than maximum allowed.");
338338
}
339339

340340
void G1CollectionSet::add_survivor_regions(HeapRegion* hr) {

src/hotspot/share/gc/g1/g1CollectionSet.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ class G1CollectionSet {
147147
// concurrent readers. This means we are good with using storestore and loadload
148148
// barriers on the writer and reader respectively only.
149149
uint* _collection_set_regions;
150-
volatile size_t _collection_set_cur_length;
151-
size_t _collection_set_max_length;
150+
volatile uint _collection_set_cur_length;
151+
uint _collection_set_max_length;
152152

153153
// When doing mixed collections we can add old regions to the collection set, which
154154
// will be collected only if there is enough time. We call these optional regions.

0 commit comments

Comments
 (0)