Skip to content

Commit

Permalink
VM: removes the signal_handler_impl methods from factor_vm
Browse files Browse the repository at this point in the history
Instead the code is in the functions with the same name. That way, they
don't need to exist both as functions and methods.
  • Loading branch information
bjourne committed Jun 29, 2016
1 parent 880d43d commit 801c70e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 28 deletions.
45 changes: 20 additions & 25 deletions vm/errors.cpp
Expand Up @@ -121,45 +121,40 @@ void factor_vm::divide_by_zero_error() {
void factor_vm::primitive_unimplemented() { not_implemented_error(); }

/* Allocates memory */
void factor_vm::memory_signal_handler_impl() {
if (code->safepoint_p(signal_fault_addr)) {
safepoint.handle_safepoint(this, signal_fault_pc);
void memory_signal_handler_impl() {
factor_vm* vm = current_vm();
if (vm->code->safepoint_p(vm->signal_fault_addr)) {
vm->safepoint.handle_safepoint(vm, vm->signal_fault_pc);
}
else {
vm_error_type type = ctx->address_to_error(signal_fault_addr);
cell number = from_unsigned_cell(signal_fault_addr);
general_error(type, number, false_object);
vm_error_type type = vm->ctx->address_to_error(vm->signal_fault_addr);
cell number = vm->from_unsigned_cell(vm->signal_fault_addr);
vm->general_error(type, number, false_object);
}
if (!signal_resumable) {
if (!vm->signal_resumable) {
/* In theory we should only get here if the callstack overflowed during a
safepoint */
general_error(ERROR_CALLSTACK_OVERFLOW, false_object, false_object);
vm->general_error(ERROR_CALLSTACK_OVERFLOW, false_object, false_object);
}
}

/* Allocates memory */
void memory_signal_handler_impl() {
current_vm()->memory_signal_handler_impl();
}

/* Allocates memory */
void factor_vm::synchronous_signal_handler_impl() {
general_error(ERROR_SIGNAL, from_unsigned_cell(signal_number), false_object);
void synchronous_signal_handler_impl() {
factor_vm* vm = current_vm();
vm->general_error(ERROR_SIGNAL,
vm->from_unsigned_cell(vm->signal_number),
false_object);
}

/* Allocates memory */
void synchronous_signal_handler_impl() {
current_vm()->synchronous_signal_handler_impl();
}
void fp_signal_handler_impl() {
factor_vm* vm = current_vm();

/* Allocates memory (fp_trap_error())*/
void factor_vm::fp_signal_handler_impl() {
/* Clear pending exceptions to avoid getting stuck in a loop */
set_fpu_state(get_fpu_state());
vm->set_fpu_state(vm->get_fpu_state());

general_error(ERROR_FP_TRAP, tag_fixnum(signal_fpu_status), false_object);
vm->general_error(ERROR_FP_TRAP,
tag_fixnum(vm->signal_fpu_status),
false_object);
}

/* Allocates memory */
void fp_signal_handler_impl() { current_vm()->fp_signal_handler_impl(); }
}
3 changes: 0 additions & 3 deletions vm/vm.hpp
Expand Up @@ -202,9 +202,6 @@ struct factor_vm {
void verify_memory_protection_error(cell addr);
void divide_by_zero_error();
void primitive_unimplemented();
void memory_signal_handler_impl();
void synchronous_signal_handler_impl();
void fp_signal_handler_impl();

// bignum
int bignum_equal_p(bignum* x, bignum* y);
Expand Down

0 comments on commit 801c70e

Please sign in to comment.