;;; platforms with 64-bit word size.
#!-sb-fluid (declaim (inline round-to-dualword))
(defun round-to-dualword (size)
- (declare (unsigned-byte size))
- (ldb (byte n-word-bits 0)
- (logand (+ size lowtag-mask) (lognot lowtag-mask))))
+ (logand (the word (+ size lowtag-mask)) (lognot lowtag-mask)))
;;; Return the total size of a vector in bytes, including any pad.
#!-sb-fluid (declaim (inline vector-total-size))
(defun vector-total-size (obj info)
- (declare (type (simple-array * (*)) obj))
(let ((shift (room-info-length info))
- (len (+ (length obj)
+ (len (+ (length (the (simple-array * (*)) obj))
(ecase (room-info-kind info)
(:vector 0)
(:string 1)))))
(eq (room-info-kind info) :lowtag))
(let ((size (* cons-size n-word-bytes)))
(funcall fun
- (make-lisp-obj (logior (sap-int current)
+ (%make-lisp-obj (logior (sap-int current)
list-pointer-lowtag))
list-pointer-lowtag
size)
(setq current (sap+ current size))))
((eql header-widetag closure-header-widetag)
- (let* ((obj (make-lisp-obj (logior (sap-int current)
+ (let* ((obj (%make-lisp-obj (logior (sap-int current)
fun-pointer-lowtag)))
(size (round-to-dualword
- (* (1+ (get-closure-length obj)) n-word-bytes))))
+ (* (the fixnum (1+ (get-closure-length obj)))
+ n-word-bytes))))
(funcall fun obj header-widetag size)
(setq current (sap+ current size))))
((eq (room-info-kind info) :instance)
- (let* ((obj (make-lisp-obj
+ (let* ((obj (%make-lisp-obj
(logior (sap-int current) instance-pointer-lowtag)))
(size (round-to-dualword
(* (+ (%instance-length obj) 1) n-word-bytes))))
(aver (zerop (logand size lowtag-mask)))
(setq current (sap+ current size))))
(t
- (let* ((obj (make-lisp-obj
+ (let* ((obj (%make-lisp-obj
(logior (sap-int current) other-pointer-lowtag)))
(size (ecase (room-info-kind info)
(:fixed
(round-to-dualword
(* (1+ (get-header-data obj)) n-word-bytes)))
(:code
- (+ (* (get-header-data obj) n-word-bytes)
+ (+ (the fixnum
+ (* (get-header-data obj) n-word-bytes))
(round-to-dualword
- (* (%code-code-size obj) n-word-bytes)))))))
+ (* (the fixnum (%code-code-size obj))
+ n-word-bytes)))))))
(funcall fun obj header-widetag size)
- (aver (zerop (logand size lowtag-mask)))
- (setq current (sap+ current size))))))))))))
+ (macrolet ((frob ()
+ `(progn
+ (aver (zerop (logand size lowtag-mask)))
+ (setq current (sap+ current size)))))
+ (etypecase size
+ (fixnum (frob))
+ (word (frob))))))))))))))
\f
;;;; MEMORY-USAGE
;;; Return a list of 3-lists (bytes object type-name) for the objects
;;; allocated in Space.
(defun type-breakdown (space)
- (let ((sizes (make-array 256 :initial-element 0))
- (counts (make-array 256 :initial-element 0 :element-type 'fixnum)))
+ (let ((sizes (make-array 256 :initial-element 0 :element-type '(unsigned-byte #.sb!vm:n-word-bits)))
+ (counts (make-array 256 :initial-element 0 :element-type '(unsigned-byte #.sb!vm:n-word-bits))))
(map-allocated-objects
(lambda (obj type size)
- (declare (index type) (optimize (speed 3)) (ignore obj))
+ (declare (word size) (optimize (speed 3)) (ignore obj))
(incf (aref sizes type) size)
(incf (aref counts type)))
space)
(maphash (lambda (k v)
(declare (ignore k))
(let ((sum 0))
+ (declare (unsigned-byte sum))
(dolist (space-total v)
(incf sum (first (cdr space-total))))
(summary-totals (cons sum v))))
(format t "~2&Summary of spaces: ~(~{~A ~}~)~%" spaces)
(let ((summary-total-bytes 0)
(summary-total-objects 0))
- (declare (fixnum summary-total-objects))
+ (declare (unsigned-byte summary-total-bytes summary-total-objects))
(dolist (space-totals
(mapcar #'cdr (sort (summary-totals) #'> :key #'car)))
(let ((total-objects 0)
(total-bytes 0)
name)
- (declare (fixnum total-objects))
+ (declare (unsigned-byte total-objects total-bytes))
(collect ((spaces))
(dolist (space-total space-totals)
(let ((total (cdr space-total)))
0))
(reported-bytes 0)
(reported-objects 0))
- (declare (fixnum total-objects cutoff-point reported-objects))
+ (declare (unsigned-byte total-objects total-bytes cutoff-point reported-objects
+ reported-bytes))
(loop for (bytes objects name) in types do
(when (<= bytes cutoff-point)
(format t " ~10:D bytes for ~9:D other object~2:*~P.~%"
(type unsigned-byte total-bytes))
(map-allocated-objects
(lambda (obj type size)
- (declare (fixnum size))
(when (eql type code-header-widetag)
- (incf total-bytes size)
- (let ((words (%code-code-size obj))
- (sap (code-instructions obj)))
+ (let ((words (truly-the fixnum (%code-code-size obj)))
+ (sap (truly-the system-area-pointer
+ (%primitive code-instructions obj)))
+ (size size))
+ (declare (fixnum size))
+ (incf total-bytes size)
(incf code-words words)
(dotimes (i words)
(when (zerop (sap-ref-word sap (* i n-word-bytes)))
(declare (inline map-allocated-objects))
(map-allocated-objects
(lambda (obj type size)
- (declare (fixnum size))
(case type
(#.code-header-widetag
- (let ((inst-words (%code-code-size obj)))
- (declare (type fixnum inst-words))
+ (let ((inst-words (truly-the fixnum (%code-code-size obj)))
+ (size size))
+ (declare (type fixnum size inst-words))
(incf non-descriptor-bytes (* inst-words n-word-bytes))
(incf descriptor-words
(- (truncate size n-word-bytes) inst-words))))
#.simple-array-unsigned-byte-32-widetag
#.simple-array-signed-byte-8-widetag
#.simple-array-signed-byte-16-widetag
- ; #.simple-array-signed-byte-30-widetag
+ ;; #.simple-array-signed-byte-30-widetag
#.simple-array-signed-byte-32-widetag
#.simple-array-single-float-widetag
#.simple-array-double-float-widetag
#.sap-widetag
#.weak-pointer-widetag
#.instance-header-widetag)
- (incf descriptor-words (truncate size n-word-bytes)))
+ (incf descriptor-words (truncate (the fixnum size) n-word-bytes)))
(t
(error "bogus widetag: ~W" type))))
space))
(let ((totals (make-hash-table :test 'eq))
(total-objects 0)
(total-bytes 0))
- (declare (fixnum total-objects))
+ (declare (unsigned-byte total-objects total-bytes))
(map-allocated-objects
(lambda (obj type size)
- (declare (fixnum size) (optimize (speed 3)))
+ (declare (optimize (speed 3)))
(when (eql type instance-header-widetag)
(incf total-objects)
- (incf total-bytes size)
(let* ((classoid (layout-classoid (%instance-ref obj 0)))
- (found (gethash classoid totals)))
+ (found (gethash classoid totals))
+ (size size))
+ (declare (fixnum size))
+ (incf total-bytes size)
(cond (found
- (incf (car found))
- (incf (cdr found) size))
+ (incf (the fixnum (car found)))
+ (incf (the fixnum (cdr found)) size))
(t
(setf (gethash classoid totals) (cons 1 size)))))))
space)
(let ((sorted (sort (totals-list) #'> :key #'cddr))
(printed-bytes 0)
(printed-objects 0))
- (declare (fixnum printed-objects))
+ (declare (unsigned-byte printed-bytes printed-objects))
(dolist (what (if top-n
(subseq sorted 0 (min (length sorted) top-n))
sorted))
(return-from print-allocated-objects (values)))
(unless count
- (let ((this-page (* (truncate addr pagesize) pagesize)))
+ (let ((this-page (* (the (values (unsigned-byte 32) t)
+ (truncate addr pagesize))
+ pagesize)))
(declare (type (unsigned-byte 32) this-page))
(when (/= this-page last-page)
(when (< pages-so-far pages)
(when (or (eq (symbol-name obj) object)
(eq (symbol-package obj) object)
(eq (symbol-plist obj) object)
- (eq (symbol-value obj) object))
+ (and (boundp obj)
+ (eq (symbol-value obj) object)))
(maybe-call fun obj)))))
space)))