VM: renaming verify_memory_protection_error to set_memory_protection_error
and sets the signal_fault_addr and signal_fault_pc in the function.char-rename
parent
65a2281188
commit
a0df88f20b
|
@ -98,17 +98,19 @@ void factor_vm::not_implemented_error() {
|
||||||
general_error(ERROR_NOT_IMPLEMENTED, false_object, false_object);
|
general_error(ERROR_NOT_IMPLEMENTED, false_object, false_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
void factor_vm::verify_memory_protection_error(cell addr) {
|
void factor_vm::set_memory_protection_error(cell fault_addr, cell fault_pc) {
|
||||||
// Called from the OS-specific top halves of the signal handlers to
|
// Called from the OS-specific top halves of the signal handlers to
|
||||||
// make sure it's safe to dispatch to memory_signal_handler_impl.
|
// make sure it's safe to dispatch to memory_signal_handler_impl.
|
||||||
if (fatal_erroring_p)
|
if (fatal_erroring_p)
|
||||||
fa_diddly_atal_error();
|
fa_diddly_atal_error();
|
||||||
if (faulting_p && !code->safepoint_p(addr))
|
if (faulting_p && !code->safepoint_p(fault_addr))
|
||||||
fatal_error("Double fault", addr);
|
fatal_error("Double fault", fault_addr);
|
||||||
else if (fep_p)
|
else if (fep_p)
|
||||||
fatal_error("Memory protection fault during low-level debugger", addr);
|
fatal_error("Memory protection fault during low-level debugger", fault_addr);
|
||||||
else if (atomic::load(¤t_gc_p))
|
else if (atomic::load(¤t_gc_p))
|
||||||
fatal_error("Memory protection fault during gc", addr);
|
fatal_error("Memory protection fault during gc", fault_addr);
|
||||||
|
signal_fault_addr = fault_addr;
|
||||||
|
signal_fault_pc = fault_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocates memory
|
// Allocates memory
|
||||||
|
|
|
@ -36,9 +36,8 @@ void factor_vm::call_fault_handler(exception_type_t exception,
|
||||||
cell handler = 0;
|
cell handler = 0;
|
||||||
|
|
||||||
if (exception == EXC_BAD_ACCESS) {
|
if (exception == EXC_BAD_ACCESS) {
|
||||||
signal_fault_addr = MACH_EXC_STATE_FAULT(exc_state);
|
set_memory_protection_error(MACH_EXC_STATE_FAULT(exc_state),
|
||||||
signal_fault_pc = (cell)MACH_PROGRAM_COUNTER(thread_state);
|
(cell)MACH_PROGRAM_COUNTER(thread_state));
|
||||||
verify_memory_protection_error(signal_fault_addr);
|
|
||||||
handler = (cell)factor::memory_signal_handler_impl;
|
handler = (cell)factor::memory_signal_handler_impl;
|
||||||
} else if (exception == EXC_ARITHMETIC && code != MACH_EXC_INTEGER_DIV) {
|
} else if (exception == EXC_ARITHMETIC && code != MACH_EXC_INTEGER_DIV) {
|
||||||
signal_fpu_status = fpu_status(mach_fpu_status(float_state));
|
signal_fpu_status = fpu_status(mach_fpu_status(float_state));
|
||||||
|
|
|
@ -100,18 +100,11 @@ segment::segment(cell size_, bool executable_p) {
|
||||||
|
|
||||||
segment::~segment() {
|
segment::~segment() {
|
||||||
int pagesize = getpagesize();
|
int pagesize = getpagesize();
|
||||||
int retval = munmap((void*)(start - pagesize), pagesize + size + pagesize);
|
int retval = munmap((void*)(start - pagesize), 2 * pagesize + size);
|
||||||
if (retval)
|
if (retval)
|
||||||
fatal_error("Segment deallocation failed", 0);
|
fatal_error("Segment deallocation failed", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void factor_vm::dispatch_signal(void* uap, void(handler)()) {
|
|
||||||
dispatch_signal_handler((cell*)&UAP_STACK_POINTER(uap),
|
|
||||||
(cell*)&UAP_PROGRAM_COUNTER(uap),
|
|
||||||
(cell)FUNCTION_CODE_POINTER(handler));
|
|
||||||
UAP_SET_TOC_POINTER(uap, (cell)FUNCTION_TOC_POINTER(handler));
|
|
||||||
}
|
|
||||||
|
|
||||||
void factor_vm::start_sampling_profiler_timer() {
|
void factor_vm::start_sampling_profiler_timer() {
|
||||||
struct itimerval timer;
|
struct itimerval timer;
|
||||||
memset((void*)&timer, 0, sizeof(struct itimerval));
|
memset((void*)&timer, 0, sizeof(struct itimerval));
|
||||||
|
@ -126,14 +119,19 @@ void factor_vm::end_sampling_profiler_timer() {
|
||||||
setitimer(ITIMER_REAL, &timer, NULL);
|
setitimer(ITIMER_REAL, &timer, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void factor_vm::dispatch_signal(void* uap, void(handler)()) {
|
||||||
|
dispatch_signal_handler((cell*)&UAP_STACK_POINTER(uap),
|
||||||
|
(cell*)&UAP_PROGRAM_COUNTER(uap),
|
||||||
|
(cell)FUNCTION_CODE_POINTER(handler));
|
||||||
|
UAP_SET_TOC_POINTER(uap, (cell)FUNCTION_TOC_POINTER(handler));
|
||||||
|
}
|
||||||
|
|
||||||
void memory_signal_handler(int signal, siginfo_t* siginfo, void* uap) {
|
void memory_signal_handler(int signal, siginfo_t* siginfo, void* uap) {
|
||||||
|
|
||||||
cell fault_addr = (cell)siginfo->si_addr;
|
cell fault_addr = (cell)siginfo->si_addr;
|
||||||
cell fault_pc = (cell)UAP_PROGRAM_COUNTER(uap);
|
cell fault_pc = (cell)UAP_PROGRAM_COUNTER(uap);
|
||||||
factor_vm* vm = current_vm();
|
factor_vm* vm = current_vm();
|
||||||
vm->verify_memory_protection_error(fault_addr);
|
vm->set_memory_protection_error(fault_addr, fault_pc);
|
||||||
vm->signal_fault_addr = fault_addr;
|
|
||||||
vm->signal_fault_pc = fault_pc;
|
|
||||||
vm->dispatch_signal(uap, factor::memory_signal_handler_impl);
|
vm->dispatch_signal(uap, factor::memory_signal_handler_impl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,9 +196,7 @@ LONG factor_vm::exception_handler(PEXCEPTION_RECORD e, void* frame, PCONTEXT c,
|
||||||
void* dispatch) {
|
void* dispatch) {
|
||||||
switch (e->ExceptionCode) {
|
switch (e->ExceptionCode) {
|
||||||
case EXCEPTION_ACCESS_VIOLATION:
|
case EXCEPTION_ACCESS_VIOLATION:
|
||||||
signal_fault_addr = e->ExceptionInformation[1];
|
set_memory_protection_error(e->ExceptionInformation[1], c->EIP);
|
||||||
signal_fault_pc = c->EIP;
|
|
||||||
verify_memory_protection_error(signal_fault_addr);
|
|
||||||
dispatch_signal_handler((cell*)&c->ESP, (cell*)&c->EIP,
|
dispatch_signal_handler((cell*)&c->ESP, (cell*)&c->EIP,
|
||||||
(cell)factor::memory_signal_handler_impl);
|
(cell)factor::memory_signal_handler_impl);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -199,7 +199,7 @@ struct factor_vm {
|
||||||
void general_error(vm_error_type error, cell arg1, cell arg2);
|
void general_error(vm_error_type error, cell arg1, cell arg2);
|
||||||
void type_error(cell type, cell tagged);
|
void type_error(cell type, cell tagged);
|
||||||
void not_implemented_error();
|
void not_implemented_error();
|
||||||
void verify_memory_protection_error(cell addr);
|
void set_memory_protection_error(cell fault_addr, cell fault_pc);
|
||||||
void divide_by_zero_error();
|
void divide_by_zero_error();
|
||||||
void primitive_unimplemented();
|
void primitive_unimplemented();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue