Changeset 13248


Ignore:
Timestamp:
Dec 3, 2009, 10:33:35 AM (10 years ago)
Author:
gb
Message:

Define HANDLE-FIXNUM-OVERFLOW-INLINE vinsn, which does most of its
work in the "uuo section" (e.g., at the end of the function); this
helps to keep that code out of the icache and allows us to use a
(predicted not taken) forward conditional branch to reach the overflow
case.

Make the 64-bit version a few bytes shorter (by flipping the sign
bit before and after shifting, rather than loading a 64-bit constant
and doing an XOR.)

Should probably do the same for other things that conditionally
box bignums.

Location:
trunk/source/compiler/X86
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/compiler/X86/X8632/x8632-vinsns.lisp

    r13067 r13248  
    11061106  (movl (:$l (- 8 x8632::fulltag-misc)) (:%l imm)))
    11071107
     1108(define-x8632-vinsn handle-fixnum-overflow-inline
     1109    (()
     1110     ((val :lisp)
     1111      (no-overflow
     1112       :label))
     1113     ((imm (:u32 #.x8632::imm0))
     1114      (freeptr (:lisp #.x8632::allocptr))))
     1115  (jo :overflow)
     1116  (:uuo-section)
     1117  :overflow
     1118  (movl (:%l val) (:%l imm))
     1119  (sarl (:$ub x8632::fixnumshift) (:%l imm))
     1120  (xorl (:$l #xc0000000) (:%l imm))
     1121  ;; stash bignum digit
     1122  (movd (:%l imm) (:%mmx x8632::mm1))
     1123  ;; set header
     1124  (movl (:$l x8632::one-digit-bignum-header) (:%l imm))
     1125  (movd (:%l imm) (:%mmx x8632::mm0))
     1126  ;; need 8 bytes of aligned memory for 1 digit bignum
     1127  (movl (:$l (- 8 x8632::fulltag-misc)) (:%l imm))
     1128  (subl (:%l imm) (:@ (:%seg :rcontext) x8632::tcr.save-allocptr))
     1129  (movl (:@ (:%seg :rcontext) x8632::tcr.save-allocptr) (:%l freeptr))
     1130  (rcmpl (:%l freeptr) (:@ (:%seg :rcontext) x8632::tcr.save-allocbase))
     1131  (ja :no-trap)
     1132  (uuo-alloc)
     1133  :no-trap
     1134  (movd (:%mmx x8632::mm0) (:@ x8632::misc-header-offset (:%l freeptr)))
     1135  (andb (:$b (lognot x8632::fulltagmask)) (:@ (:%seg :rcontext) x8632::tcr.save-allocptr))
     1136  ((:not (:pred = freeptr
     1137                (:apply %hard-regspec-value val)))
     1138   (movl (:%l freeptr) (:%l val)))
     1139  (movd (:%mmx x8632::mm1) (:@ x8632::misc-data-offset (:%l val)))
     1140  (jmp no-overflow))
     1141
     1142 
    11081143(define-x8632-vinsn set-bigits-after-fixnum-overflow (()
    11091144                                                      ((bignum :lisp)))
  • trunk/source/compiler/X86/X8664/x8664-vinsns.lisp

    r13221 r13248  
    12431243  (negq (:% val)))
    12441244
     1245(define-x8664-vinsn handle-fixnum-overflow-inline
     1246    (()
     1247     ((val :lisp)
     1248      (no-overflow :label))
     1249     ((header (:u64 #.x8664::imm0))
     1250      (scaled-size (:u64 #.x8664::imm1))
     1251      (freeptr (:lisp #.x8664::allocptr))))
     1252  (jo :overflow)
     1253  (:uuo-section)
     1254  :overflow
     1255  (movq (:%q val) (:%q scaled-size))
     1256  (btcq (:$ub 63) (:%q scaled-size))
     1257  (sarq (:$ub x8664::fixnumshift) (:%q scaled-size))
     1258  (btcq (:$ub 60) (:%q scaled-size))
     1259  (movd (:%q scaled-size) (:%mmx x8664::mm0))
     1260  (movq (:$l x8664::two-digit-bignum-header) (:%q header))
     1261  (movq (:$l (- 16 x8664::fulltag-misc)) (:%q scaled-size))
     1262  (subq (:%q scaled-size) (:rcontext x8664::tcr.save-allocptr))
     1263  (movq (:rcontext x8664::tcr.save-allocptr) (:%q freeptr))
     1264  (rcmpq (:%q freeptr) (:rcontext x8664::tcr.save-allocbase))
     1265  (:byte #x77) (:byte #x02)             ;(ja :no-trap)
     1266  (uuo-alloc)
     1267  :no-trap
     1268  (movq (:%q header) (:@ x8664::misc-header-offset (:%q freeptr)))
     1269  (andb (:$b (lognot x8664::fulltagmask)) (:rcontext x8664::tcr.save-allocptr))
     1270  ((:not (:pred = freeptr
     1271                (:apply %hard-regspec-value val)))
     1272   (movq (:%q freeptr) (:%q val)))
     1273  (movq (:%mmx x8664::mm0) (:@ x8664::misc-data-offset (:%q val)))
     1274  (jmp no-overflow))
     1275
     1276   
    12451277;;; This handles the 1-bit overflow from addition/subtraction/unary negation
    12461278(define-x8664-vinsn set-bigits-and-header-for-fixnum-overflow
Note: See TracChangeset for help on using the changeset viewer.