Changeset 11798


Ignore:
Timestamp:
04/29/09 19:49:19 (14 years ago)
Author:
ehuelsmann
Message:

Remove the use of XEPs (eXternal Entry Points) which
were optimizing for the 1-optional-argument special case
by calling an internal entry point if that argument was
provided and the XEP otherwise. This is too much code
to justify this case.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

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

    r11796 r11798  
    910910(initialize-p1-handlers)
    911911
    912 (defun invoke-compile-xep (xep-lambda-expression compiland)
    913   (let ((xep-compiland
    914    (make-compiland :lambda-expression
    915        (precompile-form xep-lambda-expression t)
    916        :class-file (compiland-class-file compiland))))
    917     (compile-xep xep-compiland)))
    918 
    919912(defun p1-compiland (compiland)
    920913;;   (format t "p1-compiland name = ~S~%" (compiland-name compiland))
     
    926919    (let* ((lambda-list (cadr form))
    927920           (body (cddr form)))
    928 
    929       (when (and (null (compiland-parent compiland))
    930                  ;; FIXME support SETF functions!
    931                  (symbolp (compiland-name compiland)))
    932         (when (memq '&OPTIONAL lambda-list)
    933           (unless (or (memq '&KEY lambda-list) (memq '&REST lambda-list))
    934             (let ((required-args (subseq lambda-list 0 (position '&OPTIONAL lambda-list)))
    935                   (optional-args (cdr (memq '&OPTIONAL lambda-list))))
    936             (dformat t "optional-args = ~S~%" optional-args)
    937             (when (= (length optional-args) 1)
    938               (let* ((optional-arg (car optional-args))
    939                      (name (if (consp optional-arg) (%car optional-arg) optional-arg))
    940                      (initform (if (consp optional-arg) (cadr optional-arg) nil))
    941                      (supplied-p-var (and (consp optional-arg)
    942                                           (= (length optional-arg) 3)
    943                                           (third optional-arg)))
    944                      (all-args
    945                       (append required-args (list name)
    946                               (when supplied-p-var (list supplied-p-var)))))
    947                 (when (<= (length all-args) call-registers-limit)
    948                   (dformat t "optional-arg = ~S~%" optional-arg)
    949                   (dformat t "supplied-p-var = ~S~%" supplied-p-var)
    950                   (dformat t "required-args = ~S~%" required-args)
    951                   (dformat t "all-args = ~S~%" all-args)
    952                   (cond (supplied-p-var
    953                          (let ((xep-lambda-expression
    954                                 `(lambda ,required-args
    955                                    (let* ((,name ,initform)
    956                                           (,supplied-p-var nil))
    957                                      (%call-internal ,@all-args)))))
    958                            (dformat t "xep-lambda-expression = ~S~%" xep-lambda-expression)
    959          (invoke-compile-xep xep-lambda-expression compiland))
    960                          (let ((xep-lambda-expression
    961                                 `(lambda ,(append required-args (list name))
    962                                    (let* ((,supplied-p-var t))
    963                                      (%call-internal ,@all-args)))))
    964                            (dformat t "xep-lambda-expression = ~S~%" xep-lambda-expression)
    965          (invoke-compile-xep xep-lambda-expression compiland))
    966                          (setf lambda-list all-args)
    967                          (setf (compiland-kind compiland) :internal))
    968                         (t
    969                          (let ((xep-lambda-expression
    970                                 `(lambda ,required-args
    971                                    (let* ((,name ,initform))
    972                                      (,(compiland-name compiland) ,@all-args)))))
    973                            (dformat t "xep-lambda-expression = ~S~%" xep-lambda-expression)
    974          (invoke-compile-xep xep-lambda-expression compiland))
    975                          (setf lambda-list all-args))))))))))
    976921
    977922      (let* ((closure (make-closure `(lambda ,lambda-list nil) nil))
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r11795 r11798  
    80968096             (write-u2 0 stream))))))
    80978097
    8098 (defun compile-xep (xep)
    8099   (declare (type compiland xep))
    8100   (let ((*all-variables* ())
    8101         (*closure-variables* ())
    8102         (*current-compiland* xep)
    8103         (*speed* 3)
    8104         (*safety* 0)
    8105         (*debug* 0))
    8106 
    8107     (aver (not (null (compiland-class-file xep))))
    8108 
    8109     ;; Pass 1.
    8110     (p1-compiland xep)
    8111 ;;     (dformat t "*all-variables* = ~S~%" (mapcar #'variable-name *all-variables*))
    8112     (setf *closure-variables*
    8113           (remove-if-not #'variable-used-non-locally-p *all-variables*))
    8114     (setf *closure-variables*
    8115           (remove-if #'variable-special-p *closure-variables*))
    8116 ;;     (dformat t "*closure-variables* = ~S~%" (mapcar #'variable-name *closure-variables*))
    8117 
    8118     (when *closure-variables*
    8119       (let ((i 0))
    8120         (dolist (var (reverse *closure-variables*))
    8121           (setf (variable-closure-index var) i)
    8122           (dformat t "var = ~S closure index = ~S~%" (variable-name var)
    8123                    (variable-closure-index var))
    8124           (incf i))))
    8125 
    8126     ;; Pass 2.
    8127     (with-class-file (compiland-class-file xep)
    8128       (p2-compiland xep))))
    8129 
    8130 
    8131 (defun p2-%call-internal (form target representation)
    8132   (dformat t "p2-%call-internal~%")
    8133   (aload 0) ; this
    8134   (let ((args (cdr form))
    8135         (must-clear-values nil))
    8136     (dformat t "args = ~S~%" args)
    8137     (dolist (arg args)
    8138       (compile-form arg 'stack nil)
    8139       (unless must-clear-values
    8140         (unless (single-valued-p arg)
    8141           (setf must-clear-values t))))
    8142     (let ((arg-types (lisp-object-arg-types (length args)))
    8143           (return-type +lisp-object+))
    8144       (emit-invokevirtual *this-class* "_execute" arg-types return-type))
    8145     (emit-move-from-stack target representation)))
    8146 
    81478098(defknown p2-compiland-process-type-declarations (list) t)
    81488099(defun p2-compiland-process-type-declarations (body)
     
    87658716                               nth
    87668717                               progn))
    8767   (install-p2-handler '%call-internal      'p2-%call-internal)
    87688718  (install-p2-handler '%ldb                'p2-%ldb)
    87698719  (install-p2-handler '%make-structure     'p2-%make-structure)
Note: See TracChangeset for help on using the changeset viewer.