Skip to content

Commit 1b0eb4d

Browse files
authored
Disable mark list optimization if we hit a per region mark list overflow (#86508)
1 parent 848a09b commit 1b0eb4d

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/coreclr/gc/gc.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10596,7 +10596,7 @@ static int __cdecl cmp_mark_list_item (const void* vkey, const void* vdatum)
1059610596
#endif // _DEBUG
1059710597

1059810598
#ifdef USE_REGIONS
10599-
uint8_t** gc_heap::get_region_mark_list (uint8_t* start, uint8_t* end, uint8_t*** mark_list_end_ptr)
10599+
uint8_t** gc_heap::get_region_mark_list (BOOL& use_mark_list, uint8_t* start, uint8_t* end, uint8_t*** mark_list_end_ptr)
1060010600
{
1060110601
size_t region_number = get_basic_region_index_for_address (start);
1060210602
size_t source_number = region_number;
@@ -10726,6 +10726,13 @@ void gc_heap::merge_mark_lists (size_t total_mark_list_size)
1072610726

1072710727
// blast this piece to the mark list
1072810728
append_to_mark_list(source[lowest_source], x);
10729+
#ifdef USE_REGIONS
10730+
if (mark_list_index > mark_list_end)
10731+
{
10732+
use_mark_list = false;
10733+
return nullptr;
10734+
}
10735+
#endif //USE_REGIONS
1072910736
piece_count++;
1073010737

1073110738
source[lowest_source] = x;
@@ -10745,6 +10752,13 @@ void gc_heap::merge_mark_lists (size_t total_mark_list_size)
1074510752
}
1074610753
// we're left with just one source that we copy
1074710754
append_to_mark_list(source[0], source_end[0]);
10755+
#ifdef USE_REGIONS
10756+
if (mark_list_index > mark_list_end)
10757+
{
10758+
use_mark_list = false;
10759+
return nullptr;
10760+
}
10761+
#endif //USE_REGIONS
1074810762
piece_count++;
1074910763
}
1075010764

@@ -10801,7 +10815,7 @@ static uint8_t** binary_search (uint8_t** left, uint8_t** right, uint8_t* e)
1080110815
return a + l;
1080210816
}
1080310817

10804-
uint8_t** gc_heap::get_region_mark_list (uint8_t* start, uint8_t* end, uint8_t*** mark_list_end_ptr)
10818+
uint8_t** gc_heap::get_region_mark_list (BOOL& use_mark_list, uint8_t* start, uint8_t* end, uint8_t*** mark_list_end_ptr)
1080510819
{
1080610820
// do a binary search over the sorted marked list to find start and end of the
1080710821
// mark list for this region
@@ -31610,7 +31624,7 @@ void gc_heap::plan_phase (int condemned_gen_number)
3161031624
uint8_t** mark_list_index = nullptr;
3161131625
uint8_t** mark_list_next = nullptr;
3161231626
if (use_mark_list)
31613-
mark_list_next = get_region_mark_list (x, end, &mark_list_index);
31627+
mark_list_next = get_region_mark_list (use_mark_list, x, end, &mark_list_index);
3161431628
#else // USE_REGIONS
3161531629
assert (!marked (x));
3161631630
uint8_t** mark_list_next = &mark_list[0];
@@ -31898,7 +31912,7 @@ void gc_heap::plan_phase (int condemned_gen_number)
3189831912
current_brick = brick_of (x);
3189931913
#ifdef USE_REGIONS
3190031914
if (use_mark_list)
31901-
mark_list_next = get_region_mark_list (x, end, &mark_list_index);
31915+
mark_list_next = get_region_mark_list (use_mark_list, x, end, &mark_list_index);
3190231916

3190331917
if (should_sweep_in_plan (seg1))
3190431918
{
@@ -31968,7 +31982,7 @@ void gc_heap::plan_phase (int condemned_gen_number)
3196831982
current_brick = brick_of (x);
3196931983

3197031984
if (use_mark_list)
31971-
mark_list_next = get_region_mark_list (x, end, &mark_list_index);
31985+
mark_list_next = get_region_mark_list (use_mark_list, x, end, &mark_list_index);
3197231986

3197331987
if (should_sweep_in_plan (seg1))
3197431988
{

src/coreclr/gc/gcpriv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3160,7 +3160,7 @@ class gc_heap
31603160
PER_HEAP_ISOLATED_METHOD void grow_mark_list();
31613161

31623162
#ifdef USE_REGIONS
3163-
PER_HEAP_METHOD uint8_t** get_region_mark_list (uint8_t* start, uint8_t* end, uint8_t*** mark_list_end);
3163+
PER_HEAP_METHOD uint8_t** get_region_mark_list (BOOL& use_mark_list, uint8_t* start, uint8_t* end, uint8_t*** mark_list_end);
31643164
#endif //USE_REGIONS
31653165

31663166
#ifdef BACKGROUND_GC

0 commit comments

Comments
 (0)