Changeset 11828 for trunk/abcl/src/org


Ignore:
Timestamp:
05/03/09 21:43:08 (15 years ago)
Author:
ehuelsmann
Message:

Use the fact that tags have lexical scope:
if they're not used, don't generate comparisons
for tags which are not used.

  • P1: Find out which tags are used
  • P2: Limit the number of tag comparisons
Location:
trunk/abcl/src/org/armedbear/lisp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass1.lisp

    r11825 r11828  
    337337         (*blocks* (cons block *blocks*))
    338338         (*visible-tags* *visible-tags*)
     339         (local-tags '())
    339340         (body (cdr form)))
    340341    ;; Make all the tags visible before processing the body forms.
     
    342343      (when (or (symbolp subform) (integerp subform))
    343344        (let* ((tag (make-tag :name subform :label (gensym) :block block)))
     345          (push tag local-tags)
    344346          (push tag *visible-tags*))))
    345347    (let ((new-body '())
     
    348350        (cond ((or (symbolp subform) (integerp subform))
    349351               (push subform new-body)
     352               (push (find subform local-tags :key #'tag-name :test #'eql)
     353                     (block-tags block))
    350354               (setf live t))
    351355              ((not live)
     
    368372    (unless tag
    369373      (error "p1-go: tag not found: ~S" name))
     374    (setf (tag-used tag) t)
    370375    (let ((tag-block (tag-block tag)))
    371376      (cond ((eq (tag-compiland tag) *current-compiland*)
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r11827 r11828  
    44314431         (form (block-form block))
    44324432         (body (cdr form))
    4433          (local-tags ())
    44344433         (BEGIN-BLOCK (gensym))
    44354434         (END-BLOCK (gensym))
     
    44414440            (block-environment-register block) environment-register))
    44424441    ;; Scan for tags.
    4443     (dolist (subform body)
    4444       (when (or (symbolp subform) (integerp subform))
    4445         (let* ((tag (make-tag :name subform :label (gensym) :block block)))
    4446           (push tag local-tags)
    4447           (push tag *visible-tags*))))
     4442    (dolist (tag (block-tags block))
     4443      (push tag *visible-tags*))
    44484444
    44494445    (when environment-register
     
    44664462         ((null rest))
    44674463      (cond ((or (symbolp subform) (integerp subform))
    4468              (let ((tag (find-tag subform)))
     4464             (let ((tag (find subform (block-tags block) :key #'tag-name
     4465                              :test #'eql)))
    44694466               (unless tag
    44704467                 (error "COMPILE-TAGBODY: tag not found: ~S~%" subform))
    4471                (label (tag-label tag))))
     4468               (when (tag-used tag)
     4469                 (label (tag-label tag)))))
    44724470            (t
    44734471             (compile-form subform nil nil)
     
    44934491        (emit 'getfield +lisp-go-class+ "tag" +lisp-object+) ; Stack depth is still 1.
    44944492        (astore tag-register)
    4495         (dolist (tag local-tags)
     4493        ;; Don't actually generate comparisons for tags
     4494        ;; to which there is no GO instruction
     4495        (dolist (tag (remove-if-not #'tag-used (block-tags block)))
    44964496          (let ((NEXT (gensym)))
    44974497            (aload tag-register)
  • trunk/abcl/src/org/armedbear/lisp/jvm.lisp

    r11826 r11828  
    371371  vars
    372372  free-specials
     373  ;; Only used in TAGBODY
     374  tags
    373375  )
    374376
     
    432434  ;; The associated TAGBODY
    433435  block
    434   (compiland *current-compiland*))
     436  (compiland *current-compiland*)
     437  used)
    435438
    436439(defknown find-tag (t) t)
Note: See TracChangeset for help on using the changeset viewer.