Changeset 8435


Ignore:
Timestamp:
Feb 7, 2008, 2:41:20 PM (13 years ago)
Author:
mb
Message:

Waste less space in %lfun-info.

Store pc->source mappings as vectors of 4 integers (instead of a plist). If all the characters in the source-text are 8bit
ascii (the really really common case) we store the text as an array of 8 bit integers.

Location:
branches/working-0711/ccl/compiler
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/compiler/X86/x86-disassemble.lisp

    r8421 r8435  
    27312731             (text (if source-info
    27322732                       (string-sans-most-whitespace
    2733                         (subseq (getf source-note :text)
     2733                        (subseq (%fast-uncompact (getf source-note :%text))
    27342734                                (car (getf source-info :source-text-range))
    27352735                                (cdr (getf source-info :source-text-range)))
  • branches/working-0711/ccl/compiler/X86/x862.lisp

    r8423 r8435  
    661661                (setf (%svref v i) ref-fun)))))))))
    662662
     663(defun pc-source-map-pc-start (source-mapping)
     664  (etypecase source-mapping
     665    (integer (ldb (byte 15 0) source-mapping))
     666    (vector (aref source-mapping 0))))
     667
     668(defun pc-source-map-pc-end (source-mapping)
     669  (etypecase source-mapping
     670    (integer (ldb (byte 15 15) source-mapping))
     671    (vector (aref source-mapping 1))))
     672
     673(defun pc-source-map-text-start (source-mapping)
     674  (etypecase source-mapping
     675    (integer (ldb (byte 15 30) source-mapping))
     676    (vector (aref source-mapping 2))))
     677
     678(defun pc-source-map-text-end (source-mapping)
     679  (etypecase source-mapping
     680    (integer (ldb (byte 15 45) source-mapping))
     681    (vector (aref source-mapping 3))))
     682
     683(defun small-positive-integer-p (number &optional (biggest-small-value (ash 1 15)))
     684  (< 0 number biggest-small-value))
     685
     686(defun generate-pc-source-mapping (pc-start pc-end text-start text-end)
     687  (if (every #'small-positive-integer-p
     688             (list pc-start pc-end text-start text-end))
     689    (let ((mapping 0))
     690      (setf (ldb (byte 15 0) mapping)  pc-start
     691            (ldb (byte 15 15) mapping) pc-end
     692            (ldb (byte 15 30) mapping) text-start
     693            (ldb (byte 15 45) mapping) text-end)
     694      mapping)
     695    (vector pc-start pc-end text-start text-end)))
     696
     697(defstruct (pc-source-mapping (:type vector))
     698  pc-start
     699  pc-end
     700  text-start
     701  text-end)
     702
    663703(defun x862-generate-pc-source-map (definition-source-note emitted-source-notes)
    664704  (when *compiler-record-source*
    665     (let ((def-start (source-note-start definition-source-note)))
    666       (mapcar (lambda (start)
    667                 (list :pc-range (cons (x862-vinsn-note-label-address
    668                                        start
    669                                        t)
    670                                       (x862-vinsn-note-label-address
    671                                        (vinsn-note-peer start)
    672                                        nil))
    673                       :source-text-range (cons (- (source-note-start (aref (vinsn-note-info start) 0))
    674                                                   def-start)
    675                                                (- (source-note-end (aref (vinsn-note-info start) 0))
    676                                                   def-start))))
    677               emitted-source-notes))))
     705    (let ((def-start (source-note-start definition-source-note))
     706          (vec (make-array (length emitted-source-notes))))
     707      (flet ((pc-start (note) (aref note ))))
     708      (map-into vec
     709                (lambda (start)
     710                  (make-pc-source-mapping :pc-start (x862-vinsn-note-label-address
     711                                                     start
     712                                                     t)
     713                                          :pc-end (x862-vinsn-note-label-address
     714                                                   (vinsn-note-peer start)
     715                                                   nil)
     716                                          :text-start (- (source-note-start (aref (vinsn-note-info start) 0))
     717                                                         def-start)
     718                                          :text-end (- (source-note-end (aref (vinsn-note-info start) 0))
     719                                                       def-start)))
     720                emitted-source-notes)
     721      vec)))
    678722
    679723(defun x862-vinsn-note-label-address (note &optional start-p sym)
  • branches/working-0711/ccl/compiler/nx0.lisp

    r8424 r8435  
    15931593         string)))))
    15941594
     1595(defun %fast-compact (string)
     1596  (let ((vec (make-array (length string) :element-type '(unsigned-byte 8))))
     1597    (loop
     1598      for char across string
     1599      for index upfrom 0
     1600      if (<= 0 (char-code char) 255)
     1601         do (setf (aref vec index) (char-code char))
     1602      else
     1603        do (return-from %fast-compact string))
     1604    vec))
     1605
     1606(defun %fast-uncompact (data)
     1607  (if (stringp data)
     1608    data
     1609    (let ((string (make-array (length data) :element-type 'character)))
     1610      (map-into string #'code-char data)
     1611      string)))
     1612
    15951613(defun record-source-location-on-stream-p (stream)
    15961614  (and *compiler-record-source*
     
    16021620  start
    16031621  end
    1604   text
     1622  %text
    16051623  form
    16061624  children)
     
    16121630                       :start (+ start (or *compile-file-original-buffer-offset* 0))
    16131631                       :end (+ end (or *compile-file-original-buffer-offset* 0))
    1614                        :text (or text (substream stream start end))
     1632                       :%text (%fast-compact (or text (substream stream start end)))
    16151633                       :form form
    16161634                       :children children)))
     1635
     1636(defmethod source-note-text ((source-note source-note))
     1637  (%fast-uncompact (source-note-%text source-note)))
     1638
     1639(defmethod (setf source-note-text) (text (source-note source-note))
     1640  (setf (source-note-%text source-note) (%fast-compact text)))
    16171641
    16181642;;; we don't actually store source-note structs in the fasl since that runs into problems dumping
     
    16221646  (append (when start (list :start (source-note-start note)))
    16231647          (when end   (list :end   (source-note-end   note)))
    1624           (when text  (list :text  (source-note-text  note)))
     1648          (when text  (list :%text  (source-note-%text  note)))
    16251649          (when form  (list :form  (source-note-form  note)))
    16261650          (when children (list :children (source-note-children note)))
     
    16681692      (let* ((best-guess nil)
    16691693             (best-length nil))
    1670         (dolist (pc-map pc-source-map)
    1671           (let ((pc-start (car (getf pc-map :pc-range)))
    1672                 (pc-end (cdr (getf pc-map :pc-range))))
    1673             (when (<= pc-start pc pc-end)
    1674               ;; possible match, see if it's the better than best-guess
    1675               (when (or (null best-guess)
    1676                         (< (- pc-end pc-start) best-length))
    1677                 (setf best-guess pc-map
    1678                       best-length (- pc-end pc-start))))))
    1679        
     1694        (loop
     1695          for pc-map across pc-source-map
     1696          for pc-start = (aref pc-map 0)
     1697          for pc-end = (aref pc-map 1)
     1698          do (when (and (<= pc-start pc pc-end)
     1699                        (or (null best-guess)
     1700                            (< (- pc-end pc-start) best-length)))
     1701               (setf best-guess pc-map
     1702                     best-length (- pc-end pc-start))))
    16801703        (when best-guess
    1681           (list :pc-range (getf best-guess :pc-range)
    1682                 :source-text-range (getf best-guess :source-text-range)
     1704          (list :pc-range (cons (aref best-guess 0)
     1705                                (aref best-guess 1))
     1706                :source-text-range (cons (aref best-guess 2)
     1707                                         (aref best-guess 3))
    16831708                :file-name (getf function-source-note :file-name)
    16841709                :text (getf function-source-note :text)))))))
Note: See TracChangeset for help on using the changeset viewer.