PageRenderTime 23ms CodeModel.GetById 13ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/vm/gc_info.hpp

http://github.com/abeaumont/factor
C++ Header | 67 lines | 54 code | 13 blank | 0 comment | 0 complexity | fe32d5c9ad8fa5f2b77db372bebd5556 MD5 | raw file
 1namespace factor
 2{
 3
 4struct gc_info {
 5	u32 scrub_d_count;
 6	u32 scrub_r_count;
 7	u32 gc_root_count;
 8	u32 derived_root_count;
 9	u32 return_address_count;
10
11	cell callsite_bitmap_size()
12	{
13		return scrub_d_count + scrub_r_count + gc_root_count;
14	}
15
16	cell total_bitmap_size()
17	{
18		return return_address_count * callsite_bitmap_size();
19	}
20
21	cell total_bitmap_bytes()
22	{
23		return ((total_bitmap_size() + 7) / 8);
24	}
25
26	u32 *return_addresses()
27	{
28		return (u32 *)this - return_address_count;
29	}
30
31	u32 *base_pointer_map()
32	{
33		return return_addresses() - return_address_count * derived_root_count;
34	}
35
36	u8 *gc_info_bitmap()
37	{
38		return (u8 *)base_pointer_map() - total_bitmap_bytes();
39	}
40
41	cell callsite_scrub_d(cell index)
42	{
43		return index * scrub_d_count;
44	}
45
46	cell callsite_scrub_r(cell index)
47	{
48		return return_address_count * scrub_d_count +
49			index * scrub_r_count;
50	}
51
52	cell callsite_gc_roots(cell index)
53	{
54		return return_address_count * scrub_d_count
55			+ return_address_count * scrub_r_count
56			+ index * gc_root_count;
57	}
58
59	u32 lookup_base_pointer(cell index, cell derived_root)
60	{
61		return base_pointer_map()[index * derived_root_count + derived_root];
62	}
63
64	cell return_address_index(cell return_address);
65};
66
67}