@@ -7151,7 +7151,6 @@ void gc_mechanisms::init_mechanisms()
7151
7151
found_finalizers = FALSE;
7152
7152
#ifdef BACKGROUND_GC
7153
7153
background_p = gc_heap::background_running_p() != FALSE;
7154
- allocations_allowed = TRUE;
7155
7154
#endif //BACKGROUND_GC
7156
7155
7157
7156
entry_memory_load = 0;
@@ -7444,15 +7443,6 @@ void gc_heap::reset_allocation_pointers (generation* gen, uint8_t* start)
7444
7443
7445
7444
bool gc_heap::new_allocation_allowed (int gen_number)
7446
7445
{
7447
- #ifdef BACKGROUND_GC
7448
- //TODO BACKGROUND_GC this is for test only
7449
- if (!settings.allocations_allowed)
7450
- {
7451
- dprintf (2, ("new allocation not allowed"));
7452
- return FALSE;
7453
- }
7454
- #endif //BACKGROUND_GC
7455
-
7456
7446
if (dd_new_allocation (dynamic_data_of (gen_number)) < 0)
7457
7447
{
7458
7448
if (gen_number != 0)
@@ -16084,18 +16074,22 @@ void gc_heap::wait_for_background (alloc_wait_reason awr, bool loh_p)
16084
16074
add_saved_spinlock_info (loh_p, me_acquire, mt_wait_bgc);
16085
16075
}
16086
16076
16087
- void gc_heap::wait_for_bgc_high_memory (alloc_wait_reason awr, bool loh_p)
16077
+ bool gc_heap::wait_for_bgc_high_memory (alloc_wait_reason awr, bool loh_p)
16088
16078
{
16079
+ bool wait_p = false;
16089
16080
if (gc_heap::background_running_p())
16090
16081
{
16091
16082
uint32_t memory_load;
16092
16083
get_memory_info (&memory_load);
16093
16084
if (memory_load >= m_high_memory_load_th)
16094
16085
{
16086
+ wait_p = true;
16095
16087
dprintf (GTC_LOG, ("high mem - wait for BGC to finish, wait reason: %d", awr));
16096
16088
wait_for_background (awr, loh_p);
16097
16089
}
16098
16090
}
16091
+
16092
+ return wait_p;
16099
16093
}
16100
16094
16101
16095
#endif //BACKGROUND_GC
@@ -17203,18 +17197,27 @@ allocation_state gc_heap::try_allocate_more_space (alloc_context* acontext, size
17203
17197
}
17204
17198
17205
17199
#ifdef BACKGROUND_GC
17206
- wait_for_bgc_high_memory (awr_gen0_alloc, loh_p);
17200
+ bool recheck_p = wait_for_bgc_high_memory (awr_gen0_alloc, loh_p);
17207
17201
#endif //BACKGROUND_GC
17208
17202
17209
17203
#ifdef SYNCHRONIZATION_STATS
17210
17204
bad_suspension++;
17211
17205
#endif //SYNCHRONIZATION_STATS
17212
17206
dprintf (2, ("h%d running out of budget on gen%d, gc", heap_number, gen_number));
17213
17207
17214
- if (!settings.concurrent || (gen_number == 0))
17208
+ #ifdef BACKGROUND_GC
17209
+ bool trigger_gc_p = true;
17210
+ if (recheck_p)
17211
+ trigger_gc_p = !(new_allocation_allowed (gen_number));
17212
+
17213
+ if (trigger_gc_p)
17214
+ #endif //BACKGROUND_GC
17215
17215
{
17216
- trigger_gc_for_alloc (0, ((gen_number == 0) ? reason_alloc_soh : reason_alloc_loh),
17217
- msl, loh_p, mt_try_budget);
17216
+ if (!settings.concurrent || (gen_number == 0))
17217
+ {
17218
+ trigger_gc_for_alloc (0, ((gen_number == 0) ? reason_alloc_soh : reason_alloc_loh),
17219
+ msl, loh_p, mt_try_budget);
17220
+ }
17218
17221
}
17219
17222
}
17220
17223
}
0 commit comments