mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-14 16:27:35 +02:00
WIP
This commit is contained in:
parent
3a68ce5a32
commit
2db7a2e86c
2 changed files with 22 additions and 1 deletions
|
@ -68,7 +68,7 @@ gc_heap *gc_heap_last(gc_heap *h);
|
|||
size_t gc_heap_total_size(gc_heap *h);
|
||||
void gc_mark(gc_heap *h, object obj);
|
||||
size_t gc_sweep(gc_heap *h, size_t *sum_freed_ptr);
|
||||
//void gc_collect(gc_heap *h, size_t *sum_freed)
|
||||
void gc_collect(gc_heap *h, size_t *sum_freed);
|
||||
|
||||
/* GC debugging flags */
|
||||
//#define DEBUG_GC 0
|
||||
|
|
21
runtime.c
21
runtime.c
|
@ -2345,6 +2345,27 @@ void Cyc_apply_from_buf(int argc, object prim, object *buf) {
|
|||
// longjmp(jmp_main,1); /* Return globals gc_cont, gc_ans. */
|
||||
//}
|
||||
|
||||
// NEW GC algorithm
|
||||
void gc_collect(gc_heap *h, size_t *sum_freed)
|
||||
{
|
||||
printf("(heap: %p size: %d)\n", h, (unsigned int)gc_heap_total_size(h));
|
||||
// Mark global variables
|
||||
gc_mark(h, Cyc_global_variables); /* Internal global used by the runtime */
|
||||
{
|
||||
list l = global_table;
|
||||
for(; !nullp(l); l = cdr(l)){
|
||||
cvar_type *c = (cvar_type *)car(l);
|
||||
gc_mark(h, *(c->pvar)); // Mark global, not the pvar
|
||||
}
|
||||
}
|
||||
// TODO: what else to mark? gc_mark(
|
||||
// conservative mark?
|
||||
// weak refs?
|
||||
// finalize?
|
||||
gc_sweep(h, sum_freed);
|
||||
// debug print free stats
|
||||
// return value from sweep??
|
||||
}
|
||||
void GC(cont,ans,num_ans) closure cont; object *ans; int num_ans;
|
||||
// TODO: take 'live' objects from the stack and allocate them on the heap
|
||||
/*
|
||||
|
|
Loading…
Add table
Reference in a new issue