Skip to content

Commit

Permalink
0.9.18.52:
Browse files Browse the repository at this point in the history
	If possible, use a shorter XOR instruction on x86-64 when we zero
	  a register.
  • Loading branch information
Nathan Froyd committed Nov 14, 2006
1 parent 3e1d39f commit e188f84
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/compiler/x86-64/alloc.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
(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)))

Expand Down
10 changes: 5 additions & 5 deletions src/compiler/x86-64/arith.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@
(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)
Expand Down Expand Up @@ -786,7 +786,7 @@
(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)
Expand Down Expand Up @@ -896,7 +896,7 @@
(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)
Expand Down Expand Up @@ -927,7 +927,7 @@
(inst inc res)
(inst jmp DONE)
ZERO
(inst xor res res)
(zeroize res)
DONE))

(define-vop (unsigned-byte-64-len)
Expand All @@ -944,7 +944,7 @@
(inst inc res)
(inst jmp DONE)
ZERO
(inst xor res res)
(zeroize res)
DONE))

(define-vop (unsigned-byte-64-count)
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/x86-64/call.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@
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
Expand Down Expand Up @@ -1032,7 +1032,7 @@
;; 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)
Expand Down Expand Up @@ -1194,7 +1194,7 @@
;; 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.
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/x86-64/cell.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
(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)
Expand Down
19 changes: 15 additions & 4 deletions src/compiler/x86-64/move.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,25 @@

(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))
(let ((val (tn-value x)))
(etypecase val
(integer
(if (zerop val)
(inst xor y y)
(zeroize y)
(inst mov y (fixnumize val))))
(symbol
(load-symbol y val))
Expand All @@ -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)
Expand Down Expand Up @@ -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))))
Expand Down Expand Up @@ -134,7 +145,7 @@
(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
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/x86-64/subprim.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion version.lisp-expr
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit e188f84

Please sign in to comment.