summaryrefslogtreecommitdiffstats
path: root/bytecode/heap.h
blob: c6c10c44f2bfcf6f7a3bf4960968d0de8865a95e (plain) (blame)
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
#ifndef _HEAP_H_
#define _HEAP_H_

#include <stddef.h>
#include <stdint.h>

#include "value.h"
#include "value_slice.h"

struct heap {
	// The heap is divided into two halves for garbage collection.
	// buf holds the malloc'd heap buffer.
	value *buf;
	// active and standby are slices that partition buf.
	value_slice active;
	value_slice standby;

	size_t free_ptr;

	size_t last_free;
	value_slice gc_roots;
};

struct heap new_heap(value_slice);
value *alloc(struct heap *, int64_t);

#endif