Skip to content

Commit b9c6811

Browse files
authored
Merge pull request #1045 from Unity-Technologies/expose-incremental-gc-time-slice-
Expose incremental gc time slice
2 parents 7ddade2 + efa4871 commit b9c6811

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

mono/metadata/boehm-gc.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,34 @@ mono_gc_get_heap_size (void)
419419
return GC_get_heap_size ();
420420
}
421421

422+
int64_t
423+
mono_gc_get_max_time_slice_ns()
424+
{
425+
#if HAVE_BDWGC_GC
426+
return GC_get_time_limit() * 1000000;
427+
#else
428+
return 0;
429+
#endif
430+
}
431+
432+
void
433+
mono_gc_set_max_time_slice_ns(int64_t maxTimeSlice)
434+
{
435+
#if HAVE_BDWGC_GC
436+
GC_set_time_limit(maxTimeSlice / 1000000);
437+
#endif
438+
}
439+
440+
MonoBoolean
441+
mono_gc_is_incremental()
442+
{
443+
#if HAVE_BDWGC_GC
444+
return GC_is_incremental_mode();
445+
#else
446+
return FALSE;
447+
#endif
448+
}
449+
422450
gboolean
423451
mono_gc_is_gc_thread (void)
424452
{

mono/metadata/mono-gc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ MONO_API int mono_gc_get_generation (MonoObject *object);
109109
MONO_API int mono_gc_collection_count (int generation);
110110
MONO_API int64_t mono_gc_get_used_size (void);
111111
MONO_API int64_t mono_gc_get_heap_size (void);
112+
MONO_API int64_t mono_gc_get_max_time_slice_ns ();
113+
MONO_API void mono_gc_set_max_time_slice_ns (int64_t maxTimeSlice);
112114
MONO_API MonoBoolean mono_gc_pending_finalizers (void);
115+
MONO_API MonoBoolean mono_gc_is_incremental (void);
113116
MONO_API void mono_gc_finalize_notify (void);
114117
MONO_API int mono_gc_invoke_finalizers (void);
115118
/* heap walking is only valid in the pre-stop-world event callback */

mono/metadata/null-gc.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,23 @@ mono_gc_get_heap_size (void)
9191
return 2*1024*1024;
9292
}
9393

94+
int64_t
95+
mono_gc_get_max_time_slice_ns()
96+
{
97+
return 0;
98+
}
99+
100+
void
101+
mono_gc_set_max_time_slice_ns(int64_t maxTimeSlice)
102+
{
103+
}
104+
105+
MonoBoolean
106+
mono_gc_is_incremental()
107+
{
108+
return FALSE;
109+
}
110+
94111
gboolean
95112
mono_gc_is_gc_thread (void)
96113
{

mono/metadata/sgen-mono.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,6 +2831,23 @@ mono_gc_get_heap_size (void)
28312831
return (int64_t)sgen_gc_get_total_heap_allocation ();
28322832
}
28332833

2834+
int64_t
2835+
mono_gc_get_max_time_slice_ns()
2836+
{
2837+
return 0;
2838+
}
2839+
2840+
MonoBoolean
2841+
mono_gc_is_incremental()
2842+
{
2843+
return FALSE;
2844+
}
2845+
2846+
void
2847+
mono_gc_set_max_time_slice_ns(int64_t maxTimeSlice)
2848+
{
2849+
}
2850+
28342851
MonoGCDescriptor
28352852
mono_gc_make_root_descr_user (MonoGCRootMarkFunc marker)
28362853
{

0 commit comments

Comments
 (0)