wingo pushed a commit to branch wip-whippet
in repository guile.

commit 44f37a373ceae45d9fa1ff090d75830062cc86be
Author: Andy Wingo <wi...@igalia.com>
AuthorDate: Sun Jan 22 21:04:20 2023 +0100

    Add gc_collect(mutator) API
---
 bdw.c     | 2 +-
 gc-api.h  | 2 ++
 semi.c    | 4 ++++
 whippet.c | 4 ++++
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/bdw.c b/bdw.c
index c8fdc5a80..d4aac0a56 100644
--- a/bdw.c
+++ b/bdw.c
@@ -116,7 +116,7 @@ void* gc_allocate_pointerless(struct gc_mutator *mut,
   return GC_malloc_atomic(size);
 }
 
-static inline void collect(struct gc_mutator *mut) {
+void gc_collect(struct gc_mutator *mut) {
   GC_gcollect();
 }
 
diff --git a/gc-api.h b/gc-api.h
index a33fd7b12..bec889cf4 100644
--- a/gc-api.h
+++ b/gc-api.h
@@ -57,6 +57,8 @@ GC_API_ void* gc_call_without_gc(struct gc_mutator *mut, 
void* (*f)(void*),
                                  void *data) GC_NEVER_INLINE;
 GC_API_ void gc_print_stats(struct gc_heap *heap);
 
+GC_API_ void gc_collect(struct gc_mutator *mut);
+
 static inline void gc_clear_fresh_allocation(struct gc_ref obj,
                                              size_t size) GC_ALWAYS_INLINE;
 static inline void gc_clear_fresh_allocation(struct gc_ref obj,
diff --git a/semi.c b/semi.c
index 4c505b60e..d9e1110cf 100644
--- a/semi.c
+++ b/semi.c
@@ -171,6 +171,10 @@ static void collect(struct gc_mutator *mut) {
   // fprintf(stderr, "%zd bytes copied\n", 
(space->size>>1)-(space->limit-space->hp));
 }
 
+void gc_collect(struct gc_mutator *mut) {
+  collect(mut);
+}
+
 static void collect_for_alloc(struct gc_mutator *mut, size_t bytes) {
   collect(mut);
   struct semi_space *space = mutator_semi_space(mut);
diff --git a/whippet.c b/whippet.c
index 90f2b470c..ee18445de 100644
--- a/whippet.c
+++ b/whippet.c
@@ -1992,6 +1992,10 @@ static void trigger_collection(struct gc_mutator *mut) {
   heap_unlock(heap);
 }
 
+void gc_collect(struct gc_mutator *mut) {
+  trigger_collection(mut);
+}
+
 void* gc_allocate_large(struct gc_mutator *mut, size_t size) {
   struct gc_heap *heap = mutator_heap(mut);
   struct large_object_space *space = heap_large_object_space(heap);

Reply via email to