Changeset 8439


Ignore:
Timestamp:
Feb 7, 2008, 12:44:29 PM (17 years ago)
Author:
marco baringer
Message:

More optimizations to source-location.

1) Only use substream to read in the toplevel definition's text, otherwise use displaced arrays.

2) When possible compact ps-source-mapping objcets directly into 64 bit integers

Location:
branches/working-0711/ccl
Files:
5 edited

Legend:

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

    r8435 r8439  
    27062706      usual)))
    27072707
    2708 
    27092708(defun string-sans-most-whitespace (string &optional (max-length (length string)))
    27102709  (with-output-to-string (sans-whitespace)
     
    27292728      (let* ((source-note (getf (%lfun-info function) 'function-source-note))
    27302729             (source-info (find-source-at-pc function pc))
    2731              (text (if source-info
     2730             (text (if (and source-info
     2731                            (plusp (car (getf source-info :source-text-range)))
     2732                            (plusp (cdr (getf source-info :source-text-range))))
    27322733                       (string-sans-most-whitespace
    27332734                        (subseq (%fast-uncompact (getf source-note :%text))
  • branches/working-0711/ccl/compiler/X86/x862.lisp

    r8435 r8439  
    611611                                      (when (and *compiler-record-source* *definition-source-note*)
    612612                                        (list 'function-source-note
    613                                               (source-note-to-list *definition-source-note* :form nil :children nil)))
     613                                              (source-note-for-%lfun-info *definition-source-note* :form nil :children nil)))
    614614                                      (when *x862-recorded-symbols*
    615615                                        (list 'function-symbol-map (x862-digest-symbols)))
     
    685685
    686686(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)
     687  (cond
     688    ((every #'small-positive-integer-p (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    ((every #'plusp (list pc-start pc-end text-start text-end))
     696     (vector pc-start pc-end text-start text-end))
     697    (t nil)))
    702698
    703699(defun x862-generate-pc-source-map (definition-source-note emitted-source-notes)
    704700  (when *compiler-record-source*
    705701    (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
     702          (vec (make-array (length emitted-source-notes) :fill-pointer 0)))
     703      (loop
     704        for start in emitted-source-notes
     705        for mapping = (generate-pc-source-mapping (x862-vinsn-note-label-address
     706                                                       start
     707                                                       t)
     708                                                  (x862-vinsn-note-label-address
    714709                                                   (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)))
     710                                                       nil)
     711                                                  (- (source-note-start (aref (vinsn-note-info start) 0))
     712                                                            def-start)
     713                                                  (- (source-note-end (aref (vinsn-note-info start) 0))
     714                                                            def-start))
     715        when mapping
     716          do (vector-push-extend mapping vec))
     717      (let ((simple-vec (make-array (length vec))))
     718        (map-into simple-vec #'identity vec)
     719        simple-vec))))
    722720
    723721(defun x862-vinsn-note-label-address (note &optional start-p sym)
  • branches/working-0711/ccl/compiler/nx0.lisp

    r8435 r8439  
    15691569(defvar *compile-file-original-buffer-offset* nil)
    15701570
    1571 (defun substream (stream start &optional end)
     1571(defun substream (stream start end)
    15721572  "like subseq, but on streams that support file-position. Leaves stream positioned where it was
    15731573before calling substream."
     
    15791579    ((not (open-stream-p stream))
    15801580     (if (typep stream 'file-stream)
    1581           (if (probe-file (stream-pathname stream))
    1582               (with-open-file (f (stream-pathname stream)) ; I should really understand how this happens.
    1583                 (substream f start end))
    1584               "")
    1585           ""))
     1581       (if (probe-file (stream-pathname stream))
     1582         (with-open-file (f (stream-pathname stream)) ; I should really understand how this happens.
     1583           (substream f start end))
     1584         "")
     1585       ""))
    15861586    (t
    15871587     (let ((now (file-position stream)))
     
    16301630                       :start (+ start (or *compile-file-original-buffer-offset* 0))
    16311631                       :end (+ end (or *compile-file-original-buffer-offset* 0))
    1632                        :%text (%fast-compact (or text (substream stream start end)))
     1632                       :%text text
    16331633                       :form form
    16341634                       :children children)))
     
    16431643;;; the struct.
    16441644
    1645 (defun source-note-to-list (note &key (start t) (end t) (text t) (form t) (children t) (file-name t))
     1645(defun source-note-for-%lfun-info (note &key (start t) (end t) (text t) (form t) (children t) (file-name t))
    16461646  (append (when start (list :start (source-note-start note)))
    1647           (when end   (list :end   (source-note-end   note)))
    1648           (when text  (list :%text  (source-note-%text  note)))
    1649           (when form  (list :form  (source-note-form  note)))
     1647          (when end   (list :end  (source-note-end   note)))
     1648          (when text  (list :%text (%fast-compact (source-note-%text  note))))
     1649          (when form  (list :form (source-note-form  note)))
    16501650          (when children (list :children (source-note-children note)))
    16511651          (when file-name (list :file-name (source-note-file-name note)))))
     
    16751675    map))
    16761676
     1677(defun compute-children-text (source-note stream)
     1678  (unless (source-note-%text source-note)
     1679    (setf (source-note-%text source-note)
     1680          (substream stream (source-note-start source-note) (source-note-end source-note))))
     1681  (dolist (nested (source-note-children source-note))
     1682    (when nested
     1683      (unless (source-note-%text nested)
     1684        (setf (source-note-%text nested)
     1685              (make-array (- (source-note-end nested) (source-note-start nested))
     1686                          :displaced-to (source-note-%text source-note)
     1687                          :displaced-index-offset (- (source-note-start nested)
     1688                                                     (source-note-start source-note)))))
     1689      (compute-children-text nested nil)))
     1690  source-note)
     1691
    16771692(defun nx1-source-note (nx1-code)
    16781693  "Return the source-note for the form which generated NX1-CODE."
     
    16941709        (loop
    16951710          for pc-map across pc-source-map
    1696           for pc-start = (aref pc-map 0)
    1697           for pc-end = (aref pc-map 1)
     1711          for pc-start = (pc-source-map-pc-start pc-map)
     1712          for pc-end = (pc-source-map-pc-end pc-map)
    16981713          do (when (and (<= pc-start pc pc-end)
    16991714                        (or (null best-guess)
     
    17021717                     best-length (- pc-end pc-start))))
    17031718        (when best-guess
    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))
     1719          (list :pc-range (cons (pc-source-map-pc-start best-guess)
     1720                                (pc-source-map-pc-end best-guess))
     1721                :source-text-range (cons (pc-source-map-text-start best-guess)
     1722                                         (pc-source-map-text-end best-guess))
    17081723                :file-name (getf function-source-note :file-name)
    17091724                :text (getf function-source-note :text)))))))
  • branches/working-0711/ccl/level-1/l1-reader.lisp

    r8424 r8439  
    25032503              (values form
    25042504                      t
    2505                       (when (and (consp form) (record-source-location-on-stream-p stream))
     2505                      (when (and (not (eql t nested-source-notes))
     2506                                 (consp form)
     2507                                 (record-source-location-on-stream-p stream))
     2508                        ;; mb 2008-02-07: sometime the nested-source-notes end with t, don't know
     2509                        ;; why. don't really care here.
     2510                       
     2511                        (let ((last (last nested-source-notes)))
     2512                          (when (atom (cdr last))
     2513                            ;; dotted list.
     2514                            (setf (cdr last) (list (cdr last)))))
    25062515                        (make-source-note :stream stream
    25072516                                          :start (1- start)
    25082517                                          :end end
    25092518                                          :form (car vals)
    2510                                           :children (labels ((rec (note)
    2511                                                                ;; use this recursive function to
    2512                                                                ;; remove nils since
    2513                                                                ;; nested-source-notes can be a
    2514                                                                ;; dotted list or an atom
    2515                                                                (cond
    2516                                                                  ((consp note)
    2517                                                                   (if (null (car note))
    2518                                                                       (rec (cdr note))
    2519                                                                       (cons (car note) (rec (cdr note)))))
    2520                                                                  ((source-note-p note)
    2521                                                                   note)
    2522                                                                  #| ((null note) '())
    2523                                                                  (t (error "Don't know how to deal with a source note like ~S."
    2524                                                                            nested-source-notes)) |# )))
    2525                                                       (rec nested-source-notes)))))))))))
     2519                                          :children nested-source-notes)))))))))
    25262520
    25272521#|
    25282522(defun %parse-expression-test (string)
    2529   (let* ((stream (make-string-input-stream string)))
    2530     (%parse-expression stream (read-char stream t) nil)))
     2523(let* ((stream (make-string-input-stream string)))
     2524(%parse-expression stream (read-char stream t) nil)))
    25312525
    25322526(%parse-expression-test ";hello")
  • branches/working-0711/ccl/lib/nfcomp.lisp

    r8421 r8439  
    425425                      (return))
    426426                    (setf form -form
    427                           *definition-source-note* source-note
    428                           *form-source-note-map* (make-source-note-form-map source-note
     427                          *definition-source-note* (compute-children-text source-note *fcomp-stream*)
     428                          *form-source-note-map* (make-source-note-form-map *definition-source-note*
    429429                                                                            *form-source-note-map*))))))
    430430            (fcomp-form form env processing-mode)
     
    497497      (record-form-source-equivalent/list form body)
    498498      (fcomp-macrolet body env processing-mode))
    499     ;; special case for passing around source-location info
    500     (%source-note (fcomp-form (list 'quote (source-note-to-list *definition-source-note*))
    501                               env processing-mode))
    502499    ((%include include) (fcomp-include form env processing-mode))
    503500    (t
Note: See TracChangeset for help on using the changeset viewer.