1.0.2.2:
[sbcl.git] / src / compiler / x86 / macros.lisp
index e99bf9b..fdf55a2 100644 (file)
   ;; 32-bit lispobjs).  In that case, this AND instruction is
   ;; unneccessary and could be removed.  If not, explain why.  -- CSR,
   ;; 2004-03-30
-  (inst and esp-tn #.(ldb (byte 32 0) (lognot lowtag-mask)))
+  (inst and esp-tn (lognot lowtag-mask))
   (aver (not (location= alloc-tn esp-tn)))
   (inst mov alloc-tn esp-tn)
   (values))
 ;;; place and there's no logical single place to attach documentation.
 ;;; grep (mostly in src/runtime) is your friend
 
-;;; FIXME: *PSEUDO-ATOMIC-FOO* could be made into *PSEUDO-ATOMIC-BITS*,
-;;; set with a single operation and cleared with SHR *PSEUDO-ATOMIC-BITS*,-2;
-;;; the ATOMIC bit is bit 0, the INTERRUPTED bit is bit 1, and you check
-;;; the C flag after the shift to see whether you were interrupted.
-;;;
 ;;; KLUDGE: since the stack on the x86 is treated conservatively, it
 ;;; does not matter whether a signal occurs during construction of a
 ;;; dynamic-extent object, as the half-finished construction of the
   (with-unique-names (label)
     `(let ((,label (gen-label)))
        (inst fs-segment-prefix)
-       (inst mov (make-ea :byte :disp (* 4 thread-pseudo-atomic-atomic-slot))
+       (inst or (make-ea :byte :disp (* 4 thread-pseudo-atomic-bits-slot))
             (fixnumize 1))
        ,@forms
        (inst fs-segment-prefix)
-       (inst mov (make-ea :byte :disp (* 4 thread-pseudo-atomic-atomic-slot)) 0)
-       (inst fs-segment-prefix)
-       (inst cmp (make-ea :byte
-                          :disp (* 4 thread-pseudo-atomic-interrupted-slot)) 0)
-       (inst jmp :eq ,label)
+       (inst xor (make-ea :byte :disp (* 4 thread-pseudo-atomic-bits-slot))
+             (fixnumize 1))
+       (inst jmp :z ,label)
        ;; if PAI was set, interrupts were disabled at the same
        ;; time using the process signal mask.
        (inst break pending-interrupt-trap)
        ;; FIXME: The MAKE-EA noise should become a MACROLET macro
        ;; or something. (perhaps SVLB, for static variable low
        ;; byte)
-       (inst mov (make-ea :byte :disp (+ nil-value
-                                         (static-symbol-offset
-                                          '*pseudo-atomic-atomic*)
-                                         (ash symbol-value-slot word-shift)
-                                         (- other-pointer-lowtag)))
+       (inst or (make-ea :byte :disp (+ nil-value
+                                        (static-symbol-offset
+                                         '*pseudo-atomic-bits*)
+                                        (ash symbol-value-slot word-shift)
+                                        (- other-pointer-lowtag)))
              (fixnumize 1))
        ,@forms
-       (inst mov (make-ea :byte :disp (+ nil-value
+       (inst xor (make-ea :byte :disp (+ nil-value
                                          (static-symbol-offset
-                                          '*pseudo-atomic-atomic*)
+                                          '*pseudo-atomic-bits*)
                                          (ash symbol-value-slot word-shift)
                                          (- other-pointer-lowtag)))
-             0)
-       (inst cmp (make-ea :byte
-                          :disp (+ nil-value
-                                   (static-symbol-offset
-                                    '*pseudo-atomic-interrupted*)
-                                   (ash symbol-value-slot word-shift)
-                                   (- other-pointer-lowtag)))
-             0)
-       (inst jmp :eq ,label)
+             (fixnumize 1))
+       (inst jmp :z ,label)
        ;; if PAI was set, interrupts were disabled at the same
        ;; time using the process signal mask.
        (inst break pending-interrupt-trap)
            `((:translate ,translate)))
        (:policy :fast-safe)
        (:args (object :scs (descriptor-reg))
-              (index :scs (any-reg immediate)))
+              (index :scs (any-reg immediate unsigned-reg)))
        (:arg-types ,type tagged-num)
        (:results (value :scs ,scs))
        (:result-types ,el-type)
                                      :disp (- (* (+ ,offset (tn-value index))
                                                  n-word-bytes)
                                               ,lowtag))))
+           (unsigned-reg
+            (inst mov value (make-ea :dword :base object :index index :scale 4
+                                     :disp (- (* ,offset n-word-bytes)
+                                              ,lowtag))))
            (t
             (inst mov value (make-ea :dword :base object :index index
                                      :disp (- (* ,offset n-word-bytes)
                                               ,lowtag)))))))))
 
+(defmacro define-full-reffer+offset (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))
+              (index :scs (any-reg immediate unsigned-reg)))
+       (:arg-types ,type tagged-num
+                   (:constant (constant-displacement ,lowtag sb!vm:n-word-bytes ,offset)))
+       (:info offset)
+       (:results (value :scs ,scs))
+       (:result-types ,el-type)
+       (:generator 3                    ; pw was 5
+         (sc-case index
+           (immediate
+            (inst mov value (make-ea :dword :base object
+                                     :disp (- (* (+ ,offset
+                                                    (tn-value index)
+                                                    offset)
+                                                 n-word-bytes)
+                                              ,lowtag))))
+           (unsigned-reg
+            (inst mov value (make-ea :dword :base object :index index :scale 4
+                                     :disp (- (* (+ ,offset offset)
+                                                 n-word-bytes)
+                                              ,lowtag))))
+           (t
+            (inst mov value (make-ea :dword :base object :index index
+                                     :disp (- (* (+ ,offset offset)
+                                                 n-word-bytes)
+                                              ,lowtag)))))))))
+
 (defmacro define-full-setter (name type offset lowtag scs el-type &optional translate)
   `(progn
      (define-vop (,name)
                   value)))
         (move result value)))))
 
+(defmacro define-full-setter+offset (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))
+              (index :scs (any-reg immediate))
+              (value :scs ,scs :target result))
+       (:info offset)
+       (:arg-types ,type tagged-num
+                   (:constant (constant-displacement ,lowtag sb!vm:n-word-bytes ,offset)) ,el-type)
+       (:results (result :scs ,scs))
+       (:result-types ,el-type)
+       (:generator 4                    ; was 5
+         (sc-case index
+           (immediate
+            (inst mov (make-ea :dword :base object
+                               :disp (- (* (+ ,offset (tn-value index) offset)
+                                           n-word-bytes)
+                                        ,lowtag))
+                  value))
+           (t
+            (inst mov (make-ea :dword :base object :index index
+                               :disp (- (* (+ ,offset offset)
+                                           n-word-bytes) ,lowtag))
+                  value)))
+        (move result value)))))
+
 ;;; helper for alien stuff.
 (defmacro with-pinned-objects ((&rest objects) &body body)
   "Arrange with the garbage collector that the pages occupied by