Skip to content

Commit d063d2b

Browse files
committed
Expose incremental gc time slice in mono API
1 parent a098bd2 commit d063d2b

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

mono/metadata/boehm-gc.c

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

422+
int64_t
423+
mono_get_max_time_slice_ns()
424+
{
425+
return GC_get_time_limit() * 1000000;
426+
}
427+
428+
void
429+
mono_set_max_time_slice_ns(int64_t maxTimeSlice)
430+
{
431+
GC_set_time_limit(maxTimeSlice / 1000000);
432+
}
433+
422434
gboolean
423435
mono_gc_is_gc_thread (void)
424436
{

mono/metadata/mono-gc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ 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_get_max_time_slice_ns ();
113+
MONO_API void mono_set_max_time_slice_ns (int64_t maxTimeSlice);
112114
MONO_API MonoBoolean mono_gc_pending_finalizers (void);
113115
MONO_API void mono_gc_finalize_notify (void);
114116
MONO_API int mono_gc_invoke_finalizers (void);

mono/metadata/null-gc.c

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

94+
int64_t
95+
mono_get_max_time_slice_ns()
96+
{
97+
return 0;
98+
}
99+
100+
void
101+
mono_set_max_time_slice_ns(int64_t maxTimeSlice)
102+
{
103+
}
104+
94105
gboolean
95106
mono_gc_is_gc_thread (void)
96107
{

mono/metadata/sgen-mono.c

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

2834+
int64_t
2835+
mono_get_max_time_slice_ns()
2836+
{
2837+
return 0;
2838+
}
2839+
2840+
void
2841+
mono_set_max_time_slice_ns(int64_t maxTimeSlice)
2842+
{
2843+
}
2844+
28342845
MonoGCDescriptor
28352846
mono_gc_make_root_descr_user (MonoGCRootMarkFunc marker)
28362847
{

0 commit comments

Comments
 (0)