]> gitweb.factorcode.org Git - factor.git/blob - vm/gc.hpp
vm: get GC events working, -verbosegc switch now produces more info
[factor.git] / vm / gc.hpp
1 namespace factor
2 {
3
4 enum gc_op {
5         collect_nursery_op,
6         collect_aging_op,
7         collect_to_tenured_op,
8         collect_full_op,
9         collect_compact_op,
10         collect_growing_heap_op
11 };
12
13 struct gc_event {
14         gc_op op;
15         cell nursery_size_before;
16         cell aging_size_before;
17         cell tenured_size_before;
18         cell tenured_free_block_count_before;
19         cell code_size_before;
20         cell code_free_block_count_before;
21         cell nursery_size_after;
22         cell aging_size_after;
23         cell tenured_size_after;
24         cell tenured_free_block_count_after;
25         cell code_size_after;
26         cell code_free_block_count_after;
27         cell cards_scanned;
28         cell decks_scanned;
29         cell code_blocks_scanned;
30         u64 start_time;
31         cell total_time;
32         cell card_scan_time;
33         cell code_scan_time;
34         cell data_sweep_time;
35         cell code_sweep_time;
36         cell compaction_time;
37
38         explicit gc_event(gc_op op_, factor_vm *parent);
39         void started_card_scan();
40         void ended_card_scan(cell cards_scanned_, cell decks_scanned_);
41         void started_code_scan();
42         void ended_code_scan(cell code_blocks_scanned_);
43         void started_data_sweep();
44         void ended_data_sweep();
45         void started_code_sweep();
46         void ended_code_sweep();
47         void started_compaction();
48         void ended_compaction();
49         void ended_gc(factor_vm *parent);
50 };
51
52 struct gc_state {
53         gc_op op;
54         u64 start_time;
55         jmp_buf gc_unwind;
56         gc_event *event;
57
58         explicit gc_state(gc_op op_, factor_vm *parent);
59         ~gc_state();
60         void start_again(gc_op op_, factor_vm *parent);
61 };
62
63 VM_C_API void inline_gc(cell *gc_roots_base, cell gc_roots_size, factor_vm *parent);
64
65 }