(define-vop (set cell-set)
(:variant symbol-value-slot other-pointer-lowtag))
-;;; Do a cell ref with an error check for being unbound.
-;;; XXX stil used? I can't see where -dan
-(define-vop (checked-cell-ref)
- (:args (object :scs (descriptor-reg) :target obj-temp))
- (:results (value :scs (descriptor-reg any-reg)))
- (:policy :fast-safe)
- (:vop-var vop)
- (:save-p :compute-only)
- (:temporary (:sc descriptor-reg :from (:argument 0)) obj-temp))
-
;;; With Symbol-Value, we check that the value isn't the trap object. So
;;; Symbol-Value of NIL is NIL.
#!+sb-thread
(pseudo-atomic
(emit-label get-tls-index-lock)
(inst mov temp 1)
- (inst xor rax rax)
+ (zeroize rax)
(inst lock)
(inst cmpxchg (make-ea-for-symbol-value *tls-index-lock*) temp)
(inst jmp :ne get-tls-index-lock)
(inst mov (make-ea :qword :base thread-base-tn :scale 1 :index tls-index)
value)
- (storew 0 bsp (- binding-value-slot binding-size))
(storew 0 bsp (- binding-symbol-slot binding-size))
+ (storew 0 bsp (- binding-value-slot binding-size))
(inst sub bsp (* binding-size n-word-bytes))
(store-binding-stack-pointer bsp)))
(loadw symbol bsp (- binding-symbol-slot binding-size))
(loadw value bsp (- binding-value-slot binding-size))
(storew value symbol symbol-value-slot other-pointer-lowtag)
- (storew 0 bsp (- binding-value-slot binding-size))
(storew 0 bsp (- binding-symbol-slot binding-size))
+ (storew 0 bsp (- binding-value-slot binding-size))
(inst sub bsp (* binding-size n-word-bytes))
(store-symbol-value bsp *binding-stack-pointer*)))
#!+sb-thread
(inst mov (make-ea :qword :base thread-base-tn :scale 1 :index tls-index)
value)
- (storew 0 bsp (- binding-value-slot binding-size))
(storew 0 bsp (- binding-symbol-slot binding-size))
SKIP
+ (storew 0 bsp (- binding-value-slot binding-size))
(inst sub bsp (* binding-size n-word-bytes))
(inst cmp where bsp)
(inst jmp :ne LOOP)
funcallable-instance-info-offset fun-pointer-lowtag
(descriptor-reg any-reg) * %funcallable-instance-info)
-(define-vop (funcallable-instance-lexenv cell-ref)
- (:variant funcallable-instance-lexenv-slot fun-pointer-lowtag))
-
(define-vop (closure-ref slot-ref)
(:variant closure-info-offset fun-pointer-lowtag))
(define-full-setter instance-index-set * instance-slots-offset
instance-pointer-lowtag (any-reg descriptor-reg) * %instance-set)
-
-(defknown %instance-set-conditional (instance index t t) t
- (unsafe))
-
-(define-vop (instance-set-conditional)
- (:translate %instance-set-conditional)
- (:args (object :scs (descriptor-reg) :to :eval)
- (slot :scs (any-reg) :to :result)
- (old-value :scs (descriptor-reg any-reg) :target rax)
- (new-value :scs (descriptor-reg any-reg)))
- (:arg-types instance positive-fixnum * *)
- (:temporary (:sc descriptor-reg :offset rax-offset
- :from (:argument 2) :to :result :target result) rax)
- (:results (result :scs (descriptor-reg any-reg)))
- ;(:guard (backend-featurep :i486))
- (:policy :fast-safe)
- (:generator 5
- (move rax old-value)
- (inst lock)
- (inst cmpxchg (make-ea :qword :base object :index slot :scale 1
- :disp (- (* instance-slots-offset n-word-bytes)
- instance-pointer-lowtag))
- new-value)
- (move result rax)))
-
-
+(define-full-compare-and-swap instance-compare-and-swap instance
+ instance-slots-offset instance-pointer-lowtag (any-reg descriptor-reg)
+ * %instance-compare-and-swap)
\f
;;;; code object frobbing
(define-full-setter code-header-set * 0 other-pointer-lowtag
(any-reg descriptor-reg) * code-header-set)
-
-
\f
;;;; raw instance slot accessors
+(defun make-ea-for-raw-slot (object index instance-length
+ &optional (adjustment 0))
+ (etypecase index
+ (tn
+ (make-ea :qword :base object :index instance-length
+ :disp (+ (* (1- instance-slots-offset) n-word-bytes)
+ (- instance-pointer-lowtag)
+ adjustment)))
+ (integer
+ (make-ea :qword :base object :index instance-length
+ :scale 8
+ :disp (+ (* (1- instance-slots-offset) n-word-bytes)
+ (- instance-pointer-lowtag)
+ adjustment
+ (- (fixnumize index)))))))
+
(define-vop (raw-instance-ref/word)
(:translate %raw-instance-ref/word)
(:policy :fast-safe)
(inst shr tmp n-widetag-bits)
(inst shl tmp 3)
(inst sub tmp index)
- (inst mov
- value
- (make-ea :qword
- :base object
- :index tmp
- :disp (- (* (1- instance-slots-offset) n-word-bytes)
- instance-pointer-lowtag)))))
+ (inst mov value (make-ea-for-raw-slot object index tmp))))
+
+(define-vop (raw-instance-ref-c/word)
+ (:translate %raw-instance-ref/word)
+ (:policy :fast-safe)
+ (:args (object :scs (descriptor-reg)))
+ (:arg-types * (:constant (load/store-index #.sb!vm:n-word-bytes
+ #.instance-pointer-lowtag
+ #.instance-slots-offset)))
+ (:info index)
+ (:temporary (:sc unsigned-reg) tmp)
+ (:results (value :scs (unsigned-reg)))
+ (:result-types unsigned-num)
+ (:generator 4
+ (loadw tmp object 0 instance-pointer-lowtag)
+ (inst shr tmp n-widetag-bits)
+ (inst mov value (make-ea-for-raw-slot object index tmp))))
(define-vop (raw-instance-set/word)
(:translate %raw-instance-set/word)
(inst shr tmp n-widetag-bits)
(inst shl tmp 3)
(inst sub tmp index)
- (inst mov
- (make-ea :qword
- :base object
- :index tmp
- :disp (- (* (1- instance-slots-offset) n-word-bytes)
- instance-pointer-lowtag))
- value)
+ (inst mov (make-ea-for-raw-slot object index tmp) value)
+ (move result value)))
+
+(define-vop (raw-instance-set-c/word)
+ (:translate %raw-instance-set/word)
+ (:policy :fast-safe)
+ (:args (object :scs (descriptor-reg))
+ (value :scs (unsigned-reg) :target result))
+ (:arg-types * (:constant (load/store-index #.sb!vm:n-word-bytes
+ #.instance-pointer-lowtag
+ #.instance-slots-offset))
+ unsigned-num)
+ (:info index)
+ (:temporary (:sc unsigned-reg) tmp)
+ (:results (result :scs (unsigned-reg)))
+ (:result-types unsigned-num)
+ (:generator 4
+ (loadw tmp object 0 instance-pointer-lowtag)
+ (inst shr tmp n-widetag-bits)
+ (inst mov (make-ea-for-raw-slot object index tmp) value)
(move result value)))
(define-vop (raw-instance-ref/single)
(inst shr tmp n-widetag-bits)
(inst shl tmp 3)
(inst sub tmp index)
- (inst movss
- value
- (make-ea :dword
- :base object
- :index tmp
- :disp (- (* (1- instance-slots-offset) n-word-bytes)
- instance-pointer-lowtag)))))
+ (inst movss value (make-ea-for-raw-slot object index tmp))))
+
+(define-vop (raw-instance-ref-c/single)
+ (:translate %raw-instance-ref/single)
+ (:policy :fast-safe)
+ (:args (object :scs (descriptor-reg)))
+ (:arg-types * (:constant (load/store-index #.sb!vm:n-word-bytes
+ #.instance-pointer-lowtag
+ #.instance-slots-offset)))
+ (:info index)
+ (:temporary (:sc unsigned-reg) tmp)
+ (:results (value :scs (single-reg)))
+ (:result-types single-float)
+ (:generator 4
+ (loadw tmp object 0 instance-pointer-lowtag)
+ (inst shr tmp n-widetag-bits)
+ (inst movss value (make-ea-for-raw-slot object index tmp))))
(define-vop (raw-instance-set/single)
(:translate %raw-instance-set/single)
(inst shr tmp n-widetag-bits)
(inst shl tmp 3)
(inst sub tmp index)
- (inst movss
- (make-ea :dword
- :base object
- :index tmp
- :disp (- (* (1- instance-slots-offset) n-word-bytes)
- instance-pointer-lowtag))
- value)
+ (inst movss (make-ea-for-raw-slot object index tmp) value)
+ (unless (location= result value)
+ (inst movss result value))))
+
+(define-vop (raw-instance-set-c/single)
+ (:translate %raw-instance-set/single)
+ (:policy :fast-safe)
+ (:args (object :scs (descriptor-reg))
+ (value :scs (single-reg) :target result))
+ (:arg-types * (:constant (load/store-index #.sb!vm:n-word-bytes
+ #.instance-pointer-lowtag
+ #.instance-slots-offset))
+ single-float)
+ (:info index)
+ (:temporary (:sc unsigned-reg) tmp)
+ (:results (result :scs (single-reg)))
+ (:result-types single-float)
+ (:generator 4
+ (loadw tmp object 0 instance-pointer-lowtag)
+ (inst shr tmp n-widetag-bits)
+ (inst movss (make-ea-for-raw-slot object index tmp) value)
(unless (location= result value)
(inst movss result value))))
(inst shr tmp n-widetag-bits)
(inst shl tmp 3)
(inst sub tmp index)
- (inst movsd
- value
- (make-ea :dword
- :base object
- :index tmp
- :disp (- (* (1- instance-slots-offset) n-word-bytes)
- instance-pointer-lowtag)))))
+ (inst movsd value (make-ea-for-raw-slot object index tmp))))
+
+(define-vop (raw-instance-ref-c/double)
+ (:translate %raw-instance-ref/double)
+ (:policy :fast-safe)
+ (:args (object :scs (descriptor-reg)))
+ (:arg-types * (:constant (load/store-index #.sb!vm:n-word-bytes
+ #.instance-pointer-lowtag
+ #.instance-slots-offset)))
+ (:info index)
+ (:temporary (:sc unsigned-reg) tmp)
+ (:results (value :scs (double-reg)))
+ (:result-types double-float)
+ (:generator 4
+ (loadw tmp object 0 instance-pointer-lowtag)
+ (inst shr tmp n-widetag-bits)
+ (inst movsd value (make-ea-for-raw-slot object index tmp))))
(define-vop (raw-instance-set/double)
(:translate %raw-instance-set/double)
(inst shr tmp n-widetag-bits)
(inst shl tmp 3)
(inst sub tmp index)
- (inst movsd
- (make-ea :dword
- :base object
- :index tmp
- :disp (- (* (1- instance-slots-offset) n-word-bytes)
- instance-pointer-lowtag))
- value)
+ (inst movsd (make-ea-for-raw-slot object index tmp) value)
+ (unless (location= result value)
+ (inst movsd result value))))
+
+(define-vop (raw-instance-set-c/double)
+ (:translate %raw-instance-set/double)
+ (:policy :fast-safe)
+ (:args (object :scs (descriptor-reg))
+ (value :scs (double-reg) :target result))
+ (:arg-types * (:constant (load/store-index #.sb!vm:n-word-bytes
+ #.instance-pointer-lowtag
+ #.instance-slots-offset))
+ double-float)
+ (:info index)
+ (:temporary (:sc unsigned-reg) tmp)
+ (:results (result :scs (double-reg)))
+ (:result-types double-float)
+ (:generator 4
+ (loadw tmp object 0 instance-pointer-lowtag)
+ (inst shr tmp n-widetag-bits)
+ (inst movsd (make-ea-for-raw-slot object index tmp) value)
(unless (location= result value)
(inst movsd result value))))
(inst shl tmp 3)
(inst sub tmp index)
(let ((real-tn (complex-single-reg-real-tn value)))
- (inst movss
- real-tn
- (make-ea :dword
- :base object
- :index tmp
- :disp (- (* (1- instance-slots-offset) n-word-bytes)
- instance-pointer-lowtag))))
+ (inst movss real-tn (make-ea-for-raw-slot object index tmp)))
(let ((imag-tn (complex-single-reg-imag-tn value)))
- (inst movss
- imag-tn
- (make-ea :dword
- :base object
- :index tmp
- :disp (+ (* (1- instance-slots-offset) n-word-bytes)
- 4
- (- instance-pointer-lowtag)))))))
+ (inst movss imag-tn (make-ea-for-raw-slot object index tmp 4)))))
+
+(define-vop (raw-instance-ref-c/complex-single)
+ (:translate %raw-instance-ref/complex-single)
+ (:policy :fast-safe)
+ (:args (object :scs (descriptor-reg)))
+ (:arg-types * (:constant (load/store-index #.sb!vm:n-word-bytes
+ #.instance-pointer-lowtag
+ #.instance-slots-offset)))
+ (:info index)
+ (:temporary (:sc unsigned-reg) tmp)
+ (:results (value :scs (complex-single-reg)))
+ (:result-types complex-single-float)
+ (:generator 4
+ (loadw tmp object 0 instance-pointer-lowtag)
+ (inst shr tmp n-widetag-bits)
+ (let ((real-tn (complex-single-reg-real-tn value)))
+ (inst movss real-tn (make-ea-for-raw-slot object index tmp)))
+ (let ((imag-tn (complex-single-reg-imag-tn value)))
+ (inst movss imag-tn (make-ea-for-raw-slot object index tmp 4)))))
(define-vop (raw-instance-set/complex-single)
(:translate %raw-instance-set/complex-single)
(inst sub tmp index)
(let ((value-real (complex-single-reg-real-tn value))
(result-real (complex-single-reg-real-tn result)))
- (inst movss (make-ea :dword
- :base object
- :index tmp
- :disp (- (* (1- instance-slots-offset) n-word-bytes)
- instance-pointer-lowtag))
- value-real)
+ (inst movss (make-ea-for-raw-slot object index tmp) value-real)
+ (unless (location= value-real result-real)
+ (inst movss result-real value-real)))
+ (let ((value-imag (complex-single-reg-imag-tn value))
+ (result-imag (complex-single-reg-imag-tn result)))
+ (inst movss (make-ea-for-raw-slot object index tmp 4) value-imag)
+ (unless (location= value-imag result-imag)
+ (inst movss result-imag value-imag)))))
+
+(define-vop (raw-instance-set-c/complex-single)
+ (:translate %raw-instance-set/complex-single)
+ (:policy :fast-safe)
+ (:args (object :scs (descriptor-reg))
+ (value :scs (complex-single-reg) :target result))
+ (:arg-types * (:constant (load/store-index #.sb!vm:n-word-bytes
+ #.instance-pointer-lowtag
+ #.instance-slots-offset))
+ complex-single-float)
+ (:info index)
+ (:temporary (:sc unsigned-reg) tmp)
+ (:results (result :scs (complex-single-reg)))
+ (:result-types complex-single-float)
+ (:generator 4
+ (loadw tmp object 0 instance-pointer-lowtag)
+ (inst shr tmp n-widetag-bits)
+ (let ((value-real (complex-single-reg-real-tn value))
+ (result-real (complex-single-reg-real-tn result)))
+ (inst movss (make-ea-for-raw-slot object index tmp) value-real)
(unless (location= value-real result-real)
(inst movss result-real value-real)))
(let ((value-imag (complex-single-reg-imag-tn value))
(result-imag (complex-single-reg-imag-tn result)))
- (inst movss (make-ea :dword
- :base object
- :index tmp
- :disp (+ (* (1- instance-slots-offset) n-word-bytes)
- 4
- (- instance-pointer-lowtag)))
- value-imag)
+ (inst movss (make-ea-for-raw-slot object index tmp 4) value-imag)
(unless (location= value-imag result-imag)
(inst movss result-imag value-imag)))))
(inst shl tmp 3)
(inst sub tmp index)
(let ((real-tn (complex-double-reg-real-tn value)))
- (inst movsd
- real-tn
- (make-ea :dword
- :base object
- :index tmp
- :disp (- (* (- instance-slots-offset 2) n-word-bytes)
- instance-pointer-lowtag))))
+ (inst movsd real-tn (make-ea-for-raw-slot object index tmp -8)))
+ (let ((imag-tn (complex-double-reg-imag-tn value)))
+ (inst movsd imag-tn (make-ea-for-raw-slot object index tmp)))))
+
+(define-vop (raw-instance-ref-c/complex-double)
+ (:translate %raw-instance-ref/complex-double)
+ (:policy :fast-safe)
+ (:args (object :scs (descriptor-reg)))
+ (:arg-types * (:constant (load/store-index #.sb!vm:n-word-bytes
+ #.instance-pointer-lowtag
+ #.instance-slots-offset)))
+ (:info index)
+ (:temporary (:sc unsigned-reg) tmp)
+ (:results (value :scs (complex-double-reg)))
+ (:result-types complex-double-float)
+ (:generator 4
+ (loadw tmp object 0 instance-pointer-lowtag)
+ (inst shr tmp n-widetag-bits)
+ (let ((real-tn (complex-double-reg-real-tn value)))
+ (inst movsd real-tn (make-ea-for-raw-slot object index tmp -8)))
(let ((imag-tn (complex-double-reg-imag-tn value)))
- (inst movsd
- imag-tn
- (make-ea :dword
- :base object
- :index tmp
- :disp (- (* (1- instance-slots-offset) n-word-bytes)
- instance-pointer-lowtag))))))
+ (inst movsd imag-tn (make-ea-for-raw-slot object index tmp)))))
(define-vop (raw-instance-set/complex-double)
(:translate %raw-instance-set/complex-double)
(inst sub tmp index)
(let ((value-real (complex-double-reg-real-tn value))
(result-real (complex-double-reg-real-tn result)))
- (inst movsd (make-ea :dword
- :base object
- :index tmp
- :disp (- (* (- instance-slots-offset 2) n-word-bytes)
- instance-pointer-lowtag))
- value-real)
+ (inst movsd (make-ea-for-raw-slot object index tmp -8) value-real)
+ (unless (location= value-real result-real)
+ (inst movsd result-real value-real)))
+ (let ((value-imag (complex-double-reg-imag-tn value))
+ (result-imag (complex-double-reg-imag-tn result)))
+ (inst movsd (make-ea-for-raw-slot object index tmp) value-imag)
+ (unless (location= value-imag result-imag)
+ (inst movsd result-imag value-imag)))))
+
+(define-vop (raw-instance-set-c/complex-double)
+ (:translate %raw-instance-set/complex-double)
+ (:policy :fast-safe)
+ (:args (object :scs (descriptor-reg))
+ (value :scs (complex-double-reg) :target result))
+ (:arg-types * (:constant (load/store-index #.sb!vm:n-word-bytes
+ #.instance-pointer-lowtag
+ #.instance-slots-offset))
+ complex-double-float)
+ (:info index)
+ (:temporary (:sc unsigned-reg) tmp)
+ (:results (result :scs (complex-double-reg)))
+ (:result-types complex-double-float)
+ (:generator 4
+ (loadw tmp object 0 instance-pointer-lowtag)
+ (inst shr tmp n-widetag-bits)
+ (let ((value-real (complex-double-reg-real-tn value))
+ (result-real (complex-double-reg-real-tn result)))
+ (inst movsd (make-ea-for-raw-slot object index tmp -8) value-real)
(unless (location= value-real result-real)
(inst movsd result-real value-real)))
(let ((value-imag (complex-double-reg-imag-tn value))
(result-imag (complex-double-reg-imag-tn result)))
- (inst movsd (make-ea :dword
- :base object
- :index tmp
- :disp (- (* (1- instance-slots-offset) n-word-bytes)
- instance-pointer-lowtag))
- value-imag)
+ (inst movsd (make-ea-for-raw-slot object index tmp) value-imag)
(unless (location= value-imag result-imag)
(inst movsd result-imag value-imag)))))