Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get rid of saved_allocated #77197

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 7 additions & 28 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11780,7 +11780,6 @@ void gc_heap::init_heap_segment (heap_segment* seg, gc_heap* hp
heap_segment_next (seg) = 0;
heap_segment_plan_allocated (seg) = heap_segment_mem (seg);
heap_segment_allocated (seg) = heap_segment_mem (seg);
heap_segment_saved_allocated (seg) = heap_segment_mem (seg);
heap_segment_decommit_target (seg) = heap_segment_reserved (seg);
#ifdef BACKGROUND_GC
heap_segment_background_allocated (seg) = 0;
Expand Down Expand Up @@ -29076,16 +29075,6 @@ 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_HEAPS
if (!heap_segment_saved_allocated(seg))
#endif // !MULTIPLE_HEAPS
{
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 @@ -29163,7 +29152,6 @@ 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 @@ -29211,7 +29199,6 @@ 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
save_allocated(seg);
heap_segment_allocated (seg) = shigh + Align (size (shigh));
}
// test if the segment is in the range of [slow, shigh]
Expand All @@ -29230,7 +29217,6 @@ void gc_heap::plan_phase (int condemned_gen_number)
#endif //USE_REGIONS
}
#endif //BACKGROUND_GC
save_allocated(seg);
// shorten it to minimum
heap_segment_allocated (seg) = heap_segment_mem (seg);
}
Expand All @@ -29246,7 +29232,6 @@ void gc_heap::plan_phase (int condemned_gen_number)
heap_segment* sseg = seg;
do
{
heap_segment_saved_allocated(seg) = 0;
uint8_t* start_unmarked = heap_segment_mem (seg);
#ifndef USE_REGIONS
// shorten it to minimum
Expand All @@ -29265,7 +29250,6 @@ void gc_heap::plan_phase (int condemned_gen_number)
bgc_clear_batch_mark_array_bits (start_unmarked, heap_segment_allocated (seg));
}
#endif //BACKGROUND_GC
save_allocated(seg);
heap_segment_allocated (seg) = start_unmarked;

seg = heap_segment_next_rw (seg);
Expand Down Expand Up @@ -29548,7 +29532,6 @@ void gc_heap::plan_phase (int condemned_gen_number)
#endif //USE_REGIONS
{
assert (heap_segment_allocated (seg1) == end);
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 @@ -31927,7 +31910,6 @@ void gc_heap::sweep_region_in_plan (heap_segment* region,
#endif //_DEBUG

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

Expand Down Expand Up @@ -41159,14 +41141,13 @@ size_t gc_heap::generation_fragmentation (generation* gen,
heap_segment* seg = heap_segment_rw (generation_start_segment (gen));
while (seg)
{
frag += (heap_segment_saved_allocated (seg) -
heap_segment_plan_allocated (seg));
frag += (heap_segment_allocated (seg) - heap_segment_plan_allocated (seg));

dprintf (3, ("h%d g%d adding seg plan frag: %Ix-%Ix=%Id -> %Id",
heap_number, gen_num,
heap_segment_saved_allocated (seg),
heap_segment_allocated (seg),
heap_segment_plan_allocated (seg),
(heap_segment_saved_allocated (seg) - heap_segment_plan_allocated (seg)),
(heap_segment_allocated (seg) - heap_segment_plan_allocated (seg)),
frag));

seg = heap_segment_next_rw (seg);
Expand Down Expand Up @@ -41225,7 +41206,7 @@ size_t gc_heap::generation_fragmentation (generation* gen,
// for SOH this returns the total sizes of the generation and its
// younger generation(s).
// for LOH this returns just LOH size.
size_t gc_heap::generation_sizes (generation* gen, bool use_saved_p)
size_t gc_heap::generation_sizes (generation* gen)
{
size_t result = 0;

Expand All @@ -41237,8 +41218,7 @@ size_t gc_heap::generation_sizes (generation* gen, bool use_saved_p)
heap_segment* seg = heap_segment_in_range (generation_start_segment (generation_of (i)));
while (seg)
{
uint8_t* end = (use_saved_p ?
heap_segment_saved_allocated (seg) : heap_segment_allocated (seg));
uint8_t* end = heap_segment_allocated (seg);
result += end - heap_segment_mem (seg);
dprintf (3, ("h%d gen%d size + %Id (%Ix - %Ix) -> %Id",
heap_number, i, (end - heap_segment_mem (seg)),
Expand Down Expand Up @@ -41375,7 +41355,7 @@ BOOL gc_heap::decide_on_compacting (int condemned_gen_number,
should_expand = FALSE;
generation* gen = generation_of (condemned_gen_number);
dynamic_data* dd = dynamic_data_of (condemned_gen_number);
size_t gen_sizes = generation_sizes(gen, true);
size_t gen_sizes = generation_sizes (gen);
float fragmentation_burden = ( ((0 == fragmentation) || (0 == gen_sizes)) ? (0.0f) :
(float (fragmentation) / gen_sizes) );

Expand Down Expand Up @@ -43763,13 +43743,12 @@ void gc_heap::descr_generations (const char* msg)
heap_segment_mem (generation_tail_region (gen))));
while (seg)
{
dprintf (GTC_LOG, ("g%d: (%d:p %d) [%Ix %Ix(sa: %Ix, pa: %Ix)[-%Ix[ (%Id) (%Id)",
dprintf (GTC_LOG, ("g%d: (%d:p %d) [%Ix %Ix(pa: %Ix)[-%Ix[ (%Id) (%Id)",
curr_gen_number,
heap_segment_gen_num (seg),
heap_segment_plan_gen_num (seg),
(size_t)heap_segment_mem (seg),
(size_t)heap_segment_allocated (seg),
(size_t)heap_segment_saved_allocated (seg),
(size_t)heap_segment_plan_allocated (seg),
(size_t)heap_segment_committed (seg),
(size_t)(heap_segment_allocated (seg) - heap_segment_mem (seg)),
Expand Down
12 changes: 1 addition & 11 deletions src/coreclr/gc/gcpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -3366,7 +3366,7 @@ class gc_heap
generation* consing_gen,
uint8_t* end);
PER_HEAP
size_t generation_sizes (generation* gen, bool use_saved_p=FALSE);
size_t generation_sizes (generation* gen);
PER_HEAP
size_t committed_size();
PER_HEAP
Expand Down Expand Up @@ -5734,11 +5734,6 @@ class heap_segment
#endif //MULTIPLE_HEAPS
uint8_t* decommit_target;
uint8_t* plan_allocated;
// In the plan phase we change the allocated for a seg but we need this
// value to correctly calculate how much space we can reclaim in
// generation_fragmentation. But it's beneficial to truncate it as it
// means in the later phases we only need to look up to the new allocated.
uint8_t* saved_allocated;
uint8_t* saved_bg_allocated;
#ifdef USE_REGIONS
// These generation numbers are initialized to -1.
Expand Down Expand Up @@ -6146,11 +6141,6 @@ uint8_t*& heap_segment_plan_allocated (heap_segment* inst)
{
return inst->plan_allocated;
}
inline
uint8_t*& heap_segment_saved_allocated (heap_segment* inst)
{
return inst->saved_allocated;
}
#ifdef BACKGROUND_GC
inline
uint8_t*& heap_segment_background_allocated (heap_segment* inst)
Expand Down