~swisschili/bluejay

ref: 84aabeddd1cc358e0fc505d6226fe9c9468da2da bluejay/src/lisp/gc.h -rw-r--r-- 831 bytes
84aabeddswissChili Add GC segmented stack 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once

#include "lisp.h"

// I hate this
extern value_t *gc_base;

struct gc_skipped_segment
{
	// Top of stack (low memory)
	void *top;
	// Bottom of stack (high memory)
	void *bottom;

	value_t mark[8];
	int num_marked;
};

extern struct gc_skipped_segment gc_segments[64];
extern int gc_current_segment;

void gc_set_base_here();

value_t alloc_to_value(struct alloc *a);
void _do_gc(unsigned int esp, unsigned int ebp);
void _mark(value_t value, unsigned int *marked);
void _sweep();
void free_all();

// varargs should be a series of value_t's, followed by nil. Call this
// immediately in any function that is called by Lisp and may call
// other Lisp functions.
void gc_skip(void *last_arg, ...);
void gc_resume();
/// @param n Number of non-GC arguments passed to function
void gc_resumen(int n);
void gc_endskip();