@@ -2863,6 +2863,7 @@ uint64_t gc_heap::last_suspended_end_time = 0;
28632863uint64_t gc_heap::change_heap_count_time = 0;
28642864size_t gc_heap::gc_index_full_gc_end = 0;
28652865uint64_t gc_heap::before_distribute_free_regions_time = 0;
2866+ bool gc_heap::trigger_initial_gen2_p = false;
28662867
28672868#ifdef BACKGROUND_GC
28682869bool gc_heap::trigger_bgc_for_rethreading_p = false;
@@ -21058,6 +21059,26 @@ int gc_heap::joined_generation_to_condemn (BOOL should_evaluate_elevation,
2105821059 }
2105921060#endif //BACKGROUND_GC
2106021061
21062+ #ifdef DYNAMIC_HEAP_COUNT
21063+ if (trigger_initial_gen2_p)
21064+ {
21065+ #ifdef BACKGROUND_GC
21066+ assert (!trigger_bgc_for_rethreading_p);
21067+ assert (!background_running_p());
21068+ #endif //BACKGROUND_GC
21069+
21070+ if (n != max_generation)
21071+ {
21072+ n = max_generation;
21073+ *blocking_collection_p = FALSE;
21074+
21075+ dprintf (6666, ("doing the 1st gen2 GC requested by DATAS"));
21076+ }
21077+
21078+ trigger_initial_gen2_p = false;
21079+ }
21080+ #endif //DYNAMIC_HEAP_COUNT
21081+
2106121082 return n;
2106221083}
2106321084
@@ -25612,6 +25633,21 @@ void gc_heap::calculate_new_heap_count ()
2561225633
2561325634 if (change_int > 0)
2561425635 {
25636+ // If we do want to grow but the max HC allowed by DATAS is 0, and we haven't done any gen2 GCs yet, we do want to
25637+ // trigger a gen2 right away.
25638+ if (!max_heap_count_growth_datas && !(dynamic_heap_count_data.current_gen2_samples_count))
25639+ {
25640+ trigger_initial_gen2_p = true;
25641+
25642+ dprintf (6666, ("we want to grow but DATAS is limiting, trigger a gen2 right away"));
25643+ #ifdef BACKGROUND_GC
25644+ if (background_running_p())
25645+ {
25646+ trigger_initial_gen2_p = false;
25647+ }
25648+ #endif //BACKGROUND_GC
25649+ }
25650+
2561525651 agg_factor = dynamic_heap_count_data.get_aggressiveness (change_int);
2561625652 if (agg_factor > 1)
2561725653 {
@@ -26217,7 +26253,16 @@ bool gc_heap::change_heap_count (int new_n_heaps)
2621726253 // rethread the free lists
2621826254 for (int gen_idx = 0; gen_idx < total_generation_count; gen_idx++)
2621926255 {
26220- if (gen_idx != max_generation)
26256+ bool do_rethreading = true;
26257+
26258+ #ifdef BACKGROUND_GC
26259+ if (trigger_bgc_for_rethreading_p && (gen_idx == max_generation))
26260+ {
26261+ do_rethreading = false;
26262+ }
26263+ #endif //BACKGROUND_GC
26264+
26265+ if (do_rethreading)
2622126266 {
2622226267 if (heap_number < old_n_heaps)
2622326268 {
0 commit comments