vm: Remove signal_callstack_top nonsense
parent
1818bcb780
commit
d74817cedf
|
@ -127,9 +127,9 @@ void factor_vm::set_frame_offset(stack_frame *frame, cell offset)
|
|||
FRAME_RETURN_ADDRESS(frame,this) = entry_point + offset;
|
||||
}
|
||||
|
||||
void factor_vm::scrub_return_address(stack_frame *callstack_top)
|
||||
void factor_vm::scrub_return_address()
|
||||
{
|
||||
stack_frame *top = callstack_top;
|
||||
stack_frame *top = ctx->callstack_top;
|
||||
stack_frame *bottom = ctx->callstack_bottom;
|
||||
stack_frame *frame = bottom - 1;
|
||||
|
||||
|
|
|
@ -27,10 +27,8 @@ void out_of_memory()
|
|||
exit(1);
|
||||
}
|
||||
|
||||
void factor_vm::throw_error(cell error, stack_frame *stack)
|
||||
void factor_vm::throw_error(cell error)
|
||||
{
|
||||
assert(stack);
|
||||
|
||||
/* If the error handler is set, we rewind any C stack frames and
|
||||
pass the error to user-space. */
|
||||
if(!current_gc && to_boolean(special_objects[ERROR_HANDLER_QUOT]))
|
||||
|
@ -49,7 +47,8 @@ void factor_vm::throw_error(cell error, stack_frame *stack)
|
|||
|
||||
ctx->push(error);
|
||||
|
||||
unwind_native_frames(special_objects[ERROR_HANDLER_QUOT],stack);
|
||||
unwind_native_frames(special_objects[ERROR_HANDLER_QUOT],
|
||||
ctx->callstack_top);
|
||||
}
|
||||
/* Error was thrown in early startup before error handler is set, just
|
||||
crash. */
|
||||
|
@ -63,16 +62,10 @@ void factor_vm::throw_error(cell error, stack_frame *stack)
|
|||
}
|
||||
}
|
||||
|
||||
void factor_vm::general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *stack)
|
||||
{
|
||||
throw_error(allot_array_4(special_objects[OBJ_ERROR],
|
||||
tag_fixnum(error),arg1,arg2),stack);
|
||||
}
|
||||
|
||||
void factor_vm::general_error(vm_error_type error, cell arg1, cell arg2)
|
||||
{
|
||||
throw_error(allot_array_4(special_objects[OBJ_ERROR],
|
||||
tag_fixnum(error),arg1,arg2),ctx->callstack_top);
|
||||
tag_fixnum(error),arg1,arg2));
|
||||
}
|
||||
|
||||
void factor_vm::type_error(cell type, cell tagged)
|
||||
|
@ -85,29 +78,29 @@ void factor_vm::not_implemented_error()
|
|||
general_error(ERROR_NOT_IMPLEMENTED,false_object,false_object);
|
||||
}
|
||||
|
||||
void factor_vm::memory_protection_error(cell addr, stack_frame *stack)
|
||||
void factor_vm::memory_protection_error(cell addr)
|
||||
{
|
||||
/* Retain and call stack underflows are not supposed to happen */
|
||||
|
||||
if(ctx->datastack_seg->underflow_p(addr))
|
||||
general_error(ERROR_DATASTACK_UNDERFLOW,false_object,false_object,stack);
|
||||
general_error(ERROR_DATASTACK_UNDERFLOW,false_object,false_object);
|
||||
else if(ctx->datastack_seg->overflow_p(addr))
|
||||
general_error(ERROR_DATASTACK_OVERFLOW,false_object,false_object,stack);
|
||||
general_error(ERROR_DATASTACK_OVERFLOW,false_object,false_object);
|
||||
else if(ctx->retainstack_seg->underflow_p(addr))
|
||||
general_error(ERROR_RETAINSTACK_UNDERFLOW,false_object,false_object,stack);
|
||||
general_error(ERROR_RETAINSTACK_UNDERFLOW,false_object,false_object);
|
||||
else if(ctx->retainstack_seg->overflow_p(addr))
|
||||
general_error(ERROR_RETAINSTACK_OVERFLOW,false_object,false_object,stack);
|
||||
general_error(ERROR_RETAINSTACK_OVERFLOW,false_object,false_object);
|
||||
else if(ctx->callstack_seg->underflow_p(addr))
|
||||
general_error(ERROR_CALLSTACK_OVERFLOW,false_object,false_object,stack);
|
||||
general_error(ERROR_CALLSTACK_OVERFLOW,false_object,false_object);
|
||||
else if(ctx->callstack_seg->overflow_p(addr))
|
||||
general_error(ERROR_CALLSTACK_UNDERFLOW,false_object,false_object,stack);
|
||||
general_error(ERROR_CALLSTACK_UNDERFLOW,false_object,false_object);
|
||||
else
|
||||
general_error(ERROR_MEMORY,from_unsigned_cell(addr),false_object,stack);
|
||||
general_error(ERROR_MEMORY,from_unsigned_cell(addr),false_object);
|
||||
}
|
||||
|
||||
void factor_vm::signal_error(cell signal, stack_frame *stack)
|
||||
void factor_vm::signal_error(cell signal)
|
||||
{
|
||||
general_error(ERROR_SIGNAL,from_unsigned_cell(signal),false_object,stack);
|
||||
general_error(ERROR_SIGNAL,from_unsigned_cell(signal),false_object);
|
||||
}
|
||||
|
||||
void factor_vm::divide_by_zero_error()
|
||||
|
@ -115,9 +108,9 @@ void factor_vm::divide_by_zero_error()
|
|||
general_error(ERROR_DIVIDE_BY_ZERO,false_object,false_object);
|
||||
}
|
||||
|
||||
void factor_vm::fp_trap_error(unsigned int fpu_status, stack_frame *stack)
|
||||
void factor_vm::fp_trap_error(unsigned int fpu_status)
|
||||
{
|
||||
general_error(ERROR_FP_TRAP,tag_fixnum(fpu_status),false_object,stack);
|
||||
general_error(ERROR_FP_TRAP,tag_fixnum(fpu_status),false_object);
|
||||
}
|
||||
|
||||
/* For testing purposes */
|
||||
|
@ -128,8 +121,8 @@ void factor_vm::primitive_unimplemented()
|
|||
|
||||
void factor_vm::memory_signal_handler_impl()
|
||||
{
|
||||
scrub_return_address(signal_callstack_top);
|
||||
memory_protection_error(signal_fault_addr,signal_callstack_top);
|
||||
scrub_return_address();
|
||||
memory_protection_error(signal_fault_addr);
|
||||
}
|
||||
|
||||
void memory_signal_handler_impl()
|
||||
|
@ -139,8 +132,8 @@ void memory_signal_handler_impl()
|
|||
|
||||
void factor_vm::misc_signal_handler_impl()
|
||||
{
|
||||
scrub_return_address(signal_callstack_top);
|
||||
signal_error(signal_number,signal_callstack_top);
|
||||
scrub_return_address();
|
||||
signal_error(signal_number);
|
||||
}
|
||||
|
||||
void misc_signal_handler_impl()
|
||||
|
@ -153,8 +146,8 @@ void factor_vm::fp_signal_handler_impl()
|
|||
/* Clear pending exceptions to avoid getting stuck in a loop */
|
||||
set_fpu_state(get_fpu_state());
|
||||
|
||||
scrub_return_address(signal_callstack_top);
|
||||
fp_trap_error(signal_fpu_status,signal_callstack_top);
|
||||
scrub_return_address();
|
||||
fp_trap_error(signal_fpu_status);
|
||||
}
|
||||
|
||||
void fp_signal_handler_impl()
|
||||
|
|
|
@ -37,7 +37,6 @@ void factor_vm::call_fault_handler(
|
|||
{
|
||||
MACH_STACK_POINTER(thread_state) = (cell)fix_callstack_top((stack_frame *)MACH_STACK_POINTER(thread_state));
|
||||
|
||||
signal_callstack_top = (stack_frame *)MACH_STACK_POINTER(thread_state);
|
||||
ctx->callstack_top = (stack_frame *)MACH_STACK_POINTER(thread_state);
|
||||
|
||||
/* Now we point the program counter at the right handler function. */
|
||||
|
|
|
@ -118,7 +118,6 @@ 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_PROGRAM_COUNTER(uap) = (cell)handler;
|
||||
|
||||
signal_callstack_top = (stack_frame *)UAP_STACK_POINTER(uap);
|
||||
ctx->callstack_top = (stack_frame *)UAP_STACK_POINTER(uap);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@ void sleep_nanos(u64 nsec)
|
|||
LONG factor_vm::exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch)
|
||||
{
|
||||
c->ESP = (cell)fix_callstack_top((stack_frame *)c->ESP);
|
||||
signal_callstack_top = (stack_frame *)c->ESP;
|
||||
ctx->callstack_top = (stack_frame *)c->ESP;
|
||||
|
||||
switch (e->ExceptionCode)
|
||||
|
|
16
vm/vm.hpp
16
vm/vm.hpp
|
@ -49,12 +49,11 @@ struct factor_vm
|
|||
/* Is call counting enabled? */
|
||||
bool profiling_p;
|
||||
|
||||
/* Global variables used to pass fault handler state from signal handler to
|
||||
user-space */
|
||||
/* Global variables used to pass fault handler state from signal handler
|
||||
to VM */
|
||||
cell signal_number;
|
||||
cell signal_fault_addr;
|
||||
unsigned int signal_fpu_status;
|
||||
stack_frame *signal_callstack_top;
|
||||
|
||||
/* GC is off during heap walking */
|
||||
bool gc_off;
|
||||
|
@ -168,15 +167,14 @@ struct factor_vm
|
|||
void primitive_profiling();
|
||||
|
||||
// errors
|
||||
void throw_error(cell error, stack_frame *stack);
|
||||
void general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *stack);
|
||||
void throw_error(cell error);
|
||||
void general_error(vm_error_type error, cell arg1, cell arg2);
|
||||
void type_error(cell type, cell tagged);
|
||||
void not_implemented_error();
|
||||
void memory_protection_error(cell addr, stack_frame *stack);
|
||||
void signal_error(cell signal, stack_frame *stack);
|
||||
void memory_protection_error(cell addr);
|
||||
void signal_error(cell signal);
|
||||
void divide_by_zero_error();
|
||||
void fp_trap_error(unsigned int fpu_status, stack_frame *stack);
|
||||
void fp_trap_error(unsigned int fpu_status);
|
||||
void primitive_unimplemented();
|
||||
void memory_signal_handler_impl();
|
||||
void misc_signal_handler_impl();
|
||||
|
@ -588,7 +586,7 @@ struct factor_vm
|
|||
cell frame_scan(stack_frame *frame);
|
||||
cell frame_offset(stack_frame *frame);
|
||||
void set_frame_offset(stack_frame *frame, cell offset);
|
||||
void scrub_return_address(stack_frame *callstack_top);
|
||||
void scrub_return_address();
|
||||
void primitive_callstack_to_array();
|
||||
stack_frame *innermost_stack_frame(callstack *stack);
|
||||
void primitive_innermost_stack_frame_executing();
|
||||
|
|
Loading…
Reference in New Issue