]> gitweb.factorcode.org Git - factor.git/blob - vm/gc.hpp
Merge branch 'bitfields' of git://factorcode.org/git/factor into bitfields
[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         data_heap *old_data_heap;
28
29         /* Which generation is being collected */
30         cell collecting_gen;
31
32         /* If true, we are collecting aging space for the second time, so if it is still
33            full, we go on to collect tenured */
34         bool collecting_aging_again;
35
36         /* GC start time, for benchmarking */
37         u64 start_time;
38
39         jmp_buf gc_unwind;
40
41         explicit gc_state(data_heap *data_, bool growing_data_heap_, cell collecting_gen_);
42         ~gc_state();
43
44         inline bool collecting_nursery_p()
45         {
46                 return collecting_gen == nursery_gen;
47         }
48
49         inline bool collecting_aging_p()
50         {
51                 return collecting_gen == aging_gen;
52         }
53
54         inline bool collecting_tenured_p()
55         {
56                 return collecting_gen == tenured_gen;
57         }
58
59         inline bool collecting_accumulation_gen_p()
60         {
61                 return ((collecting_aging_p() && !collecting_aging_again)
62                         || collecting_tenured_p());
63         }
64 };
65
66 VM_C_API void inline_gc(cell *gc_roots_base, cell gc_roots_size, factor_vm *myvm);
67
68 }