From 0654f3d8a093b1575d202c9d100f34306e679fbe Mon Sep 17 00:00:00 2001 From: Maoni0 Date: Sat, 12 Aug 2023 00:17:21 -0700 Subject: [PATCH 1/2] gen0_bricks_cleared flag needs to be propagated --- src/coreclr/gc/gc.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index 02a9b8f26c2f56..a539379cc485dd 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -25490,8 +25490,9 @@ bool gc_heap::change_heap_count (int new_n_heaps) from_heap_number = (from_heap_number + 1) % old_n_heaps; } - // prepare for the switch by fixing the allocation contexts on the old heaps, + // prepare for the switch by fixing the allocation contexts on the old heaps, unify the gen0_bricks_cleared flag, // and setting the survived size for the existing regions to their allocated size + BOOL unified_gen0_bricks_cleared = true; for (int i = 0; i < old_n_heaps; i++) { gc_heap* hp = g_heaps[i]; @@ -25501,6 +25502,11 @@ bool gc_heap::change_heap_count (int new_n_heaps) hp->fix_allocation_contexts (TRUE); } + if (unified_gen0_bricks_cleared && (hp->gen0_bricks_cleared == FALSE)) + { + unified_gen0_bricks_cleared = FALSE; + } + for (int gen_idx = 0; gen_idx < total_generation_count; gen_idx++) { generation* gen = hp->generation_of (gen_idx); @@ -25611,6 +25617,8 @@ bool gc_heap::change_heap_count (int new_n_heaps) { gc_heap* hp = g_heaps[i]; + hp->gen0_bricks_cleared = unified_gen0_bricks_cleared; + // establish invariants regarding the ephemeral segment generation* gen0 = hp->generation_of (0); if ((hp->ephemeral_heap_segment == nullptr) || From 59e3e421a8fc8f1ab3a3e8488c9bcfb3e3c3b722 Mon Sep 17 00:00:00 2001 From: Maoni0 Date: Mon, 14 Aug 2023 20:41:24 -0700 Subject: [PATCH 2/2] small fix --- src/coreclr/gc/gc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index a539379cc485dd..aa103472122180 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -25492,7 +25492,7 @@ bool gc_heap::change_heap_count (int new_n_heaps) // prepare for the switch by fixing the allocation contexts on the old heaps, unify the gen0_bricks_cleared flag, // and setting the survived size for the existing regions to their allocated size - BOOL unified_gen0_bricks_cleared = true; + BOOL unified_gen0_bricks_cleared = TRUE; for (int i = 0; i < old_n_heaps; i++) { gc_heap* hp = g_heaps[i];