Nearly cease use of *PSEUDO-ATOMIC-BITS* static symbol
Some checks are pending
CL-host / ecl (push) Waiting to run
CL-host / clisp (push) Waiting to run
CL-host / ccl (push) Waiting to run
CL-host / cmucl (push) Waiting to run
CL-host / sbcl (push) Waiting to run
CL-host / self (push) Waiting to run
CL-host / compare-xc-host-fasls (ccl, false) (push) Blocked by required conditions
CL-host / compare-xc-host-fasls (clisp, false) (push) Blocked by required conditions
CL-host / compare-xc-host-fasls (cmucl, false) (push) Blocked by required conditions
CL-host / compare-xc-host-fasls (self, false) (push) Blocked by required conditions
Linux / build (x86, --with-sb-thread, ) (push) Waiting to run
Linux / build (x86, --without-sb-thread, ) (push) Waiting to run
Linux / build (x86, --without-sb-unicode, ) (push) Waiting to run
Linux / build (x86-64, --with-mark-region-gc) (push) Waiting to run
Linux / build (x86-64, --with-sb-fasteval --without-sb-eval, fasteval) (push) Waiting to run
Linux / build (x86-64, --with-sb-thread, ) (push) Waiting to run
Linux / build (x86-64, --with-sb-thread, sse4) (push) Waiting to run
Linux / build (x86-64, --without-sb-thread, ) (push) Waiting to run
Linux / build (x86-64, --without-sb-unicode, ) (push) Waiting to run
Mac / build (--without-sb-thread, x86-64) (push) Waiting to run
Mac / build (arm64, --with-mark-region-gc) (push) Waiting to run
Mac / build (arm64, --with-sb-thread) (push) Waiting to run
Mac / build (x86-64, --with-mark-region-gc) (push) Waiting to run
Mac / build (x86-64, --with-sb-thread) (push) Waiting to run
Windows / build (push) Waiting to run

x86-64 uses a thread slot regardless of +/- sb-thread.
x86 without threads still uses a symbol.
This commit is contained in:
Douglas Katzman 2024-09-10 21:59:30 -04:00
parent f8a97c2fb8
commit e911e4ab33
7 changed files with 19 additions and 22 deletions

View file

@ -37,8 +37,7 @@
;;; This is a slot of 'struct thread' if multithreaded,
;;; and the symbol-global-value should never be used.
;;; (And in any case it is not really a special var)
#+(and (or x86 x86-64) (not sb-thread))
(defvar *pseudo-atomic-bits* 0)
#+(and x86 (not sb-thread)) (defvar *pseudo-atomic-bits* 0)
#+c-stack-is-control-stack
(setf (info :variable :always-bound 'sb-c:*alien-stack-pointer*) :always-bound)

View file

@ -560,9 +560,10 @@ during backtrace.
(current-catch-block :special *current-catch-block*)
#+(or x86-64 (and (or riscv arm64) sb-thread))
(current-unwind-protect-block :special *current-unwind-protect-block*)
#+(or sb-thread sparc ppc)
(pseudo-atomic-bits #+(or x86 x86-64) :special #+(or x86 x86-64) *pseudo-atomic-bits*
:c-type "pa_bits_t")
;; BUG: fundamentally a pseudo-atomic code sequence does not use these bits
;; with #+sb-safepoint so why does this slot need to be defined at all in that case?
#+(or sb-thread sparc ppc x86-64)
(pseudo-atomic-bits :c-type "pa_bits_t")
(alien-stack-pointer :c-type "lispobj *" :pointer t
:special *alien-stack-pointer*)
;; Deterministic consing profile recording area.

View file

@ -188,10 +188,8 @@
(inst test :byte rax-tn (ea -8 gc-card-table-reg-tn)))
(macrolet ((pa-bits-ea ()
#+sb-thread `(thread-slot-ea
thread-pseudo-atomic-bits-slot
#+gs-seg ,@(if thread (list thread)))
#-sb-thread `(static-symbol-value-ea '*pseudo-atomic-bits*))
`(thread-slot-ea thread-pseudo-atomic-bits-slot
#+gs-seg ,@(if thread (list thread))))
(nonzero-bits ()
;; reg-mem move is allegedly faster than imm-mem according to
;; someone at some point. Whether that's true or not, it is what it is.

View file

@ -163,8 +163,6 @@
;; That being so, it has to use the #-sb-thread mechanism of placing the new value
;; in the symbol's value slot for compatibility with UNBIND and all else.
#-sb-thread *alien-stack-pointer* ; a thread slot if #+sb-thread
;; interrupt handling
#-sb-thread *pseudo-atomic-bits* ; ditto
;; Since the text space and alien linkage table might both get relocated on startup
;; under #+immobile-space, an alien callback wrapper can't wire in the address
;; of a word that holds the C function pointer to callback_wrapper_trampoline.

View file

@ -203,10 +203,8 @@
(with-unique-names (label pa-bits-ea)
`(let ((,label (gen-label))
(,pa-bits-ea
#+sb-thread
(make-ea :dword :disp (* 4 thread-pseudo-atomic-bits-slot))
#-sb-thread
(make-ea-for-symbol-value *pseudo-atomic-bits* :dword)))
#+sb-thread (make-ea :dword :disp (* 4 thread-pseudo-atomic-bits-slot))
#-sb-thread (make-ea-for-symbol-value *pseudo-atomic-bits* :dword)))
(unless ,elide-if
(inst mov ,pa-bits-ea ebp-tn #+sb-thread :fs))
,@forms

View file

@ -111,8 +111,8 @@ clear_pseudo_atomic_interrupted(struct thread *thread)
/* x86 uses either a thread slot, or a single static symbol holding
* the same value as the thread slot would hold.
* The encoding of the values is strange - the entire word is onzero
* whend pseudo-atomic, and the lowest bit should be 0.
* The encoding of the values is strange - the entire word is nonzero
* when pseudo-atomic, and the lowest bit should be 0.
* If interrupted, the low bit becomes 1. This seems a little bogus because
* symbol->value at that point can have "illegal" bits (non-descriptor).
* I guess the reason it's allowed is GC can't ever see the bad value.
@ -124,10 +124,10 @@ clear_pseudo_atomic_interrupted(struct thread *thread)
# define LISPOBJ_ASM_SUFFIX "l"
#endif
#ifdef LISP_FEATURE_SB_THREAD
# define pa_bits thread->pseudo_atomic_bits
#else
#if defined LISP_FEATURE_X86 && !defined LISP_FEATURE_SB_THREAD
# define pa_bits SYMBOL(PSEUDO_ATOMIC_BITS)->value
#else
# define pa_bits thread->pseudo_atomic_bits
#endif
#include "interr.h" // for lose()

View file

@ -24,6 +24,9 @@
#+(or x86 x86-64) ;; x86oid-only, see internal commentary.
(with-test (:name (:interrupt-thread :interrupt-consing-child :again)
:broken-on :win32)
(symbol-macrolet ((pseudoatomic-bits
(sb-sys:sap-int (sb-vm::current-thread-offset-sap
sb-vm::thread-pseudo-atomic-bits-slot))))
(let ((c (make-thread (lambda () (loop (alloc-stuff))))))
;; NB this only works on x86: other ports don't have a symbol for
;; pseudo-atomic atomicity
@ -36,7 +39,7 @@
(force-output)
(assert (thread-alive-p *current-thread*))
(assert
(not (logbitp 0 SB-KERNEL:*PSEUDO-ATOMIC-BITS*))))))
(not (logbitp 0 pseudoatomic-bits))))))
(process-all-interrupts c)
(terminate-thread c)
(wait-for-threads (list c))))
(wait-for-threads (list c)))))