]> gitweb.factorcode.org Git - factor.git/blob - vm/gc_info.hpp
VM: Replace u8-64, s8-64, cell, fixnum with stdint.h equivalents
[factor.git] / vm / gc_info.hpp
1 namespace factor {
2
3 struct gc_info {
4   uint32_t scrub_d_count;
5   uint32_t scrub_r_count;
6   uint32_t gc_root_count;
7   uint32_t derived_root_count;
8   uint32_t return_address_count;
9
10   cell callsite_bitmap_size() {
11     return scrub_d_count + scrub_r_count + gc_root_count;
12   }
13
14   cell total_bitmap_size() {
15     return return_address_count * callsite_bitmap_size();
16   }
17
18   cell total_bitmap_bytes() { return ((total_bitmap_size() + 7) / 8); }
19
20   uint32_t* return_addresses() {
21     return (uint32_t*)this - return_address_count;
22   }
23
24   uint32_t* base_pointer_map() {
25     return return_addresses() - return_address_count * derived_root_count;
26   }
27
28   uint8_t* gc_info_bitmap() {
29     return (uint8_t*)base_pointer_map() - total_bitmap_bytes();
30   }
31
32   cell callsite_scrub_d(cell index) { return index * scrub_d_count; }
33
34   cell callsite_scrub_r(cell index) {
35     return return_address_count * scrub_d_count + index * scrub_r_count;
36   }
37
38   cell callsite_gc_roots(cell index) {
39     return return_address_count * scrub_d_count +
40            return_address_count * scrub_r_count + index * gc_root_count;
41   }
42
43   uint32_t lookup_base_pointer(cell index, cell derived_root) {
44     return base_pointer_map()[index * derived_root_count + derived_root];
45   }
46
47   cell return_address_index(cell return_address);
48 };
49
50 }