Skip to content

Commit 531d09b

Browse files
jechterUnityAlex
authored andcommitted
Don't use mono_gc_is_moving for incremental gc (#1228)
1 parent 20e0320 commit 531d09b

File tree

7 files changed

+31
-9
lines changed

7 files changed

+31
-9
lines changed

mono/metadata/boehm-gc.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -237,17 +237,16 @@ mono_gc_base_init (void)
237237
opt = strchr (opt, '=') + 1;
238238
if (*opt && mono_gc_parse_environment_string_extract_number (opt, &time_limit)) {
239239
GC_enable_incremental ();
240-
#if HAVE_BDWGC_GC
241-
if (time_limit != 0)
240+
if (time_limit != 0) {
242241
// value is in milliseconds
243242
GC_set_time_limit (time_limit);
244-
#endif
243+
}
245244
}
246245
continue;
247246
} else if (g_str_has_prefix (opt, "strict-wbarriers")) {
248247
gc_strict_wbarriers = TRUE;
249248
continue;
250-
}else {
249+
} else {
251250
/* Could be a parameter for sgen */
252251
/*
253252
fprintf (stderr, "MONO_GC_PARAMS must be a comma-delimited list of one or more of the following:\n");
@@ -1174,6 +1173,12 @@ mono_gc_set_desktop_mode (void)
11741173

11751174
gboolean
11761175
mono_gc_is_moving (void)
1176+
{
1177+
return FALSE;
1178+
}
1179+
1180+
gboolean
1181+
mono_gc_needs_write_barriers(void)
11771182
{
11781183
return GC_is_incremental_mode ();
11791184
}

mono/metadata/gc-internals.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
} while (0)
6363

6464
/* useful until we keep track of gc-references in corlib etc. */
65-
#define IS_GC_REFERENCE(class,t) (mono_gc_is_moving () ? FALSE : ((t)->type == MONO_TYPE_U && (class)->image == mono_defaults.corlib))
65+
#define IS_GC_REFERENCE(class,t) (mono_gc_needs_write_barriers() ? FALSE : ((t)->type == MONO_TYPE_U && (class)->image == mono_defaults.corlib))
6666

6767
void mono_object_register_finalizer (MonoObject *obj);
6868

@@ -320,6 +320,11 @@ void mono_gc_set_desktop_mode (void);
320320
*/
321321
gboolean mono_gc_is_moving (void);
322322

323+
/*
324+
* Return whenever this GC needs write barriers
325+
*/
326+
gboolean mono_gc_needs_write_barriers (void);
327+
323328
typedef void* (*MonoGCLockedCallbackFunc) (void *data);
324329

325330
void* mono_gc_invoke_with_gc_lock (MonoGCLockedCallbackFunc func, void *data);

mono/metadata/null-gc.c

+6
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,12 @@ mono_gc_is_moving (void)
454454
return FALSE;
455455
}
456456

457+
gboolean
458+
mono_gc_needs_write_barriers(void)
459+
{
460+
return FALSE;
461+
}
462+
457463
gboolean
458464
mono_gc_is_disabled (void)
459465
{

mono/metadata/object.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -6304,7 +6304,7 @@ mono_array_full_copy (MonoArray *src, MonoArray *dest)
63046304
static void
63056305
array_full_copy_unchecked_size (MonoArray *src, MonoArray *dest, MonoClass *klass, uintptr_t size)
63066306
{
6307-
if (mono_gc_is_moving ()) {
6307+
if (mono_gc_needs_write_barriers ()) {
63086308
MonoClass *element_class = m_class_get_element_class (klass);
63096309
if (m_class_is_valuetype (element_class)) {
63106310
if (m_class_has_references (element_class))
@@ -7170,7 +7170,7 @@ mono_value_box_handle (MonoDomain *domain, MonoClass *klass, gpointer value, Mon
71707170
return_val_if_nok (error, NULL_HANDLE);
71717171

71727172
size -= MONO_ABI_SIZEOF (MonoObject);
7173-
if (mono_gc_is_moving ()) {
7173+
if (mono_gc_needs_write_barriers ()) {
71747174
g_assert (size == mono_class_value_size (klass, NULL));
71757175
MONO_ENTER_NO_SAFEPOINTS;
71767176
gpointer data = mono_handle_get_data_unsafe (res_handle);

mono/metadata/sgen-mono.c

+6
Original file line numberDiff line numberDiff line change
@@ -2558,6 +2558,12 @@ mono_gc_is_moving (void)
25582558
return TRUE;
25592559
}
25602560

2561+
gboolean
2562+
mono_gc_needs_write_barriers(void)
2563+
{
2564+
return TRUE;
2565+
}
2566+
25612567
gboolean
25622568
mono_gc_is_disabled (void)
25632569
{

mono/mini/aot-compiler.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4412,7 +4412,7 @@ add_gc_wrappers (MonoAotCompile *acfg)
44124412
}
44134413

44144414
/* write barriers */
4415-
if (mono_gc_is_moving ()) {
4415+
if (mono_gc_needs_write_barriers ()) {
44164416
add_method (acfg, mono_gc_get_specific_write_barrier (FALSE));
44174417
add_method (acfg, mono_gc_get_specific_write_barrier (TRUE));
44184418
}

mono/mini/mini-gc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2647,7 +2647,7 @@ mini_gc_set_slot_type_from_cfa (MonoCompile *cfg, int slot_offset, GCSlotType ty
26472647
void
26482648
mini_gc_init_cfg (MonoCompile *cfg)
26492649
{
2650-
if (mono_gc_is_moving ()) {
2650+
if (mono_gc_needs_write_barriers()) {
26512651
cfg->disable_ref_noref_stack_slot_share = TRUE;
26522652
cfg->gen_write_barriers = TRUE;
26532653
}

0 commit comments

Comments
 (0)