Ejemplo n.º 1
0
void memory_signal_handler(int signal, siginfo_t* siginfo, void* uap) {
  factor_vm* vm = current_vm();
  vm->verify_memory_protection_error((cell)siginfo->si_addr);
  vm->signal_fault_addr = (cell)siginfo->si_addr;
  vm->signal_fault_pc = (cell)UAP_PROGRAM_COUNTER(uap);
  vm->dispatch_signal(uap, factor::memory_signal_handler_impl);
}
Ejemplo n.º 2
0
void critical_error(const char* msg, cell tagged) {
  std::cout << "You have triggered a bug in Factor. Please report.\n";
  std::cout << "critical_error: " << msg;
  std::cout << ": " << std::hex << tagged << std::dec;
  std::cout << std::endl;
  current_vm()->factorbug();
}
Ejemplo n.º 3
0
// Allocates memory
void fp_signal_handler_impl() {
    factor_vm* vm = current_vm();

    // Clear pending exceptions to avoid getting stuck in a loop
    vm->set_fpu_state(vm->get_fpu_state());

    vm->general_error(ERROR_FP_TRAP,
                      tag_fixnum(vm->signal_fpu_status),
                      false_object);
}
Ejemplo n.º 4
0
void fpe_signal_handler(int signal, siginfo_t* siginfo, void* uap) {
  factor_vm* vm = current_vm();
  vm->signal_number = signal;
  vm->signal_fpu_status = fpu_status(uap_fpu_status(uap));
  uap_clear_fpu_status(uap);

  vm->dispatch_signal(
      uap, (siginfo->si_code == FPE_INTDIV || siginfo->si_code == FPE_INTOVF)
               ? factor::synchronous_signal_handler_impl
               : factor::fp_signal_handler_impl);
}
Ejemplo n.º 5
0
void fatal_error(const char* msg, cell tagged) {
  if (factor_vm::fatal_erroring_p)
    fa_diddly_atal_error();

  factor_vm::fatal_erroring_p = true;

  std::cout << "fatal_error: " << msg;
  std::cout << ": " << (void*)tagged;
  std::cout << std::endl << std::endl;
  factor_vm* vm = current_vm();
  if (vm->data) {
    vm->dump_memory_layout(std::cout);
  }
  abort();
}
Ejemplo n.º 6
0
// Allocates memory
void memory_signal_handler_impl() {
    factor_vm* vm = current_vm();
    if (vm->code->safepoint_p(vm->signal_fault_addr)) {
        vm->handle_safepoint(vm->signal_fault_pc);
    }
    else {
        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 (!vm->signal_resumable) {
        // In theory we should only get here if the callstack overflowed during a
        // safepoint
        vm->general_error(ERROR_CALLSTACK_OVERFLOW, false_object, false_object);
    }
}
Ejemplo n.º 7
0
/* Allocates memory */
void fp_signal_handler_impl() { current_vm()->fp_signal_handler_impl(); }
Ejemplo n.º 8
0
/* Allocates memory */
void synchronous_signal_handler_impl() {
  current_vm()->synchronous_signal_handler_impl();
}
Ejemplo n.º 9
0
/* Allocates memory */
void memory_signal_handler_impl() {
  current_vm()->memory_signal_handler_impl();
}
Ejemplo n.º 10
0
// Allocates memory
void synchronous_signal_handler_impl() {
    factor_vm* vm = current_vm();
    vm->general_error(ERROR_SIGNAL,
                      vm->from_unsigned_cell(vm->signal_number),
                      false_object);
}
Ejemplo n.º 11
0
void undefined_symbol()
{
	return current_vm()->undefined_symbol();
}
Ejemplo n.º 12
0
void misc_signal_handler(int signal, siginfo_t *siginfo, void *uap)
{
	factor_vm *vm = current_vm();
	vm->signal_number = signal;
	vm->dispatch_signal(uap,factor::misc_signal_handler_impl);
}
Ejemplo n.º 13
0
void memory_signal_handler(int signal, siginfo_t *siginfo, void *uap)
{
	factor_vm *vm = current_vm();
	vm->signal_fault_addr = (cell)siginfo->si_addr;
	vm->dispatch_signal(uap,factor::memory_signal_handler_impl);
}
Ejemplo n.º 14
0
VM_C_API LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch)
{
	return current_vm()->exception_handler(e,frame,c,dispatch);
}
Ejemplo n.º 15
0
void out_of_memory()
{
	std::cout << "Out of memory\n\n";
	current_vm()->dump_generations();
	abort();
}