]> gitweb.factorcode.org Git - factor.git/blob - vm/gc.hpp
Merge branch 's3' of git://double.co.nz/git/factor
[factor.git] / vm / gc.hpp
1 namespace factor
2 {
3
4 /* statistics */
5 struct generation_statistics {
6         cell collections;
7         u64 gc_time;
8         u64 max_gc_time;
9         cell object_count;
10         u64 bytes_copied;
11 };
12
13 struct gc_statistics {
14         generation_statistics generations[gen_count];
15         u64 cards_scanned;
16         u64 decks_scanned;
17         u64 card_scan_time;
18         u64 code_blocks_scanned;
19 };
20
21 struct gc_state {
22         /* The data heap we're collecting */
23         data_heap *data;
24
25         /* sometimes we grow the heap */
26         bool growing_data_heap;
27
28         /* Which generation is being collected */
29         cell collecting_gen;
30
31         /* If true, we are collecting aging space for the second time, so if it is still
32            full, we go on to collect tenured */
33         bool collecting_aging_again;
34
35         /* GC start time, for benchmarking */
36         u64 start_time;
37
38         jmp_buf gc_unwind;
39
40         explicit gc_state(data_heap *data_, bool growing_data_heap_, cell collecting_gen_);
41         ~gc_state();
42
43         inline bool collecting_nursery_p()
44         {
45                 return collecting_gen == nursery_gen;
46         }
47
48         inline bool collecting_aging_p()
49         {
50                 return collecting_gen == aging_gen;
51         }
52
53         inline bool collecting_tenured_p()
54         {
55                 return collecting_gen == tenured_gen;
56         }
57
58         inline bool collecting_accumulation_gen_p()
59         {
60                 return ((collecting_aging_p() && !collecting_aging_again)
61                         || collecting_tenured_p());
62         }
63 };
64
65 VM_C_API void inline_gc(cell *gc_roots_base, cell gc_roots_size, factor_vm *myvm);
66
67 }