From: John Benediktsson Date: Fri, 14 Aug 2020 17:27:18 +0000 (-0700) Subject: vm: change some bools from cell to bool. X-Git-Tag: 0.99~3124 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=f21deee3df3858cb98a8734d369a9f8830155347 vm: change some bools from cell to bool. --- diff --git a/vm/atomic.hpp b/vm/atomic.hpp index a8b2723720..081b3b5401 100644 --- a/vm/atomic.hpp +++ b/vm/atomic.hpp @@ -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(); diff --git a/vm/sampling_profiler.cpp b/vm/sampling_profiler.cpp index 4a36ccb7c1..d7bb06677a 100644 --- a/vm/sampling_profiler.cpp +++ b/vm/sampling_profiler.cpp @@ -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) diff --git a/vm/vm.hpp b/vm/vm.hpp index 5ef2443f5e..ba92de3592 100644 --- 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;