-
Notifications
You must be signed in to change notification settings - Fork 5
/
runtime.h
51 lines (36 loc) · 1.49 KB
/
runtime.h
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
// At several points in our compiler we have decided to rely on the
// fact that pointers are 64 bits wide. The stdint.h header file
// declares a platform aware type that is guaranteed to contain
// 64-bits.
#include <stdint.h>
// Fromspace is our heap which is conceptually an array of 64 bit data
// unless meta information tells us more about about their contents.
int64_t* fromspace_begin;
int64_t* fromspace_end;
// The free pointer should always point to the next free memory
// location. While the mutator (user program) is running this
// should always be pointing into fromspace.
int64_t* free_ptr;
// The root stack is an array of pointers into the heap. During calls
// to the collector only pointers between the roostack_ptr and
// rootstack_begin are considered as live roots.
int64_t** rootstack_begin;
int64_t** rootstack_end;
// Initialize the memory of the runtime with a fixed rootstack size
// and initial heap size.
void initialize(uint64_t rootstack_size, uint64_t heap_size);
// Collect garbage data making room for a requested amount of memory.
// Use the pointers in the rootstack to determine what values in the
// heap are still live.
void collect(int64_t** rootstack_ptr, uint64_t bytes_requested);
// Read an integer from stdin.
int64_t read_int();
// Print an integer to stdout.
void print_int(int64_t x);
// Print a boolean to stdout.
void print_bool(int64_t x);
void print_vecbegin();
void print_vecend();
void print_space();
void print_ellipsis();
void print_any(int64_t any);