summaryrefslogtreecommitdiffstats
path: root/bytecode/heap.h
blob: c8d7e2ce875c8c33360ac51161b8d29dbd0a7e5a (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 "slice.h"
#include "value.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.
	struct val_slice active;
	struct val_slice standby;

	size_t free_ptr;

	size_t last_free;
	struct val_slice gc_roots;
};

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

#endif