Changeset 8514


Ignore:
Timestamp:
Feb 19, 2008, 8:08:50 AM (12 years ago)
Author:
gb
Message:

Propagate changeset:8513 to this branch.

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

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/compiler/nx0.lisp

    r8444 r8514  
    927927    (nx1-punt-var v (pop initforms))))
    928928
    929 ; at the beginning of a binding construct, note which lexical variables are bound to other
    930 ; variables and the number of setqs done so far on the initform.
    931 ; After executing the body, if neither variable has been closed over,
    932 ; the new variable hasn't been setq'ed, and the old guy wasn't setq'ed
    933 ; in the body, the binding can be punted.
    934 (defun nx1-note-var-bindings (vars initforms &aux alist)
    935   (dolist (var vars alist)
    936     (let* ((binding (nx1-note-var-binding var (pop initforms))))
    937       (if binding (push binding alist)))))
     929;;; at the beginning of a binding construct, note which lexical
     930;;; variables are bound to other variables and the number of setqs
     931;;; done so far on the initform.  After executing the body, if neither
     932;;; variable has been closed over, the new variable hasn't been
     933;;; setq'ed, and the old guy wasn't setq'ed in the body, the binding
     934;;; can be punted.
    938935
    939936(defun nx1-note-var-binding (var initform)
     
    961958              nil)))))))
    962959                     
     960;;; Process entries involving variables bound to other variables at
     961;;; the end of a binding construct.  Each entry is of the form
     962;;; (source-var setq-count . target-var), where setq-count is the
     963;;; assignment count of TARGET-VAR at the time that the binding's
     964;;; initform was evaluated (not, in the case of LET, at the time that
     965;;; the bindinw was established.).  If the target isn't closed-over
     966;;; and SETQed (somewhere), and wasn't setqed in the body (e.g.,
     967;;; still has the same assignment-count as it had when the initform
     968;;; was executed), then we can "punt" the source (and replace references
     969;;; to it with references to the target.)
     970;;; It obviously makes no sense to do this if the source is SPECIAL;
     971;;; in some cases (LET), we create the source variable and add it to
     972;;; this alist before it's known whether or not the source variable
     973;;; is SPECIAL. so we have to ignore that case here.
    963974(defun nx1-check-var-bindings (alist)
    964975  (dolist (pair alist)
     
    968979           (target-bits (nx-var-bits target)))
    969980      (unless (or
    970                ; var can't be setq'ed or closed; target can't be setq'ed AND closed.
    971                (neq (%ilogand vbits (%ilogior (%ilsl $vbitsetq 1) (%ilsl $vbitclosed 1))) 0)
     981               ;; var can't be special, setq'ed or closed; target can't be
     982               ;; setq'ed AND closed.
     983               (neq (%ilogand vbits (%ilogior (%ilsl $vbitsetq 1)
     984                                              (%ilsl $vbitclosed 1)
     985                                              (%ilsl $vbitspecial 1))) 0)
    972986               (eq (%ilogior (%ilsl $vbitsetq 1) (%ilsl $vbitclosed 1))
    973987                   (%ilogand
  • branches/working-0711/ccl/compiler/nx1.lisp

    r8421 r8514  
    17751775
    17761776(defnx1 nx1-let let (pairs &body forms &environment old-env)
    1777   (let* ((vars nil)
    1778          (vals nil)
    1779          (varspecs nil))
     1777  (collect ((vars)
     1778            (vals)
     1779            (varbindings))
    17801780    (with-nx-declarations (pending)
    17811781      (multiple-value-bind (body decls)
    17821782                           (parse-body forms *nx-lexical-environment* nil)
    17831783        (nx-process-declarations pending decls)
    1784         ; Make sure that the initforms are processed in the outer
    1785         ; environment (in case any declaration handlers side-effected
    1786         ; the environment.)
     1784        ;; Make sure that the initforms are processed in the outer
     1785        ;; environment (in case any declaration handlers side-effected
     1786        ;; the environment.)
     1787       
    17871788        (let* ((*nx-lexical-environment* old-env))
    17881789          (dolist (pair pairs)
    1789             (push (nx-need-var (nx-pair-name pair)) vars)
    1790             (push (nx1-typed-var-initform pending (car vars) (nx-pair-initform pair)) vals)))
    1791         (let* ((*nx-bound-vars* (append vars *nx-bound-vars*))
    1792                (varbindings (nx1-note-var-bindings
    1793                              (dolist (sym vars varspecs)
    1794                                (push (nx-new-var pending sym) varspecs))
    1795                              (setq vals (nreverse vals))))
    1796                (form
    1797                 (make-acode
    1798                  (%nx1-operator let)
    1799                  varspecs
    1800                  vals
    1801                  (progn
    1802                    (nx-effect-other-decls pending *nx-lexical-environment*)
    1803                    (nx1-env-body body old-env))
     1790            (let* ((sym (nx-need-var (nx-pair-name pair)))
     1791                   (var (nx-cons-var sym))
     1792                   (val (nx1-typed-var-initform pending sym (nx-pair-initform pair)))
     1793                   (binding (nx1-note-var-binding var val)))
     1794              (vars var)
     1795              (vals val)
     1796              (when binding (varbindings binding)))))
     1797        (let* ((*nx-bound-vars* *nx-bound-vars*)
     1798               (varbindings (varbindings)))
     1799          (dolist (v (vars)) (nx-init-var pending v))
     1800          (let* ((form
     1801                  (make-acode
     1802                   (%nx1-operator let)
     1803                   (vars)
     1804                   (vals)
     1805                   (progn
     1806                     (nx-effect-other-decls pending *nx-lexical-environment*)
     1807                     (nx1-env-body body old-env))
    18041808                 *nx-new-p2decls*)))
    18051809          (nx1-check-var-bindings varbindings)
    1806           (nx1-punt-bindings varspecs vals)
    1807           form)))))
     1810          (nx1-punt-bindings (vars) (vals))
     1811          form))))))
    18081812
    18091813
Note: See TracChangeset for help on using the changeset viewer.