Skip to content
Merged
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
24 changes: 20 additions & 4 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20912,6 +20912,7 @@ void gc_heap::gc1()
for (int gen = 0; gen <= limit; gen++)
{
size_t total_desired = 0;
size_t total_already_consumed = 0;

for (int i = 0; i < gc_heap::n_heaps; i++)
{
Expand All @@ -20925,11 +20926,22 @@ void gc_heap::gc1()
break;
}
total_desired = temp_total_desired;
// for gen 1 and gen 2, there may have been some incoming size
// already accounted for
assert ((ptrdiff_t)dd_desired_allocation (dd) >= dd_new_allocation (dd));
size_t already_consumed = dd_desired_allocation (dd) - dd_new_allocation (dd);
size_t temp_total_already_consumed = total_already_consumed + already_consumed;

// we should never have an overflow here as the consumed size should always fit in a size_t
assert (temp_total_already_consumed >= total_already_consumed);
total_already_consumed = temp_total_already_consumed;
}

size_t desired_per_heap = Align (total_desired/gc_heap::n_heaps,
get_alignment_constant (gen <= max_generation));

size_t already_consumed_per_heap = total_already_consumed / gc_heap::n_heaps;

if (gen == 0)
{
#if 1 //subsumed by the linear allocation model
Expand Down Expand Up @@ -20973,7 +20985,7 @@ void gc_heap::gc1()
dynamic_data* dd = hp->dynamic_data_of (gen);
dd_desired_allocation (dd) = desired_per_heap;
dd_gc_new_allocation (dd) = desired_per_heap;
dd_new_allocation (dd) = desired_per_heap;
dd_new_allocation (dd) = desired_per_heap - already_consumed_per_heap;

if (gen == 0)
{
Expand Down Expand Up @@ -39412,6 +39424,8 @@ void gc_heap::compute_new_dynamic_data (int gen_number)
// When we are in the low latency mode, we can still be
// condemning more than gen1's 'cause of induced GCs.
dd_desired_allocation (dd) = low_latency_alloc;
dd_gc_new_allocation (dd) = dd_desired_allocation (dd);
dd_new_allocation (dd) = dd_gc_new_allocation (dd);
}
else
{
Expand Down Expand Up @@ -39461,14 +39475,16 @@ void gc_heap::compute_new_dynamic_data (int gen_number)
{
dd_desired_allocation (dd) = desired_new_allocation (dd, out, gen_number, 0);
}
dd_gc_new_allocation (dd) = dd_desired_allocation (dd);

// we may have had some incoming objects during this GC -
// adjust the consumed budget for these
dd_new_allocation (dd) = dd_gc_new_allocation (dd) - in;
}

gen_data->pinned_surv = dd_pinned_survived_size (dd);
gen_data->npinned_surv = dd_survived_size (dd) - dd_pinned_survived_size (dd);

dd_gc_new_allocation (dd) = dd_desired_allocation (dd);
dd_new_allocation (dd) = dd_gc_new_allocation (dd);

dd_promoted_size (dd) = out;
if (gen_number == max_generation)
{
Expand Down