blob: 789e1241ed4df1e30cc88af3142076d862b04862 [file] [log] [blame]
swissChili6d6525e2021-06-15 21:20:53 -07001#pragma once
2
swissChili9e57da42021-06-15 22:22:46 -07003#include "lisp.h"
4
5// I hate this
6extern value_t *gc_base;
7
swissChilia890aed2022-07-30 17:13:07 -07008struct gc_stats
9{
10 // bytes currently used
11 unsigned long bytes_used;
12 // bytes ever freed by the GC
13 unsigned long bytes_freed;
14 // how many total allocations are currently alive
15 unsigned long total_allocs;
16 // how many times has the GC ever been run
17 unsigned long gc_runs;
18};
19
swissChili9e57da42021-06-15 22:22:46 -070020void gc_set_base_here();
21
swissChilie9fec8b2021-06-22 13:59:33 -070022value_t alloc_to_value(struct alloc *a);
swissChili6d6525e2021-06-15 21:20:53 -070023void _do_gc(unsigned int esp, unsigned int ebp);
swissChilie9fec8b2021-06-22 13:59:33 -070024void _mark(value_t value, unsigned int *marked);
swissChili6d6525e2021-06-15 21:20:53 -070025void _sweep();
swissChilib8fd4712021-06-23 15:32:04 -070026void free_all();
swissChilia890aed2022-07-30 17:13:07 -070027struct gc_stats gc_get_stats();