Changeset 13535 for release/1.4/source


Ignore:
Timestamp:
Mar 16, 2010, 6:33:28 PM (10 years ago)
Author:
rme
Message:

Merge r13529 through r13532 (special-case divisor of -1 in %fixnum-truncate)
from trunk to 1.4 branch. Fixes ticket:666.

Location:
release/1.4/source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • release/1.4/source

  • release/1.4/source/compiler

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • release/1.4/source/level-0/PPC/ppc-numbers.lisp

    r13075 r13535  
    207207
    208208
    209 ;;;; maybe this could be smarter but frankly scarlett I dont give a damn
     209;;; maybe this could be smarter but frankly scarlett I dont give a damn
     210;;; ticket:666 describes one reason to give a damn.
    210211#+ppc32-target
    211212(defppclapfunction %fixnum-truncate ((dividend arg_y) (divisor arg_z))
     
    217218        (boxed-quotient temp1)
    218219        (remainder temp2))
     220    (cmpwi divisor '-1)   
    219221    (unbox-fixnum unboxed-dividend dividend)
    220222    (unbox-fixnum unboxed-divisor divisor)
     223    (beq @neg)
    221224    (divwo. unboxed-quotient unboxed-dividend unboxed-divisor)          ; set OV if divisor = 0
    222225    (box-fixnum boxed-quotient unboxed-quotient)
     
    236239    (set-nargs 2)
    237240    (la temp0 8 vsp)
     241    (ba .SPvalues)
     242    @neg
     243    (nego. dividend dividend)
     244    (lwz arg_z '*least-positive-bignum* nfn)
     245    (bns @ret)
     246    (mtxer rzero)
     247    (lwz dividend ppc32::symbol.vcell arg_z)
     248    @ret
     249    (mr temp0 vsp)
     250    (vpush dividend)
     251    (vpush rzero)
     252    (set-nargs 2)
    238253    (ba .SPvalues)))
    239254
     
    247262        (boxed-quotient temp1)
    248263        (remainder temp2))
     264    (cmpdi divisor '-1)
    249265    (unbox-fixnum unboxed-dividend dividend)
    250266    (unbox-fixnum unboxed-divisor divisor)
     267    (beq @neg)
    251268    (divdo. unboxed-quotient unboxed-dividend unboxed-divisor)          ; set OV if divisor = 0
    252269    (box-fixnum boxed-quotient unboxed-quotient)
     
    266283    (set-nargs 2)
    267284    (la temp0 '2 vsp)
    268     (ba .SPvalues)))
     285    (ba .SPvalues)
     286    @neg
     287    (nego. dividend dividend)
     288    (ld arg_z '*least-positive-bignum* nfn)
     289    (bns @ret)
     290    (mtxer rzero)
     291    (ld dividend ppc64::symbol.vcell arg_z)
     292    @ret
     293    (mr temp0 vsp)
     294    (vpush dividend)
     295    (vpush rzero)
     296    (set-nargs 2)
     297    (ba .SPvalues)   
     298    ))
    269299
    270300
  • release/1.4/source/level-0/X86

  • release/1.4/source/level-0/X86/X8632/x8632-numbers.lisp

    r13075 r13535  
    114114  (single-value-return))
    115115
     116
     117
    116118;;; We'll get a SIGFPE if divisor is 0.
    117119(defx8632lapfunction %fixnum-truncate ((dividend arg_y) (divisor arg_z))
     120  (cmpl ($ '-1) (% divisor))
     121  (je @neg)
    118122  (mark-as-imm temp0)
    119123  (mark-as-imm temp1)
     
    131135  (push (% arg_z))
    132136  (push (% arg_y))
     137  (set-nargs 2)
     138  (jmp-subprim .SPvalues)
     139  @neg
     140  (negl (% dividend))
     141  (load-constant *least-positive-bignum* arg_z)
     142  (cmovol (@ x8632::symbol.vcell (% arg_z)) (% dividend))
     143  (movl (% esp) (% temp0))
     144  (pushl (% dividend))
     145  (pushl ($ 0))
    133146  (set-nargs 2)
    134147  (jmp-subprim .SPvalues))
  • release/1.4/source/level-0/X86/x86-numbers.lisp

    r13075 r13535  
    112112
    113113
     114
    114115;;; We'll get a SIGFPE if divisor is 0.
    115116;;; Don't use %rbp.  Trust callback_for_interrupt() to preserve
     
    117118(defx86lapfunction %fixnum-truncate ((dividend arg_y) (divisor arg_z))
    118119  (save-simple-frame)
     120  (cmpq ($ '-1) (% divisor))
     121  (je @neg)
    119122  (unbox-fixnum divisor imm0)
    120123  (movq (% imm0) (% imm2))
     
    129132  (pushq (% arg_y))
    130133  (set-nargs 2)
     134  (jmp-subprim .SPvalues)
     135  @neg
     136  (negq (% dividend))
     137  (load-constant *least-positive-bignum* arg_z)
     138  (cmovoq (@ x8664::symbol.vcell (% arg_z)) (% dividend))
     139  (pop (% rbp))
     140  (movq (% rsp) (% temp0))
     141  (pushq (% dividend))
     142  (pushq ($ 0))
     143  (set-nargs 2)
    131144  (jmp-subprim .SPvalues))
     145 
    132146
    133147(defx86lapfunction called-for-mv-p ()
  • release/1.4/source/level-0/l0-numbers.lisp

    r13133 r13535  
    11401140         #+32-bit-target
    11411141         `(target::with-stack-short-floats ((fnum ,number)
    1142                                            (f2))
     1142                                            (f2))
    11431143           (let ((res (%unary-truncate (%short-float/-2! fnum ,divisor f2))))
    11441144             (values res
    11451145                     (%short-float--2 fnum (%short-float*-2! (%short-float res f2) ,divisor f2)))))
    1146           #+64-bit-target
     1146         #+64-bit-target
    11471147         `(let* ((temp (%short-float ,number))
    11481148                 (res (%unary-truncate (/ (the short-float temp)
     
    11521152             (the short-float (* (the short-float (%short-float res))
    11531153                                 (the short-float ,divisor)))))))
    1154          )
     1154       )
    11551155    (number-case number
    11561156      (fixnum
    1157        (if (eql number target::target-most-negative-fixnum)
    1158          (if (zerop divisor)
    1159            (error 'division-by-zero :operation 'truncate :operands (list number divisor))
    1160            (with-small-bignum-buffers ((bn number))
    1161              (multiple-value-bind (quo rem) (truncate bn divisor)
    1162                (if (eq quo bn)
    1163                  (values number rem)
    1164                  (values quo rem)))))
    1165          (number-case divisor
    1166            (fixnum (if (eq divisor 1) (values number 0) (%fixnum-truncate number divisor)))
    1167            (bignum (values 0 number))
    1168            (double-float (truncate-rat-dfloat number divisor))
    1169            (short-float (truncate-rat-sfloat number divisor))
    1170            (ratio (let ((q (truncate (* number (%denominator divisor)) ; this was wrong
    1171                                      (%numerator divisor))))
    1172                     (values q (- number (* q divisor))))))))
     1157       (number-case divisor
     1158         (fixnum (if (eq divisor 1) (values number 0) (%fixnum-truncate number divisor)))
     1159         (bignum (values 0 number))
     1160         (double-float (truncate-rat-dfloat number divisor))
     1161         (short-float (truncate-rat-sfloat number divisor))
     1162         (ratio (let ((q (truncate (* number (%denominator divisor)) ; this was wrong
     1163                                   (%numerator divisor))))
     1164                  (values q (- number (* q divisor)))))))
    11731165      (bignum (number-case divisor
    11741166                (fixnum (if (eq divisor 1) (values number 0)
     
    11991191                                    (/ (the short-float number)
    12001192                                       (the short-float divisor)))))
    1201                             (values res
    1202                                     (- (the short-float number)
    1203                                        (* (the short-float (%short-float res))
    1204                                           (the short-float divisor))))))
     1193                          (values res
     1194                                  (- (the short-float number)
     1195                                     (* (the short-float (%short-float res))
     1196                                        (the short-float divisor))))))
    12051197                       ((fixnum bignum ratio)
    12061198                        #+32-bit-target
    12071199                        (target::with-stack-short-floats ((fdiv divisor)
    1208                                                          (f2))
     1200                                                          (f2))
    12091201                          (let ((res (%unary-truncate (%short-float/-2! number fdiv f2))))
    12101202                            (values res
  • release/1.4/source/level-1/l1-init.lisp

    r13075 r13535  
    161161  "the fixnum closest in value to negative infinity")
    162162
     163(defstatic *least-positive-bignum* (1+ target::target-most-positive-fixnum)
     164  "used internally; value should be treated as a constant")
     165
    163166
    164167(defconstant lambda-list-keywords
  • release/1.4/source/lisp-kernel

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • release/1.4/source/scripts

    • Property svn:mergeinfo changed (with no actual effect on merging)
Note: See TracChangeset for help on using the changeset viewer.