summaryrefslogtreecommitdiff
path: root/src/gc.h
blob: af18323286589b978c37e90bd27f4b44a4f55a17 (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
#ifndef IMB3_GC_H
#define IMB3_GC_H

#include "value.h"

void gc_init(void);

enum gc_collect_reason {
  GC_COLLECT_MANUAL,
  GC_COLLECT_LIMIT,
  GC_COLLECT_OOM,
};

void gc_collect(enum gc_collect_reason);

struct object;

struct object *gc_alloc(size_t value_slot_count, size_t untraced_slot_count);
struct object *gc_alloc_compiled_function(size_t value_slot_count,
                                          size_t untraced_slot_count);
struct object *gc_alloc_hashtable_eq(size_t value_slot_count,
                                     size_t untraced_slot_count);

struct value gc_read_value_slot(const struct object *, size_t);
uintptr_t gc_read_untraced_slot(const struct object *, size_t);
uint8_t gc_read_untraced_byte(const struct object *, size_t);
void gc_write_value_slot(struct object *, size_t, struct value);
void gc_write_untraced_slot(struct object *, size_t, uintptr_t);
void gc_write_untraced_byte(struct object *, size_t, uint8_t);

void gc_root_push(struct value *);
void gc_root_pop(void);

void gc_debug(void);

#endif // IMB3_GC_H