-
Notifications
You must be signed in to change notification settings - Fork 9
/
alloc.h
29 lines (25 loc) · 1.31 KB
/
alloc.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
#ifndef ALLOC_H
#define ALLOC_H
#include <stdio.h> // size_t, ssize_t
enum class MEM {
STR_INTERN, // Used to allocate space for string interning hash table.
PARSE_TEMP, // Used to allocate memory for parsing objects that are useless
// (and gets de-allocated) after pass 1 of type-checking.
PARSE_PERSIST_TYPECHECK_PASS2, // Used to allocate memory for parsing objects
// that need to persist through type-checking
// and codegen.
TYPECHECK, // Used to allocate memory for type-checking / codegen.
FUNC, // Used for memory that is only used per function and then
// gets de-allocated.
// TODO: Locals and stuff could be saved there and not persist.
VTABLE, // Used only during the generation of vtables and then gets de-allocated.
CHILDREN, // Used only during the generation of vtables and then gets de-allocated.
// But note that we can't use the same arena as above because this gets
// de-allocated every time we change inheritance tree (which means
// we would lose the children of the other inheritance trees).
__LEN
};
void *allocate(size_t n, MEM enum_ar);
void *allocate_zero(size_t n, MEM ar);
void deallocate(MEM enum_ar);
#endif