mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-15 18:20:42 +02:00
mark-sweep: mutator data structure separate from heap
This will allow thread-local allocation buffers.
This commit is contained in:
parent
61d38e4205
commit
2401732e31
1 changed files with 10 additions and 7 deletions
17
mark-sweep.h
17
mark-sweep.h
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue