Skip to content

Commit 23c22ce

Browse files
authored
Report SIP survivors (#67940)
1 parent c2dbee1 commit 23c22ce

File tree

2 files changed

+45
-11
lines changed

2 files changed

+45
-11
lines changed

src/coreclr/gc/gc.cpp

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32150,11 +32150,7 @@ void gc_heap::walk_relocation (void* profiling_context, record_surv_fn fn)
3215032150
generation* condemned_gen = generation_of (i);
3215132151
heap_segment* current_heap_segment = heap_segment_rw (generation_start_segment (condemned_gen));
3215232152
#ifdef USE_REGIONS
32153-
while (current_heap_segment && heap_segment_swept_in_plan (current_heap_segment))
32154-
{
32155-
// TODO: Walk the heap segment and report the plugs.
32156-
current_heap_segment = heap_segment_next_rw (current_heap_segment);
32157-
}
32153+
current_heap_segment = walk_relocation_sip (current_heap_segment, profiling_context, fn);
3215832154
if (!current_heap_segment)
3215932155
continue;
3216032156
#endif // USE_REGIONS
@@ -32187,11 +32183,7 @@ void gc_heap::walk_relocation (void* profiling_context, record_surv_fn fn)
3218732183
}
3218832184
current_heap_segment = heap_segment_next_rw (current_heap_segment);
3218932185
#ifdef USE_REGIONS
32190-
while (current_heap_segment && heap_segment_swept_in_plan (current_heap_segment))
32191-
{
32192-
// TODO: Walk the heap segment and report the plugs.
32193-
current_heap_segment = heap_segment_next_rw (current_heap_segment);
32194-
}
32186+
current_heap_segment = walk_relocation_sip (current_heap_segment, profiling_context, fn);
3219532187
#endif // USE_REGIONS
3219632188
if (current_heap_segment)
3219732189
{
@@ -32218,6 +32210,45 @@ void gc_heap::walk_relocation (void* profiling_context, record_surv_fn fn)
3221832210
}
3221932211
}
3222032212

32213+
#ifdef USE_REGIONS
32214+
heap_segment* gc_heap::walk_relocation_sip (heap_segment* current_heap_segment, void* profiling_context, record_surv_fn fn)
32215+
{
32216+
while (current_heap_segment && heap_segment_swept_in_plan (current_heap_segment))
32217+
{
32218+
uint8_t* start = heap_segment_mem (current_heap_segment);
32219+
uint8_t* end = heap_segment_allocated (current_heap_segment);
32220+
uint8_t* obj = start;
32221+
uint8_t* plug_start = nullptr;
32222+
while (obj < end)
32223+
{
32224+
if (((CObjectHeader*)obj)->IsFree())
32225+
{
32226+
if (plug_start)
32227+
{
32228+
fn (plug_start, obj, 0, profiling_context, false, false);
32229+
plug_start = nullptr;
32230+
}
32231+
}
32232+
else
32233+
{
32234+
if (!plug_start)
32235+
{
32236+
plug_start = obj;
32237+
}
32238+
}
32239+
32240+
obj += Align (size (obj));
32241+
}
32242+
if (plug_start)
32243+
{
32244+
fn (plug_start, end, 0, profiling_context, false, false);
32245+
}
32246+
current_heap_segment = heap_segment_next_rw (current_heap_segment);
32247+
}
32248+
return current_heap_segment;
32249+
}
32250+
#endif // USE_REGIONS
32251+
3222132252
void gc_heap::walk_survivors (record_surv_fn fn, void* context, walk_surv_type type)
3222232253
{
3222332254
if (type == walk_for_gc)

src/coreclr/gc/gcpriv.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1647,7 +1647,10 @@ class gc_heap
16471647

16481648
PER_HEAP
16491649
void walk_relocation (void* profiling_context, record_surv_fn fn);
1650-
1650+
#ifdef USE_REGIONS
1651+
PER_HEAP
1652+
heap_segment* walk_relocation_sip (heap_segment* current_heap_segment, void* profiling_context, record_surv_fn fn);
1653+
#endif // USE_REGIONS
16511654
PER_HEAP
16521655
void walk_relocation_in_brick (uint8_t* tree, walk_relocate_args* args);
16531656

0 commit comments

Comments
 (0)