gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] compiler speed and macro expansion


From: Camm Maguire
Subject: [Gcl-devel] compiler speed and macro expansion
Date: 30 Mar 2006 14:59:29 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings!  2.7.0 is depending more upon compiler macros, and there is
some iteration when variables are typed in the presence of setq.
Things could be sped up quite a bit if I macroexpanded ahead of time.

This is not hard but for the special forms.  One must be careful to
step over let bindings, etc. lest one happens to have a macro by the
same name.

Here is an old hack which evolved through trial and error to do the
right thing, at least as far as I could tell.  I'm wondering if either
of you might be able to discern if it is woefully inadequate, or just
might need a little brushing up.

Take care,

=============================================================================

(defun push-macrolets (form)
  (dolist** (def form)
            (push (list (car def)
                        (caddr (si:defmacro* (car def) (cadr def) (cddr def))))
                  *funs*)))

(defun cmp-macroexp-with-compiler-macros (form)
  (let ((form (if (and (consp form) (eq (car form) 'or)) form (cmp-macroexpand 
form))))
    (if (and (consp form) (symbolp (car form)))
        (let ((cmf (get (car form) 'si::compiler-macro-prop)))
          (if cmf
              (cmp-eval `(funcall ',cmf ',form nil))
            form))
      form)))

;;FIXME -- this really needs replacing with another c1 pass at this point.
(defun recursively-cmp-macroexpand (form bf &aux (*funs* *funs*))
  (if (atom form)
      form
    (let ((cf (car form)))
      (let ((new-cdr-bf (or (and (eq bf 'quote) 'quote)
                            (and (eq bf 'declare) 'declare)
                            (car (member cf '(let let* lambda the flet labels 
macrolet declare quote function)))
                            (and (consp bf)
                                 (if (atom (car bf)) bf
                                   (and (member (caar bf) '(flet labels 
macrolet)) 'lambda)))))
            (new-car-bf (and (consp cf) bf (if (or (eq bf 'quote) (eq bf 
'declare)) bf (list bf))))
            (new-cf (if (or bf (atom cf) (eq (car cf) 'lambda))
                        cf (cmp-macroexp-with-compiler-macros cf))))
        (cons (recursively-cmp-macroexpand new-cf new-car-bf)
              (progn
                (when (eq bf 'macrolet)
                  (push-macrolets cf))
                (recursively-cmp-macroexpand (cdr form) new-cdr-bf)))))))

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

[Prev in Thread] Current Thread [Next in Thread]