Changeset 9052


Ignore:
Timestamp:
Apr 8, 2008, 4:52:04 AM (11 years ago)
Author:
gb
Message:

Don't constant-fold if arg count is obviously wrong.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/compiler/nx0.lisp

    r9027 r9052  
    21432143
    21442144           
    2145 ; This guy has to return multiple values.
    2146 ; The arguments have already been transformed; if they're all constant (or quoted), try
    2147 ; to evaluate the expression at compile-time.
     2145;;; This guy has to return multiple values.  The arguments have
     2146;;; already been transformed; if they're all constant (or quoted), try
     2147;;; to evaluate the expression at compile-time.
    21482148(defun nx-constant-fold (original-call &optional (environment *nx-lexical-environment*) &aux
    21492149                                       (fn (car original-call)) form mv foldable foldfn)
     
    21612161        (funcall foldfn original-call environment)
    21622162        (progn
    2163             (let ((args nil))
    2164               (dolist (arg (cdr original-call) (setq args (nreverse args)))
    2165                 (if (quoted-form-p arg)
    2166                   (setq arg (%cadr arg))
    2167                   (unless (self-evaluating-p arg) (return-from nx-constant-fold (values original-call nil))))
    2168                 (push arg args))
     2163          (let ((args nil))
     2164            (dolist (arg (cdr original-call) (setq args (nreverse args)))
     2165              (if (quoted-form-p arg)
     2166                (setq arg (%cadr arg))
     2167                (unless (self-evaluating-p arg) (return-from nx-constant-fold (values original-call nil))))
     2168              (push arg args))
     2169            (if (nx1-check-call-args (fboundp fn) args nil)
     2170              (return-from nx-constant-fold (values original-call nil))
    21692171              (setq form (multiple-value-list
    2170                           (handler-case (apply fn args)
    2171                             (error (condition)
    2172                                    (warn "Error: \"~A\" ~&signalled during compile-time evaluation of ~S ."
    2173                                          condition original-call)
    2174                                    (return-from nx-constant-fold
    2175                                      (values `(locally (declare (notinline ,fn))
    2176                                                 ,original-call)
    2177                                              t)))))))
     2172                             (handler-case (apply fn args)
     2173                               (error (condition)
     2174                                      (warn "Error: \"~A\" ~&signalled during compile-time evaluation of ~S ."
     2175                                            condition original-call)
     2176                                      (return-from nx-constant-fold
     2177                                        (values `(locally (declare (notinline ,fn))
     2178                                                  ,original-call)
     2179                                                t))))))))
    21782180          (if form
    21792181            (if (null (%cdr form))
Note: See TracChangeset for help on using the changeset viewer.