blob: 8377e4cbeb25a915b534c282dca3063d04975681 (
plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#ifndef SHED_GC_H
#define SHED_GC_H
#include <stdbool.h>
#include "../patio/patio.h"
#include "./std/unistd.h"
#include "./primitives.h"
// == Runtime types ==
struct RuntimeType {
uint32_t children_offset;
uint32_t children_count;
};
extern struct RuntimeType shed__rtti[];
// == GC objects ==
struct ShedGcObjectHeader {
struct ShedGcObjectHeader* next;
uint32_t mark;
uint32_t runtime_type_tag;
};
bool shed__runtime__gc_is_gc_object(ShedObject object);
// == Roots ==
typedef size_t ShedGcRootIndex;
extern ShedGcRootIndex shed__runtime__gc_root_stack_index;
extern struct ShedGcObjectHeader* shed__runtime__gc_root_stack[];
void shed__runtime__gc_push_root_gc_object(struct ShedGcObjectHeader* gc_root);
// == Initialization ==
void shed__runtime__gc_init(void);
// == Allocation ==
void* shed__runtime__gc_alloc(size_t size, uint32_t runtime_type_tag);
// == Collection ==
void shed__runtime__gc_collect(void);
// == Clearing ==
void shed__runtime__gc_clear(void);
void shed__runtime__gc_clear_roots(void);
#endif
|