]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: change some bools from cell to bool.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 14 Aug 2020 17:27:18 +0000 (10:27 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 14 Aug 2020 17:27:18 +0000 (10:27 -0700)
vm/atomic.hpp
vm/sampling_profiler.cpp
vm/vm.hpp

index a8b27237207f0c1db7a19f16aa14930aee2403a9..081b3b54019211192d85ab931c3e5afa205ee9b8 100644 (file)
@@ -1,5 +1,9 @@
 namespace factor {
 namespace atomic {
+FACTOR_FORCE_INLINE static bool load(volatile bool* ptr) {
+  atomic::fence();
+  return *ptr;
+}
 FACTOR_FORCE_INLINE static cell load(volatile cell* ptr) {
   atomic::fence();
   return *ptr;
@@ -10,6 +14,11 @@ FACTOR_FORCE_INLINE static fixnum load(volatile fixnum* ptr) {
   return *ptr;
 }
 
+FACTOR_FORCE_INLINE static void store(volatile bool* ptr, bool val) {
+  *ptr = val;
+  atomic::fence();
+}
+
 FACTOR_FORCE_INLINE static void store(volatile cell* ptr, cell val) {
   *ptr = val;
   atomic::fence();
index 4a36ccb7c1864118e182966a1ec88b2e71f59d08..d7bb06677a7d9418e719104f47566ba870d863ae 100644 (file)
@@ -93,7 +93,7 @@ void factor_vm::record_sample(bool prolog_p) {
 }
 
 void factor_vm::set_sampling_profiler(fixnum rate) {
-  bool running_p = (atomic::load(&sampling_profiler_p) != 0);
+  bool running_p = atomic::load(&sampling_profiler_p);
   if (rate > 0 && !running_p)
     start_sampling_profiler(rate);
   else if (rate == 0 && running_p)
index 5ef2443f5e0454d832ea7bc00fbc81b8cd50b36e..ba92de3592225af5051310e6d647f2a52bc09aa5 100644 (file)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -35,7 +35,7 @@ struct factor_vm {
   cell signal_handler_addr;
 
   // are we handling a memory error? used to detect double faults
-  cell faulting_p;
+  bool faulting_p;
 
   // Various special objects, accessed by special-object and
   // set-special-object primitives
@@ -70,7 +70,7 @@ struct factor_vm {
   c_to_factor_func_type c_to_factor_func;
 
   // Is profiling enabled?
-  volatile cell sampling_profiler_p;
+  volatile bool sampling_profiler_p;
   fixnum samples_per_second;
 
   // Global variables used to pass fault handler state from signal handler
@@ -102,7 +102,7 @@ struct factor_vm {
 
   // Only set if we're performing a GC
   gc_state* current_gc;
-  volatile cell current_gc_p;
+  volatile bool current_gc_p;
 
   // Set if we're in the jit
   volatile fixnum current_jit_count;
@@ -146,7 +146,7 @@ struct factor_vm {
   static bool fatal_erroring_p;
 
   // Two fep_p variants, one might be redundant.
-  volatile cell safepoint_fep_p;
+  volatile bool safepoint_fep_p;
 
   // Allow Ctrl-Break a busy loop in the Listener, only used on Windows
   volatile bool stop_on_ctrl_break;