Skip to content

Commit c9e69e0

Browse files
authored
Merge pull request #1114 from Unity-Technologies/incremental-gc-editor-support
Incremental gc editor support
2 parents 5ff4deb + 9761b3e commit c9e69e0

File tree

8 files changed

+48
-11
lines changed

8 files changed

+48
-11
lines changed

external/bdwgc

mono/metadata/appdomain.c

+2
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetupHa
633633
goto_if_nok (error, leave);
634634
MONO_HANDLE_SETVAL (ad, data, MonoDomain*, data);
635635
data->domain = MONO_HANDLE_RAW (ad);
636+
mono_gc_wbarrier_generic_nostore (&data->domain);
636637
data->friendly_name = g_strdup (friendly_name);
637638

638639
MONO_PROFILER_RAISE (domain_name, (data, data->friendly_name));
@@ -660,6 +661,7 @@ mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetupHa
660661
goto_if_nok (error, leave);
661662

662663
data->setup = MONO_HANDLE_RAW (copy_app_domain_setup (data, setup, error));
664+
mono_gc_wbarrier_generic_nostore (&data->setup);
663665
if (!mono_error_ok (error)) {
664666
g_free (data->friendly_name);
665667
goto leave;

mono/metadata/boehm-gc.c

+13
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,19 @@ mono_gc_is_incremental()
454454
#endif
455455
}
456456

457+
void
458+
mono_gc_set_incremental(MonoBoolean value)
459+
{
460+
#if HAVE_BDWGC_GC
461+
if (GC_is_incremental_mode() == value)
462+
return;
463+
if (value)
464+
GC_enable_incremental();
465+
else
466+
GC_disable_incremental();
467+
#endif
468+
}
469+
457470
gboolean
458471
mono_gc_is_gc_thread (void)
459472
{

mono/metadata/gc.c

+18-9
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ mono_gc_finalize_notify (void)
760760
g_message ( "%s: prodding finalizer", __func__);
761761
#endif
762762

763-
if (mono_gc_is_null () || mono_gc_is_disabled())
763+
if (mono_gc_is_null ())
764764
return;
765765

766766
#ifdef HOST_WASM
@@ -928,6 +928,18 @@ finalizer_thread (gpointer unused)
928928
/* Register a hazard free queue pump callback */
929929
mono_hazard_pointer_install_free_queue_size_callback (hazard_free_queue_is_too_big);
930930

931+
/* if GC is disabled, we run no finalizer, but we still run mono_w32process_signal_finished
932+
on the finalizer thread, so that processes can exit. */
933+
if (mono_gc_is_disabled())
934+
{
935+
while (!finished)
936+
{
937+
mono_coop_sem_wait (&finalizer_sem, MONO_SEM_FLAGS_ALERTABLE);
938+
mono_w32process_signal_finished();
939+
}
940+
return 0;
941+
}
942+
931943
while (!finished) {
932944
/* Wait to be notified that there's at least one
933945
* finaliser to run
@@ -995,10 +1007,8 @@ mono_gc_init (void)
9951007

9961008
mono_gc_base_init ();
9971009

998-
if (mono_gc_is_disabled ()) {
1010+
if (mono_gc_is_disabled ())
9991011
gc_disabled = TRUE;
1000-
return;
1001-
}
10021012

10031013
#ifdef TARGET_WIN32
10041014
pending_done_event = CreateEvent (NULL, TRUE, FALSE, NULL);
@@ -1025,9 +1035,9 @@ mono_gc_cleanup (void)
10251035

10261036
if (mono_gc_is_null ())
10271037
return;
1028-
1038+
1039+
finished = TRUE;
10291040
if (!gc_disabled) {
1030-
finished = TRUE;
10311041
if (mono_thread_internal_current () != gc_thread) {
10321042
int ret;
10331043
gint64 start;
@@ -1086,10 +1096,9 @@ mono_gc_cleanup (void)
10861096
}
10871097
gc_thread = NULL;
10881098
mono_gc_base_cleanup ();
1089-
}
1090-
1091-
mono_reference_queue_cleanup ();
10921099

1100+
mono_reference_queue_cleanup ();
1101+
}
10931102
mono_coop_mutex_destroy (&finalizer_mutex);
10941103
mono_coop_mutex_destroy (&reference_queue_mutex);
10951104
}

mono/metadata/mono-gc.h

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ MONO_API int64_t mono_gc_get_max_time_slice_ns ();
114114
MONO_API void mono_gc_set_max_time_slice_ns (int64_t maxTimeSlice);
115115
MONO_API MonoBoolean mono_gc_pending_finalizers (void);
116116
MONO_API MonoBoolean mono_gc_is_incremental (void);
117+
MONO_API void mono_gc_set_incremental(MonoBoolean value);
117118
MONO_API void mono_gc_finalize_notify (void);
118119
MONO_API int mono_gc_invoke_finalizers (void);
119120
/* heap walking is only valid in the pre-stop-world event callback */

mono/metadata/null-gc.c

+5
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ mono_gc_is_incremental()
108108
return FALSE;
109109
}
110110

111+
void
112+
mono_gc_set_incremental(MonoBoolean value)
113+
{
114+
}
115+
111116
gboolean
112117
mono_gc_is_gc_thread (void)
113118
{

mono/metadata/object.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1993,9 +1993,11 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, MonoErro
19931993
* vtable field in MonoObject, since we can no longer assume the
19941994
* vtable is reachable by other roots after the appdomain is unloaded.
19951995
*/
1996-
if (!mono_gc_is_moving () && domain != mono_get_root_domain () && !mono_dont_free_domains)
1996+
#if HAVE_BOEHM_GC
1997+
if (domain != mono_get_root_domain () && !mono_dont_free_domains)
19971998
vt->gc_descr = MONO_GC_DESCRIPTOR_NULL;
19981999
else
2000+
#endif
19992001
vt->gc_descr = klass->gc_descr;
20002002

20012003
gc_bits = mono_gc_get_vtable_bits (klass);

mono/metadata/sgen-mono.c

+5
Original file line numberDiff line numberDiff line change
@@ -2843,6 +2843,11 @@ mono_gc_is_incremental()
28432843
return FALSE;
28442844
}
28452845

2846+
void
2847+
mono_gc_set_incremental(MonoBoolean value)
2848+
{
2849+
}
2850+
28462851
void
28472852
mono_gc_set_max_time_slice_ns(int64_t maxTimeSlice)
28482853
{

0 commit comments

Comments
 (0)