]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: change where we set safepoints_fep to false to allow old Ctrl-C behavior.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 2 Nov 2016 02:21:47 +0000 (19:21 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 2 Nov 2016 02:21:47 +0000 (19:21 -0700)
vm/safepoints.cpp
vm/vm.cpp
vm/vm.hpp

index 180074a2d44f673640d58ab65d900be147a4fda6..bdb9cd8eb5d9c1a7a417262e35473b4614554dd3 100644 (file)
@@ -35,7 +35,6 @@ void factor_vm::handle_safepoint(cell pc) {
   faulting_p = false;
 
   if (atomic::load(&safepoint_fep_p)) {
-    atomic::store(&safepoint_fep_p, false);
     if (atomic::load(&sampling_profiler_p))
       end_sampling_profiler();
     std::cout << "Interrupted\n";
@@ -43,10 +42,12 @@ void factor_vm::handle_safepoint(cell pc) {
       /* Ctrl-Break throws an exception, interrupting the main thread, same
          as the "t" command in the factorbug debugger. But for Ctrl-Break to
          work we don't require the debugger to be activated, or even enabled. */
+      atomic::store(&safepoint_fep_p, false);
       general_error(ERROR_INTERRUPT, false_object, false_object);
       FACTOR_ASSERT(false);
     }
     factorbug();
+    atomic::store(&safepoint_fep_p, false);
   } else if (atomic::load(&sampling_profiler_p)) {
     FACTOR_ASSERT(code->seg->in_segment_p(pc));
     code_block* block = code->code_block_for_address(pc);
index 5e9f0209d665092625f153aa8e050dfdaba8e34e..130bdda7c9d88e2f8c89cd502e0755370e8f0837 100644 (file)
--- a/vm/vm.cpp
+++ b/vm/vm.cpp
@@ -10,7 +10,6 @@ factor_vm::factor_vm(THREADHANDLE thread)
 #if defined(WINDOWS)
       thread_id(GetCurrentThreadId()),
       ctrl_break_thread(NULL),
-      stop_on_ctrl_break(false),
 #endif
       callback_id(0),
       c_to_factor_func(NULL),
@@ -30,7 +29,8 @@ factor_vm::factor_vm(THREADHANDLE thread)
       full_output(false),
       last_nano_count(0),
       signal_callstack_seg(NULL),
-      safepoint_fep_p(false) {
+      safepoint_fep_p(false),
+      stop_on_ctrl_break(false) {
   primitive_reset_dispatch_stats();
 }
 
index df45b83d65b12919f08dc4a4a783d01241f52d5b..e2a7872e412935466819202d163b1a6e977d059e 100644 (file)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -149,6 +149,9 @@ struct factor_vm {
   // Two fep_p variants, one might be redundant.
   volatile cell safepoint_fep_p;
 
+  // Allow Ctrl-Break a busy loop in the Listener, only used on Windows
+  volatile bool stop_on_ctrl_break;
+
   // contexts
   context* new_context();
   void init_context(context* ctx);
@@ -395,7 +398,6 @@ struct factor_vm {
   void primitive_die();
   void primitive_enable_ctrl_break();
   void primitive_disable_ctrl_break();
-  volatile bool stop_on_ctrl_break;
 
   // arrays
   inline void set_array_nth(array* array, cell slot, cell value);