vm: code_heap::(un)guard_safepoint methods

db4
Joe Groff 2011-10-17 13:46:25 -07:00
parent 4c8dec1e98
commit 99804d5e3f
3 changed files with 28 additions and 0 deletions

View File

@ -41,6 +41,8 @@ struct code_heap {
void clear_mark_bits(); void clear_mark_bits();
void free(code_block *compiled); void free(code_block *compiled);
void flush_icache(); void flush_icache();
void guard_safepoint();
void unguard_safepoint();
}; };
struct code_heap_room { struct code_heap_room {

View File

@ -124,6 +124,18 @@ segment::~segment()
fatal_error("Segment deallocation failed",0); fatal_error("Segment deallocation failed",0);
} }
void code_heap::guard_safepoint()
{
if(mprotect(safepoint_page,getpagesize(),PROT_NONE) == -1)
fatal_error("Cannot protect safepoint guard page",(cell)safepoint_page);
}
void code_heap::unguard_safepoint()
{
if(mprotect(safepoint_page,getpagesize(),PROT_WRITE) == -1)
fatal_error("Cannot unprotect safepoint guard page",(cell)safepoint_page);
}
void factor_vm::dispatch_signal(void *uap, void (handler)()) void factor_vm::dispatch_signal(void *uap, void (handler)())
{ {
UAP_STACK_POINTER(uap) = (UAP_STACK_POINTER_TYPE)fix_callstack_top((stack_frame *)UAP_STACK_POINTER(uap)); UAP_STACK_POINTER(uap) = (UAP_STACK_POINTER_TYPE)fix_callstack_top((stack_frame *)UAP_STACK_POINTER(uap));

View File

@ -148,6 +148,20 @@ long getpagesize()
return g_pagesize; return g_pagesize;
} }
void code_heap::guard_safepoint()
{
DWORD ignore;
if (!VirtualProtect(safepoint_page, getpagesize(), PAGE_NOACCESS, &ignore))
fatal_error("Cannot protect safepoint guard page", (cell)safepoint_page);
}
void code_heap::unguard_safepoint()
{
DWORD ignore;
if (!VirtualProtect(safepoint_page, getpagesize(), PAGE_READWRITE, &ignore))
fatal_error("Cannot unprotect safepoint guard page", (cell)safepoint_page);
}
void factor_vm::move_file(const vm_char *path1, const vm_char *path2) void factor_vm::move_file(const vm_char *path1, const vm_char *path2)
{ {
if(MoveFileEx((path1),(path2),MOVEFILE_REPLACE_EXISTING) == false) if(MoveFileEx((path1),(path2),MOVEFILE_REPLACE_EXISTING) == false)