]> gitweb.factorcode.org Git - factor.git/blob - vm/gc_info.hpp
VM: use the check_d and check_r to trace the overinitialized stack locations
[factor.git] / vm / gc_info.hpp
1 namespace factor {
2
3 // gc_info should be kept in sync with:
4 //   core/vm/vm.factor
5
6 struct gc_info {
7   uint32_t scrub_d_count;
8   uint32_t scrub_r_count;
9   uint32_t check_d_count;
10   uint32_t check_r_count;
11   uint32_t gc_root_count;
12   uint32_t derived_root_count;
13   uint32_t return_address_count;
14
15   cell callsite_bitmap_size() {
16     return
17         scrub_d_count +
18         scrub_r_count +
19         check_d_count +
20         check_r_count +
21         gc_root_count;
22   }
23
24   cell total_bitmap_size() {
25     return return_address_count * callsite_bitmap_size();
26   }
27
28   cell total_bitmap_bytes() { return ((total_bitmap_size() + 7) / 8); }
29
30   uint32_t* return_addresses() {
31     return (uint32_t*)this - return_address_count;
32   }
33
34   uint32_t* base_pointer_map() {
35     return return_addresses() - return_address_count * derived_root_count;
36   }
37
38   uint8_t* gc_info_bitmap() {
39     return (uint8_t*)base_pointer_map() - total_bitmap_bytes();
40   }
41
42   cell callsite_scrub_d(cell index) {
43     cell base = 0;
44     return base + index * scrub_d_count;
45   }
46
47   cell callsite_scrub_r(cell index) {
48     cell base = return_address_count * scrub_d_count;
49     return base + index * scrub_r_count;
50   }
51
52   cell callsite_check_d(cell index) {
53     cell base =
54         return_address_count * scrub_d_count +
55         return_address_count * scrub_r_count;
56     return base + index * check_d_count;
57   }
58
59   cell callsite_check_r(cell index) {
60     cell base =
61         return_address_count * scrub_d_count +
62         return_address_count * scrub_r_count +
63         return_address_count * check_d_count;
64     return base + index + check_r_count;
65   }
66
67   cell callsite_gc_roots(cell index) {
68     cell base =
69         return_address_count * scrub_d_count +
70         return_address_count * scrub_r_count +
71         return_address_count * check_d_count +
72         return_address_count * check_r_count;
73     return base + index * gc_root_count;
74   }
75
76   uint32_t lookup_base_pointer(cell index, cell derived_root) {
77     return base_pointer_map()[index * derived_root_count + derived_root];
78   }
79
80   cell return_address_index(cell return_address);
81 };
82
83 }