(define-integrable (system-hunk3-cons type cxr0 cxr1 cxr2)
(object-new-type type (hunk3-cons cxr0 cxr1 cxr2)))
-(define (limit-interrupts! limit-mask)
- (set-interrupt-enables! (fix:and limit-mask (get-interrupt-enables))))
-
(define-integrable (object-component-binder get-component set-component!)
(lambda (object value thunk)
(define (swap!)
(object-new-type (ucode-type constant) 1))
\f
(define (for-each-interned-symbol procedure)
- (for-each-symbol-in-obarray (fixed-objects-item 'OBARRAY) procedure))
+ (with-obarray-lock
+ (lambda ()
+ (for-each-symbol-in-obarray (fixed-objects-item 'OBARRAY) procedure))))
(define (for-each-symbol-in-obarray obarray procedure)
(let per-bucket ((index (vector-length obarray)))
list))
(define (clean-obarray)
- (without-interrupts
+ (with-obarray-lock
(lambda ()
(let ((obarray (fixed-objects-item 'OBARRAY)))
(let loop ((index (vector-length obarray)))
lexical-unassigned?
lexical-unbound?
lexical-unreferenceable?
- limit-interrupts!
link-variables
local-assignment
make-cell
with-interrupt-mask
with-values
write-to-string)
+ (import (runtime thread)
+ with-obarray-lock)
(initialization (initialize-package!)))
(define-package (runtime alternative-lambda)
;;; This allows a host without the SMP primitives to avoid calling them.
(define enable-smp? #f)
+
+(define (with-obarray-lock thunk)
+ ;; Serialize with myriad parts of the microcode that hack the
+ ;; obarray element of the fixed-objects vector.
+ (if enable-smp?
+ (if ((ucode-primitive smp-lock-obarray 1) #t)
+ (let ((value (thunk)))
+ (if ((ucode-primitive smp-lock-obarray 1) #f)
+ value
+ (begin
+ (outf-error ";with-obarray-lock: unlock failed\n")
+ #f)))
+ (begin
+ (outf-error ";with-obarray-lock: lock failed\n")))
+ (without-interrupts thunk)))
\f
(define-structure (thread
(constructor %make-thread ())
(define (state-point/space point)
(guarantee-state-point point 'STATE-POINT/SPACE)
- (let ((interrupt-mask (limit-interrupts! interrupt-mask/gc-ok)))
+ (let ((interrupt-mask
+ (set-interrupt-enables! (fix:and (get-interrupt-enables)
+ interrupt-mask/gc-ok))))
(let loop ((point point))
(let ((nearer-point (state-point/nearer-point point)))
(if nearer-point
(local #f read-only #t))
(define (get-dynamic-state)
- (let ((interrupt-mask (limit-interrupts! interrupt-mask/gc-ok)))
+ (let ((interrupt-mask
+ (set-interrupt-enables! (fix:and (get-interrupt-enables)
+ interrupt-mask/gc-ok))))
(let ((state
(make-dynamic-state
(state-space/nearest-point state-space:global)