]> gitweb.factorcode.org Git - factor.git/blob - vm/code_heap.hpp
vm: verify code heap's all_blocks set when DEBUG
[factor.git] / vm / code_heap.hpp
1 namespace factor
2 {
3
4 #if defined(WINDOWS) && defined(FACTOR_64)
5         const cell seh_area_size = 1024;
6 #else
7         const cell seh_area_size = 0;
8 #endif
9
10 struct compaction_fixup;
11
12 struct code_heap {
13         /* The actual memory area */
14         segment *seg;
15
16         /* Memory area reserved for safepoint guard page */
17         void *safepoint_page;
18
19         /* Memory area reserved for SEH. Only used on Windows */
20         char *seh_area;
21
22         /* Memory allocator */
23         free_list_allocator<code_block> *allocator;
24
25         std::set<code_block *> all_blocks;
26
27         /* Keys are blocks which need to be initialized by initialize_code_block().
28         Values are literal tables. Literal table arrays are GC roots until the
29         time the block is initialized, after which point they are discarded. */
30         std::map<code_block *, cell> uninitialized_blocks;
31
32         /* Code blocks which may reference objects in the nursery */
33         std::set<code_block *> points_to_nursery;
34
35         /* Code blocks which may reference objects in aging space or the nursery */
36         std::set<code_block *> points_to_aging;
37
38         explicit code_heap(cell size);
39         ~code_heap();
40         void write_barrier(code_block *compiled);
41         void clear_remembered_set();
42         bool uninitialized_p(code_block *compiled);
43         bool marked_p(code_block *compiled);
44         void set_marked_p(code_block *compiled);
45         void clear_mark_bits();
46         void free(code_block *compiled);
47         void flush_icache();
48         void guard_safepoint();
49         void unguard_safepoint();
50         void verify_all_blocks_set();
51         void initialize_all_blocks_set();
52         void update_all_blocks_set(mark_bits<code_block> *code_forwarding_map);
53
54         code_block *code_block_for_address(cell address);
55
56         bool safepoint_p(cell addr)
57         {
58                 cell page_mask = ~(getpagesize() - 1);
59                 return (addr & page_mask) == (cell)safepoint_page;
60         }
61
62 };
63
64 struct code_heap_room {
65         cell size;
66         cell occupied_space;
67         cell total_free;
68         cell contiguous_free;
69         cell free_block_count;
70 };
71
72 }