1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-15 10:10:21 +02:00

mark-sweep: mutator data structure separate from heap

This will allow thread-local allocation buffers.
This commit is contained in:
Andy Wingo 2022-03-29 08:36:24 +02:00
parent 61d38e4205
commit 2401732e31

View file

@ -116,12 +116,12 @@ struct context {
struct mark_space { struct context cx; }; struct mark_space { struct context cx; };
struct heap { struct mark_space mark_space; }; struct heap { struct mark_space mark_space; };
struct mutator { struct mutator {
struct heap heap; struct heap *heap;
struct handle *roots; struct handle *roots;
}; };
static inline struct heap* mutator_heap(struct mutator *mut) { 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) { static inline struct mark_space* heap_mark_space(struct heap *heap) {
return &heap->mark_space; return &heap->mark_space;
@ -472,11 +472,9 @@ static int initialize_gc(size_t size, struct heap **heap,
return 0; return 0;
} }
*mut = calloc(1, sizeof(struct mutator)); *heap = calloc(1, sizeof(struct heap));
if (!*mut) abort(); if (!*heap) abort();
(*mut)->roots = NULL; struct mark_space *space = heap_mark_space(*heap);
*heap = mutator_heap(*mut);
struct mark_space *space = mutator_mark_space(*mut);
struct context *cx = &space->cx; struct context *cx = &space->cx;
cx->mem = mem; cx->mem = mem;
@ -501,6 +499,11 @@ static int initialize_gc(size_t size, struct heap **heap,
abort(); abort();
reclaim(cx, (void*)cx->heap_base, size_to_granules(cx->heap_size)); 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; return 1;
} }