From: Nikodemus Siivola Date: Fri, 5 Aug 2011 09:05:24 +0000 (+0300) Subject: export MOST-POSITIVE-WORD from SB-EXT X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=fb15ad0ff2373a50b3b0717f705c49339b39f996;p=sbcl.git export MOST-POSITIVE-WORD from SB-EXT We need it internally anyways, and since we export the WORD type, we might just as well export the constant too. --- diff --git a/package-data-list.lisp-expr b/package-data-list.lisp-expr index e5bffc9..b17b5ed 100644 --- a/package-data-list.lisp-expr +++ b/package-data-list.lisp-expr @@ -601,6 +601,7 @@ like *STACK-TOP-HINT* and unsupported stuff like *TRACED-FUN-LIST*." "ATOMIC-INCF" "ATOMIC-DECF" "WORD" + "MOST-POSITIVE-WORD" ;; Time related things "CALL-WITH-TIMING" diff --git a/src/code/profile.lisp b/src/code/profile.lisp index c4d2750..da4f0b6 100644 --- a/src/code/profile.lisp +++ b/src/code/profile.lisp @@ -15,8 +15,6 @@ ;;;; Thread safe, and reasonably fast: in common case increment is just an ;;;; ATOMIC-INCF, in overflow case grab a lock and increment overflow counter. -(defconstant +most-positive-word+ (1- (expt 2 sb-vm:n-word-bits))) - (declaim (inline make-counter)) (defstruct (counter (:constructor make-counter) (:copier nil)) (word 0 :type sb-vm:word) @@ -36,11 +34,11 @@ ;; Increment the word-sized counter. If it overflows, record the ;; overflow. (let ((prev (atomic-incf (counter-word counter) d))) - (when (< (logand +most-positive-word+ (+ prev d)) prev) + (when (< (logand most-positive-word (+ prev d)) prev) (%incf-overflow))))) ;; DELTA can potentially be a bignum -- cut it down to word-size. (unless (typep delta 'sb-vm:word) - (multiple-value-bind (n r) (truncate delta (1+ +most-positive-word+)) + (multiple-value-bind (n r) (truncate delta (1+ most-positive-word)) (%incf-overflow n) (setf delta r))) ;; ATOMIC-INCF can at most handle SIGNED-WORD: if DELTA doesn't fit that, @@ -57,7 +55,7 @@ (defun counter-count (counter) (+ (counter-word counter) - (* (counter-overflow counter) (1+ +most-positive-word+)))) + (* (counter-overflow counter) (1+ most-positive-word)))) ;;;; High resolution timer diff --git a/src/compiler/generic/early-vm.lisp b/src/compiler/generic/early-vm.lisp index feb1abd..897d830 100644 --- a/src/compiler/generic/early-vm.lisp +++ b/src/compiler/generic/early-vm.lisp @@ -46,6 +46,9 @@ #!+sb-doc "the fixnum closest in value to negative infinity") +(def!constant most-positive-word (1- (expt 2 n-word-bits)) + "The most positive integer that is of type SB-EXT:WORD.") + (def!constant most-positive-exactly-single-float-fixnum (min #xffffff sb!xc:most-positive-fixnum)) (def!constant most-negative-exactly-single-float-fixnum