- (aver (not (location= x alloc)))
- (aver (not (location= y alloc)))
- (let ((bignum (gen-label))
- (done (gen-label))
- (one-word-bignum (gen-label))
- (L1 (gen-label)))
- (inst bsr y x) ;find msb
- (inst cmov :z y x)
- (inst cmp y 60)
- (inst jmp :ae bignum)
- (inst lea y (make-ea :qword :index x :scale 8))
- (emit-label done)
- (assemble (*elsewhere*)
- (emit-label bignum)
- ;; Note: As on the mips port, space for a two word bignum is
- ;; always allocated and the header size is set to either one
- ;; or two words as appropriate.
- (inst cmp y 63)
- (inst jmp :l one-word-bignum)
- ;; two word bignum
- (inst mov y (logior (ash (1- (+ bignum-digits-offset 2))
- n-widetag-bits)
- bignum-widetag))
- (inst jmp L1)
- (emit-label one-word-bignum)
- (inst mov y (logior (ash (1- (+ bignum-digits-offset 1))
- n-widetag-bits)
- bignum-widetag))
- (emit-label L1)
- (pseudo-atomic
- (allocation alloc (pad-data-block (+ bignum-digits-offset 2)) node)
- (storew y alloc)
- (inst lea y (make-ea :byte :base alloc :disp other-pointer-lowtag))
- (storew x y bignum-digits-offset other-pointer-lowtag))
- (inst jmp done)))))
+ (let ((done (gen-label)))
+ (inst mov y #.(ash (1- (ash 1 (1+ n-fixnum-tag-bits)))
+ n-positive-fixnum-bits))
+ ;; The assembly routines test the sign flag from this one, so if
+ ;; you change stuff here, make sure the sign flag doesn't get
+ ;; overwritten before the CALL!
+ (inst test x y)
+ ;; Faster but bigger then SHL Y 4. The cost of doing this
+ ;; speculatively should be noise compared to bignum consing if
+ ;; that is needed and saves one branch.
+ (inst lea y (make-ea :qword :index x :scale (ash 1 n-fixnum-tag-bits)))
+ (inst jmp :z done)
+ (inst mov y x)
+ (inst lea temp-reg-tn
+ (make-ea :qword :disp
+ (make-fixup (ecase (tn-offset y)
+ (#.rax-offset 'alloc-unsigned-bignum-in-rax)
+ (#.rcx-offset 'alloc-unsigned-bignum-in-rcx)
+ (#.rdx-offset 'alloc-unsigned-bignum-in-rdx)
+ (#.rbx-offset 'alloc-unsigned-bignum-in-rbx)
+ (#.rsi-offset 'alloc-unsigned-bignum-in-rsi)
+ (#.rdi-offset 'alloc-unsigned-bignum-in-rdi)
+ (#.r8-offset 'alloc-unsigned-bignum-in-r8)
+ (#.r9-offset 'alloc-unsigned-bignum-in-r9)
+ (#.r10-offset 'alloc-unsigned-bignum-in-r10)
+ (#.r12-offset 'alloc-unsigned-bignum-in-r12)
+ (#.r13-offset 'alloc-unsigned-bignum-in-r13)
+ (#.r14-offset 'alloc-unsigned-bignum-in-r14)
+ (#.r15-offset 'alloc-unsigned-bignum-in-r15))
+ :assembly-routine)))
+ (inst call temp-reg-tn)
+ (emit-label done))))