]> gitweb.factorcode.org Git - factor.git/commitdiff
VM: merge memory_protection_error() with memory_signal_handler_impl()
authorBjörn Lindqvist <bjourne@gmail.com>
Mon, 24 Aug 2015 07:47:36 +0000 (09:47 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 24 Aug 2015 14:23:40 +0000 (07:23 -0700)
vm/errors.cpp
vm/vm.hpp

index 62e30dbbb6715b30e3ca230b7faab4bab75cbde9..3de6945435e270411be6e9e96e4cfe3619ae5cce 100644 (file)
@@ -102,7 +102,7 @@ void factor_vm::not_implemented_error() {
 
 void factor_vm::verify_memory_protection_error(cell addr) {
   /* Called from the OS-specific top halves of the signal handlers to
-     make sure it's safe to dispatch to memory_protection_error */
+     make sure it's safe to dispatch to memory_signal_handler_impl. */
   if (fatal_erroring_p)
     fa_diddly_atal_error();
   if (faulting_p && !code->safepoint_p(addr))
@@ -113,16 +113,6 @@ void factor_vm::verify_memory_protection_error(cell addr) {
     fatal_error("Memory protection fault during gc", addr);
 }
 
-/* Allocates memory */
-void factor_vm::memory_protection_error(cell pc, cell addr) {
-  if (code->safepoint_p(addr))
-    safepoint.handle_safepoint(this, pc);
-  else {
-    vm_error_type type = ctx->address_to_error(addr);
-    general_error(type, from_unsigned_cell(addr), false_object);
-  }
-}
-
 /* Allocates memory */
 void factor_vm::divide_by_zero_error() {
   general_error(ERROR_DIVIDE_BY_ZERO, false_object, false_object);
@@ -134,7 +124,14 @@ void factor_vm::primitive_unimplemented() { not_implemented_error(); }
 
 /* Allocates memory */
 void factor_vm::memory_signal_handler_impl() {
-  memory_protection_error(signal_fault_pc, signal_fault_addr);
+  if (code->safepoint_p(signal_fault_addr)) {
+    safepoint.handle_safepoint(this, 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);
+  }
   if (!signal_resumable) {
     /* In theory we should only get here if the callstack overflowed during a
        safepoint */
index ea6419f9ebbff2e94ad193af1ca29754e59b1a99..e33831035a46b180e57c815bbd1249263ecfadab 100644 (file)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -215,7 +215,6 @@ struct factor_vm {
   void type_error(cell type, cell tagged);
   void not_implemented_error();
   void verify_memory_protection_error(cell addr);
-  void memory_protection_error(cell pc, cell addr);
   void divide_by_zero_error();
   void primitive_unimplemented();
   void memory_signal_handler_impl();