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