]> gitweb.factorcode.org Git - factor.git/blob - vm/data_heap.hpp
vm: number of generations is not configurable anymore, split up begin_gc() and end_gc...
[factor.git] / vm / data_heap.hpp
1 namespace factor
2 {
3
4 /* generational copying GC divides memory into zones */
5 struct zone {
6         /* allocation pointer is 'here'; its offset is hardcoded in the
7         compiler backends */
8         cell start;
9         cell here;
10         cell size;
11         cell end;
12         
13         cell init_zone(cell size_, cell start_)
14         {
15                 size = size_;
16                 start = here = start_;
17                 end = start_ + size_;
18                 return end;
19         }
20         
21         inline bool contains_p(object *pointer)
22         {
23                 return (cell)pointer >= start && (cell)pointer < end;
24         }
25 };
26
27 struct data_heap {
28         segment *seg;
29
30         cell young_size;
31         cell aging_size;
32         cell tenured_size;
33
34         zone *generations;
35         zone *semispaces;
36
37         char *allot_markers;
38         char *allot_markers_end;
39
40         char *cards;
41         char *cards_end;
42
43         char *decks;
44         char *decks_end;
45         
46         /* the 0th generation is where new objects are allocated. */
47         cell nursery() { return 0; }
48         
49         /* where objects hang around */
50         cell aging() { return 1; }
51         
52         /* the oldest generation */
53         cell tenured() { return 2; }
54         
55         explicit data_heap(factor_vm *myvm, cell young_size, cell aging_size, cell tenured_size);
56         ~data_heap();
57 };
58
59 static const cell gen_count = 3;
60
61 }