Skip to content

Commit

Permalink
Fixed a WKS specific issue by not clobbering the heap_segment_saved_a…
Browse files Browse the repository at this point in the history
…llocated (#72923)

* Fixed the WKS issue by not clobbering the heap_segment_saved_allocated

* Addressed feedback:
  • Loading branch information
mrsharm authored Aug 1, 2022
1 parent 265d89b commit f974d59
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28243,6 +28243,16 @@ void gc_heap::add_plug_in_condemned_info (generation* gen, size_t plug_size)
}
#endif //FEATURE_EVENT_TRACE

inline void save_allocated(heap_segment* seg)
{
#ifndef MULTIPLE_HEAP
if (!heap_segment_saved_allocated(seg))
#endif // !MULTIPLE_HEAP
{
heap_segment_saved_allocated (seg) = heap_segment_allocated (seg);
}
}

#ifdef _PREFAST_
#pragma warning(push)
#pragma warning(disable:21000) // Suppress PREFast warning about overly large function
Expand Down Expand Up @@ -28328,6 +28338,7 @@ void gc_heap::plan_phase (int condemned_gen_number)
heap_segment* fseg = seg;
do
{
heap_segment_saved_allocated(seg) = 0;
if (in_range_for_segment (slow, seg))
{
uint8_t* start_unmarked = 0;
Expand Down Expand Up @@ -28375,7 +28386,7 @@ void gc_heap::plan_phase (int condemned_gen_number)
bgc_clear_batch_mark_array_bits ((shigh + Align (size (shigh))), heap_segment_allocated (seg));
}
#endif //BACKGROUND_GC
heap_segment_saved_allocated (seg) = heap_segment_allocated (seg);
save_allocated(seg);
heap_segment_allocated (seg) = shigh + Align (size (shigh));
}
// test if the segment is in the range of [slow, shigh]
Expand All @@ -28394,7 +28405,7 @@ void gc_heap::plan_phase (int condemned_gen_number)
#endif //USE_REGIONS
}
#endif //BACKGROUND_GC
heap_segment_saved_allocated (seg) = heap_segment_allocated (seg);
save_allocated(seg);
// shorten it to minimum
heap_segment_allocated (seg) = heap_segment_mem (seg);
}
Expand Down Expand Up @@ -28428,7 +28439,7 @@ void gc_heap::plan_phase (int condemned_gen_number)
bgc_clear_batch_mark_array_bits (start_unmarked, heap_segment_allocated (seg));
}
#endif //BACKGROUND_GC
heap_segment_saved_allocated (seg) = heap_segment_allocated (seg);
save_allocated(seg);
heap_segment_allocated (seg) = start_unmarked;

seg = heap_segment_next_rw (seg);
Expand Down Expand Up @@ -28711,7 +28722,7 @@ void gc_heap::plan_phase (int condemned_gen_number)
#endif //USE_REGIONS
{
assert (heap_segment_allocated (seg1) == end);
heap_segment_saved_allocated (seg1) = heap_segment_allocated (seg1);
save_allocated(seg1);
heap_segment_allocated (seg1) = plug_end;
current_brick = update_brick_table (tree, current_brick, x, plug_end);
dprintf (REGIONS_LOG, ("region %Ix-%Ix(%Ix) non SIP",
Expand Down Expand Up @@ -31042,7 +31053,7 @@ void gc_heap::sweep_region_in_plan (heap_segment* region,
#endif //_DEBUG

assert (last_marked_obj_end);
heap_segment_saved_allocated (region) = heap_segment_allocated (region);
save_allocated(region);
heap_segment_allocated (region) = last_marked_obj_end;
heap_segment_plan_allocated (region) = heap_segment_allocated (region);

Expand Down

0 comments on commit f974d59

Please sign in to comment.