factor/vm/code_heap.hpp

69 lines
1.7 KiB
C++
Raw Normal View History

2013-05-11 21:51:54 -04:00
namespace factor {
#if defined(WINDOWS) && defined(FACTOR_64)
2013-05-11 21:51:54 -04:00
const cell seh_area_size = 1024;
#else
2013-05-11 21:51:54 -04:00
const cell seh_area_size = 0;
#endif
struct code_heap {
2013-05-11 21:51:54 -04:00
/* The actual memory area */
segment* seg;
2013-05-11 21:51:54 -04:00
/* Memory area reserved for safepoint guard page */
void* safepoint_page;
2013-05-11 21:51:54 -04:00
/* Memory area reserved for SEH. Only used on Windows */
char* seh_area;
2013-05-11 21:51:54 -04:00
/* Memory allocator */
free_list_allocator<code_block>* allocator;
2013-05-11 21:51:54 -04:00
std::set<cell> all_blocks;
2013-05-11 21:51:54 -04:00
/* Keys are blocks which need to be initialized by initialize_code_block().
Values are literal tables. Literal table arrays are GC roots until the
time the block is initialized, after which point they are discarded. */
std::map<code_block*, cell> uninitialized_blocks;
2013-05-11 21:51:54 -04:00
/* Code blocks which may reference objects in the nursery */
std::set<code_block*> points_to_nursery;
2013-05-11 21:51:54 -04:00
/* Code blocks which may reference objects in aging space or the nursery */
std::set<code_block*> points_to_aging;
2013-05-11 21:51:54 -04:00
explicit code_heap(cell size);
~code_heap();
void write_barrier(code_block* compiled);
void clear_remembered_set();
bool uninitialized_p(code_block* compiled);
bool marked_p(code_block* compiled);
void set_marked_p(code_block* compiled);
void clear_mark_bits();
void free(code_block* compiled);
void flush_icache();
void guard_safepoint();
void unguard_safepoint();
void verify_all_blocks_set();
void initialize_all_blocks_set();
2013-05-11 21:51:54 -04:00
void sweep();
2013-05-11 21:51:54 -04:00
code_block* code_block_for_address(cell address);
2013-05-11 21:51:54 -04:00
bool safepoint_p(cell addr) {
cell page_mask = ~(getpagesize() - 1);
return (addr & page_mask) == (cell) safepoint_page;
}
};
struct code_heap_room {
2013-05-11 21:51:54 -04:00
cell size;
cell occupied_space;
cell total_free;
cell contiguous_free;
cell free_block_count;
};
2009-05-04 02:46:13 -04:00
}