`(unless (location= ,n-dst ,n-src)
(inst mov ,n-dst ,n-src))))
+(defmacro align-stack-pointer (tn)
+ #!-darwin (declare (ignore tn))
+ #!+darwin
+ ;; 16 byte alignment.
+ `(inst and ,tn #xfffffff0))
+
(defmacro make-ea-for-object-slot (ptr slot lowtag &optional (size :dword))
`(make-ea ,size :base ,ptr :disp (- (* ,slot n-word-bytes) ,lowtag)))
(make-ea :byte :base ,n-source :disp ,n-offset)))
(:big-endian
`(inst mov ,n-target
- (make-ea :byte :base ,n-source :disp (+ ,n-offset 3)))))))
+ (make-ea :byte :base ,n-source
+ :disp (+ ,n-offset (1- n-word-bytes))))))))
\f
;;;; allocation helpers
;;; Allocate an other-pointer object of fixed SIZE with a single word
;;; header having the specified WIDETAG value. The result is placed in
;;; RESULT-TN.
-(defmacro with-fixed-allocation ((result-tn widetag size &optional inline)
+(defmacro with-fixed-allocation ((result-tn widetag size &optional inline stack-allocate-p)
&body forms)
(unless forms
(bug "empty &body in WITH-FIXED-ALLOCATION"))
- (once-only ((result-tn result-tn) (size size))
- `(pseudo-atomic
- (allocation ,result-tn (pad-data-block ,size) ,inline)
+ (once-only ((result-tn result-tn) (size size) (stack-allocate-p stack-allocate-p))
+ `(maybe-pseudo-atomic ,stack-allocate-p
+ (allocation ,result-tn (pad-data-block ,size) ,inline ,stack-allocate-p)
(storew (logior (ash (1- ,size) n-widetag-bits) ,widetag)
,result-tn)
(inst lea ,result-tn
\f
;;;; indexed references
+(defmacro define-full-compare-and-swap
+ (name type offset lowtag scs el-type &optional translate)
+ `(progn
+ (define-vop (,name)
+ ,@(when translate `((:translate ,translate)))
+ (:policy :fast-safe)
+ (:args (object :scs (descriptor-reg) :to :eval)
+ (index :scs (any-reg immediate unsigned-reg) :to :result)
+ (old-value :scs ,scs :target eax)
+ (new-value :scs ,scs))
+ (:arg-types ,type tagged-num ,el-type ,el-type)
+ (:temporary (:sc descriptor-reg :offset eax-offset
+ :from (:argument 2) :to :result :target value) eax)
+ (:results (value :scs ,scs))
+ (:result-types ,el-type)
+ (:generator 5
+ (move eax old-value)
+ #!+sb-thread
+ (inst lock)
+ (let ((ea (sc-case index
+ (immediate
+ (make-ea :dword :base object
+ :disp (- (* (+ ,offset (tn-value index))
+ n-word-bytes)
+ ,lowtag)))
+ (unsigned-reg
+ (make-ea :dword :base object :index index :scale 4
+ :disp (- (* ,offset n-word-bytes)
+ ,lowtag)))
+ (t
+ (make-ea :dword :base object :index index
+ :disp (- (* ,offset n-word-bytes)
+ ,lowtag))))))
+ (inst cmpxchg ea new-value))
+ (move value eax)))))
+
(defmacro define-full-reffer (name type offset lowtag scs el-type &optional translate)
`(progn
(define-vop (,name)