Skip to content

Commit bf46acf

Browse files
author
Thomas Schatzl
committed
8254028: G1 incorrectly updates scan_top for collection set regions during preparation of evacuation
Reviewed-by: kbarrett
1 parent a2bb4c6 commit bf46acf

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -906,14 +906,27 @@ void G1RemSet::scan_collection_set_regions(G1ParScanThreadState* pss,
906906
}
907907
}
908908

909-
void G1RemSet::prepare_region_for_scan(HeapRegion* region) {
910-
uint hrm_index = region->hrm_index();
909+
#ifdef ASSERT
910+
void G1RemSet::assert_scan_top_is_null(uint hrm_index) {
911+
assert(_scan_state->scan_top(hrm_index) == NULL,
912+
"scan_top of region %u is unexpectedly " PTR_FORMAT,
913+
hrm_index, p2i(_scan_state->scan_top(hrm_index)));
914+
}
915+
#endif
916+
917+
void G1RemSet::prepare_region_for_scan(HeapRegion* r) {
918+
uint hrm_index = r->hrm_index();
911919

912-
if (region->is_old_or_humongous_or_archive()) {
913-
_scan_state->set_scan_top(hrm_index, region->top());
920+
// Only update non-collection set old regions, others must have already been set
921+
// to NULL (don't scan) in the initialization.
922+
if (r->in_collection_set()) {
923+
assert_scan_top_is_null(hrm_index);
924+
} else if (r->is_old_or_humongous_or_archive()) {
925+
_scan_state->set_scan_top(hrm_index, r->top());
914926
} else {
915-
assert(region->in_collection_set() || region->is_free(),
916-
"Should only be free or in the collection set at this point %s", region->get_type_str());
927+
assert_scan_top_is_null(hrm_index);
928+
assert(r->is_free(),
929+
"Region %u should be free region but is %s", hrm_index, r->get_type_str());
917930
}
918931
}
919932

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class G1RemSet: public CHeapObj<mtGC> {
6767
G1HotCardCache* _hot_card_cache;
6868

6969
void print_merge_heap_roots_stats();
70+
71+
void assert_scan_top_is_null(uint hrm_index) PRODUCT_RETURN;
7072
public:
7173

7274
typedef CardTable::CardValue CardValue;

0 commit comments

Comments
 (0)