0.9.18.52:
authorNathan Froyd <froydnj@cs.rice.edu>
Tue, 14 Nov 2006 22:15:20 +0000 (22:15 +0000)
committerNathan Froyd <froydnj@cs.rice.edu>
Tue, 14 Nov 2006 22:15:20 +0000 (22:15 +0000)
If possible, use a shorter XOR instruction on x86-64 when we zero
  a register.

src/compiler/x86-64/alloc.lisp
src/compiler/x86-64/arith.lisp
src/compiler/x86-64/call.lisp
src/compiler/x86-64/cell.lisp
src/compiler/x86-64/move.lisp
src/compiler/x86-64/subprim.lisp
version.lisp-expr

index 690e34b..76bad49 100644 (file)
     (inst lea result (make-ea :byte :base result :disp other-pointer-lowtag))
     (storew type result 0 other-pointer-lowtag)
     (storew length result vector-length-slot other-pointer-lowtag)
-    (inst xor zero zero)
+    (zeroize zero)
     (inst rep)
     (inst stos zero)))
 
index 100ca5e..e0a4d3c 100644 (file)
                       (inst shl result amount)
                       (inst shr result (- amount))))
                  (t (if (sc-is result unsigned-reg)
-                        (inst xor result result)
+                        (zeroize result)
                         (inst mov result 0))))))))
 
 (define-vop (fast-ash-left/signed=>signed)
     (inst neg ecx)
     (inst cmp ecx 63)
     (inst jmp :be OKAY)
-    (inst xor result result)
+    (zeroize result)
     (inst jmp DONE)
     OKAY
     (inst shr result :cl)
     (inst or ecx ecx)
     (inst jmp :ns POSITIVE)
     (inst neg ecx)
-    (inst xor zero zero)
+    (zeroize zero)
     (inst shr result :cl)
     (inst cmp ecx 63)
     (inst cmov :nbe result zero)
     (inst inc res)
     (inst jmp DONE)
     ZERO
-    (inst xor res res)
+    (zeroize res)
     DONE))
 
 (define-vop (unsigned-byte-64-len)
     (inst inc res)
     (inst jmp DONE)
     ZERO
-    (inst xor res res)
+    (zeroize res)
     DONE))
 
 (define-vop (unsigned-byte-64-count)
index da925b3..4f25442 100644 (file)
                                do (noise `(loadw ,name new-fp ,index)))
                               (noise))
                    '((if (zerop nargs)
-                         (inst xor rcx rcx)
+                         (zeroize rcx)
                        (inst mov rcx (fixnumize nargs)))))
                ,@(cond ((eq return :tail)
                         '(;; Python has figured out what frame we should
     ;; Establish the values pointer and values count.
     (move rbx rbp-tn)
     (if (zerop nvals)
-        (inst xor rcx rcx) ; smaller
+        (zeroize rcx) ; smaller
       (inst mov rcx (fixnumize nvals)))
     ;; Restore the frame pointer.
     (move rbp-tn old-fp)
     ;; We need to copy from downwards up to avoid overwriting some of
     ;; the yet uncopied args. So we need to use R9 as the copy index
     ;; and RCX as the loop counter, rather than using RCX for both.
-    (inst xor copy-index copy-index)
+    (zeroize copy-index)
 
     ;; We used to use REP MOVS here, but on modern x86 it performs
     ;; much worse than an explicit loop for small blocks.
index d9e8368..929e74f 100644 (file)
       (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)
index 4caf11f..a5de78c 100644 (file)
 
 (in-package "SB!VM")
 
+(defun zeroize (tn)
+  (let ((offset (tn-offset tn)))
+    ;; Using the 32-bit instruction accomplishes the same thing and is
+    ;; one byte shorter.
+    (if (<= offset edi-offset)
+        (let ((tn (make-random-tn :kind :normal
+                                  :sc (sc-or-lose 'dword-reg)
+                                  :offset offset)))
+          (inst xor tn tn))
+        (inst xor tn tn))))
+
 (define-move-fun (load-immediate 1) (vop x y)
   ((immediate)
    (any-reg descriptor-reg))
@@ -18,7 +29,7 @@
     (etypecase val
       (integer
        (if (zerop val)
-           (inst xor y y)
+           (zeroize y)
          (inst mov y (fixnumize val))))
       (symbol
        (load-symbol y val))
@@ -30,7 +41,7 @@
   ((immediate) (signed-reg unsigned-reg))
   (let ((val (tn-value x)))
     (if (zerop val)
-        (inst xor y y)
+        (zeroize y)
         (inst mov y val))))
 
 (define-move-fun (load-character 1) (vop x y)
@@ -80,7 +91,7 @@
           (etypecase val
             (integer
              (if (and (zerop val) (sc-is y any-reg descriptor-reg))
-                 (inst xor y y)
+                 (zeroize y)
                  (move-immediate y (fixnumize val) temp)))
             (symbol
              (inst mov y (+ nil-value (static-symbol-offset val))))
            (let ((val (tn-value x)))
              (etypecase val
                ((integer 0 0)
-                (inst xor y y))
+                (zeroize y))
                ((or (signed-byte 29) (unsigned-byte 29))
                 (inst mov y (fixnumize val)))
                (integer
index 74692e8..4b3eed2 100644 (file)
@@ -28,7 +28,7 @@
   (:generator 40
     ;; Move OBJECT into a temp we can bash on, and initialize the count.
     (move ptr object)
-    (inst xor count count)
+    (zeroize count)
     ;; If we are starting with NIL, then it's really easy.
     (inst cmp ptr nil-value)
     (inst jmp :e DONE)
@@ -66,7 +66,7 @@
     ;; Get a copy of OBJECT in a register we can bash on, and
     ;; initialize COUNT.
     (move ptr object)
-    (inst xor count count)
+    (zeroize count)
     ;; If we are starting with NIL, we be done.
     (inst cmp ptr nil-value)
     (inst jmp :e DONE)
index 51fa7d7..72f3f96 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.9.18.51"
+"0.9.18.52"