-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgc.h
executable file
·61 lines (50 loc) · 1.34 KB
/
gc.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/** -*- coding:utf-8 -*-
\file
\author komiyamb
*/
#ifndef _KOM_GC_
#define _KOM_GC_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "type.h"
#define MEMORY_SIZE (1 << 20)/**< \def メモリサイズ */
#define top_offset 0
#define bottom_offset MEMORY_SIZE
#define STACK_SIZE 256
typedef struct memory{
lisp_object mem[MEMORY_SIZE*2];
/**
memoryの使用領域の開始位置。
top_offsetもしくはbottom_offset。
*/
int offset;
int free_point; /**< offsetからの未使用領域の開始位置。 */
}memory;
/**
実行時のオブジェクトを配置するメモリ
*/
memory mem;
typedef struct{
lisp_object* stack[STACK_SIZE];
int index;
} protect_stack;
/**
生成途中で、
envに登録されていないが回収されると困るオブジェクトを格納するリスト。
*/
protect_stack protect;
lisp_object* env;/**< 実行時の環境。*/
void test_gc(void);
void remove_protect(void);
void add_protect(lisp_object* obj);
void init_protect(void);
void gc(void);
lisp_object* alloc_obj(int num);
void init_memory(void);
double using_memory(void);
void flip_offset(void);
void init_gc_tag(void);
void set_copied(lisp_object* src, lisp_object* copied);
lisp_object* copy_obj(lisp_object* src);
#endif /* _KOM_GC_ */