Ignore:
Timestamp:
Feb 17, 2008, 4:37:21 PM (13 years ago)
Author:
gz
Message:

checkpoint work in progress, mainly some final cleanup, reorg, don't try to track atoms, keep track of source through transforms; reporting implementation in library;cover.lisp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/gz-working/compiler/nx.lisp

    r8477 r8505  
    154154
    155155(defun note-contained-in-p (note parent)
    156   (loop for n = note then (source-note-source n) while (source-note-p n) thereis (eq n parent)))
    157 
    158 (defun nx-ensure-source-note (form parent-note)
    159   ;; Try to find a source note for this form; if the form doesn't come from user source, just make
    160   ;; a new record for it.  The act of matching up a source note with forms that might come from
    161   ;; macroexpansion is heuristic at best.  In general, err in favor of making a new record, because
    162   ;; that leads to fewer false positives in code coverage reporting.  But still, try hard to
    163   ;; match things up best we can.  The main problem is with atoms, which the source recording stuff
    164   ;; doesn't track properly.
    165   (let ((note (gethash form *nx-source-note-map*)))
    166     (when note
    167       (let* ((parent-source (loop for n = parent-note then (source-note-source n)
    168                               when (or (null n) (source-note-start-pos n)) return n)))
    169         (setq note
    170               (when parent-source
    171                 (if (consp note)
    172                   ;; This form (typically an atom) has multiple source locations.
    173                   ;; At least try to distinguish occurences in different outer forms.  This allows
    174                   ;; reasonable code coverage reporting for "(if (test) t (other))", although it
    175                   ;; doesn't work for cases like "(if foo foo (other))".
    176                   (loop with found = nil
    177                     for n in note
    178                     when (note-contained-in-p n parent-source)
    179                     do (if found (return nil) (setq found n))
    180                     finally (return found))
    181                   (when (note-contained-in-p note parent-source)
    182                     ;; As an aside, here's a fun code coverage issue:  What if the same source
    183                     ;; form (i.e. single source location) gets used multiple times. e.g.
    184                     ;; (macrolet ((dup (x) `(progn (foo ,x) (bar ,x)))) (dup (something))).
    185                     ;; We could arrange to have separate records for each instance, but as of right
    186                     ;; now no existing or contemplated UI has a means of showing the distinction,
    187                     ;; so don't bother.
    188                     note))))))
    189     (unless note
    190       (setq note (make-source-note :form form :source parent-note)))
     156  (loop for n = note then (code-note-source n) while (code-note-p n) thereis (eq n parent)))
     157
     158(defun nx-find-code-note (form parent-source)
     159  ;; Try to find a source note for this form.  The act of matching up a source note with
     160  ;; forms that might come from macroexpansion is heuristic at best.  In general, err in
     161  ;; favor of not matching, because that leads to fewer false positives in code coverage
     162  ;; reporting.  But still, try hard to match things up best we can.  The main problem is
     163  ;; with atoms, which the source recording stuff doesn't track properly.
     164  #| -- This doesn't work, period, it leads to too many false positives.  The problem
     165    -- is that even if we have just one instance of the form in the parent source,
     166    -- there might be many generated occurences that do NOT correspond to the one
     167    -- in the source, and the form can be one of those, leading to false positives on the
     168    -- source version.
     169  (when parent-source
     170    (let ((note (gethash form *nx-source-note-map*)))
     171      (cond ((consp note)
     172             ;; This form (typically an atom) has multiple source locations.
     173             ;; At least try to distinguish occurences in different outer forms.  This allows
     174             ;; reasonable code coverage reporting for "(if (test) t (other))", although it
     175             ;; doesn't work for cases like "(if foo foo (other))".
     176             (loop with found = nil
     177               for n in note
     178               ;; I tried allowing parent-source to be an indirect ancestor, but that would
     179               ;; catch unrelated references in outer forms.
     180               when (eq (code-note-source n) parent-source)
     181               do (if found (return nil) (setq found n))
     182               finally (return found)))
     183            ((not (null note))
     184             (when (note-contained-in-p note parent-source)
     185               ;; As an aside, here's a fun code coverage issue:  What if the same source
     186               ;; form (i.e. single source location) gets used multiple times. e.g.
     187               ;; (macrolet ((dup (x) `(progn (foo ,x) (bar ,x)))) (dup (something))).
     188               ;; We could arrange to have separate records for each instance, but as of right
     189               ;; now no existing or contemplated UI has a means of showing the distinction,
     190               ;; so don't bother.
     191               note))
     192            (t nil))))
     193  |#
     194  (when (and parent-source
     195             (or (consp form) (vectorp form) (pathnamep form)))
     196    (let ((note (gethash form *nx-source-note-map*)))
     197      (unless (listp note)
     198        note))))
     199
     200(defun nx-ensure-code-note (form original parent-note)
     201  ;; Try to find a source note for this form; if can't, just make a new record for it.
     202  (let* ((parent-source (loop for n = parent-note then (code-note-source n)
     203                          when (or (null n) (source-note-p n)) return n))
     204         (note (or (and original (nx-find-code-note original parent-source))
     205                   (nx-find-code-note form parent-source)
     206                   (make-code-note :form (or original form) :source parent-note))))
    191207    (when (and parent-note (neq note parent-note))
    192       (push note (source-note-subform-notes parent-note)))
     208      (push note (code-note-subform-notes parent-note)))
    193209    note))
    194210
     
    214230                                :target target))))
    215231
    216 (defun compile-named-function-1 (def &key name env source-note keep-lambda keep-symbols policy load-time-eval-token target source-locations)
     232(defun compile-named-function-1 (def &key name env function-note keep-lambda keep-symbols policy load-time-eval-token target source-notes)
    217233  (when (and name *nx-discard-xref-info-hook*)
    218234    (funcall *nx-discard-xref-info-hook* name))
     
    220236   def
    221237   (let ((*load-time-eval-token* load-time-eval-token)
    222          (*nx-source-note-map* source-locations)
     238         (*nx-source-note-map* source-notes)
    223239         (env (new-lexical-environment env)))
    224240     (setf (lexenv.variables env) 'barrier)
     
    232248                      (or policy *default-compiler-policy*)
    233249                      *load-time-eval-token*
    234                       source-note)))
     250                      function-note)))
    235251         (if (afunc-lfun afunc)
    236252           afunc
Note: See TracChangeset for help on using the changeset viewer.