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

commit 2401732e318d553bac69dffe30ac04a58e371d9e
Author: Andy Wingo <wi...@igalia.com>
AuthorDate: Tue Mar 29 08:36:24 2022 +0200

    mark-sweep: mutator data structure separate from heap
    
    This will allow thread-local allocation buffers.
---
 mark-sweep.h | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/mark-sweep.h b/mark-sweep.h
index f8993bb20..034f59813 100644
--- a/mark-sweep.h
+++ b/mark-sweep.h
@@ -116,12 +116,12 @@ struct context {
 struct mark_space { struct context cx; };
 struct heap { struct mark_space mark_space; };
 struct mutator {
-  struct heap heap;
+  struct heap *heap;
   struct handle *roots;
 };
 
 static inline struct heap* mutator_heap(struct mutator *mut) {
-  return &mut->heap;
+  return mut->heap;
 }
 static inline struct mark_space* heap_mark_space(struct heap *heap) {
   return &heap->mark_space;
@@ -472,11 +472,9 @@ static int initialize_gc(size_t size, struct heap **heap,
     return 0;
   }
 
-  *mut = calloc(1, sizeof(struct mutator));
-  if (!*mut) abort();
-  (*mut)->roots = NULL;
-  *heap = mutator_heap(*mut);
-  struct mark_space *space = mutator_mark_space(*mut);
+  *heap = calloc(1, sizeof(struct heap));
+  if (!*heap) abort();
+  struct mark_space *space = heap_mark_space(*heap);
   struct context *cx = &space->cx;
 
   cx->mem = mem;
@@ -501,6 +499,11 @@ static int initialize_gc(size_t size, struct heap **heap,
     abort();
   reclaim(cx, (void*)cx->heap_base, size_to_granules(cx->heap_size));
 
+  *mut = calloc(1, sizeof(struct mutator));
+  if (!*mut) abort();
+  (*mut)->heap = *heap;
+  (*mut)->roots = NULL;
+
   return 1;
 }
 

Reply via email to