]> gitweb.factorcode.org Git - factor.git/blob - vm/code_heap.hpp
help.html: making search box have first tab index
[factor.git] / vm / code_heap.hpp
1 namespace factor {
2
3 #if defined(WINDOWS) && defined(FACTOR_64)
4 const cell seh_area_size = 1024;
5 #else
6 const cell seh_area_size = 0;
7 #endif
8
9 struct code_heap {
10   // The actual memory area
11   segment* seg;
12
13   // Memory area reserved for safepoint guard page
14   cell safepoint_page;
15
16   // Memory area reserved for SEH. Only used on Windows
17   char* seh_area;
18
19   // Memory allocator
20   free_list_allocator<code_block>* allocator;
21
22   // For fast lookup of blocks from addresses.
23   std::set<cell> all_blocks;
24
25
26   // Code blocks are initialized in two steps in
27   // primitive_modify_code_heap() because they might reference each
28   // other. First they are all allocated and placed in this map with
29   // their literal tables which are GC roots until the block is
30   // initialized. Then they are all initialized by
31   // initialize_code_block() which resolves relocations and updates
32   // addresses. Uninitialized blocks instructions must not be visited
33   // by GC.
34   std::map<code_block*, cell> uninitialized_blocks;
35
36   // Code blocks which may reference objects in the nursery
37   std::set<code_block*> points_to_nursery;
38
39   // Code blocks which may reference objects in aging space or the nursery
40   std::set<code_block*> points_to_aging;
41
42   explicit code_heap(cell size);
43   ~code_heap();
44   void write_barrier(code_block* compiled);
45   void clear_remembered_set();
46   bool uninitialized_p(code_block* compiled);
47   void free(code_block* compiled);
48   void flush_icache();
49   void set_safepoint_guard(bool locked);
50   void verify_all_blocks_set();
51   void initialize_all_blocks_set();
52   cell high_water_mark() { return allocator->size / 20; }
53
54   void sweep();
55
56   code_block* code_block_for_address(cell address);
57   cell frame_predecessor(cell frame_top);
58
59   bool safepoint_p(cell addr) {
60     cell page_mask = ~(getpagesize() - 1);
61     return (addr & page_mask) == safepoint_page;
62   }
63 };
64
65 }