From 710d23027773fd508a1efde77d3654452671e3c4 Mon Sep 17 00:00:00 2001 From: David Vazquez Date: Thu, 17 Jan 2013 16:27:45 +0000 Subject: [PATCH] Compile macro expander functions after first use in target --- ecmalisp.lisp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ecmalisp.lisp b/ecmalisp.lisp index b072d9b..eb08473 100644 --- a/ecmalisp.lisp +++ b/ecmalisp.lisp @@ -779,6 +779,9 @@ (defun binding-name (b) (first b)) (defun binding-type (b) (second b)) (defun binding-value (b) (third b)) +(defun set-binding-value (b value) + (setcar (cdr (cdr b)) value)) + (defun binding-declared (b) (and b (fourth b))) (defun mark-binding-as-declared (b) @@ -1483,7 +1486,19 @@ (defun ls-macroexpand-1 (form) (let ((macro-binding (macro (car form)))) (if macro-binding - (apply (eval (binding-value macro-binding)) (cdr form)) + (let ((expander (binding-value macro-binding))) + (when (listp expander) + (let ((compiled (eval expander))) + ;; The list representation are useful while + ;; bootstrapping, as we can dump the definition of the + ;; macros easily, but they are slow because we have to + ;; evaluate them and compile them now and again. So, let + ;; us replace the list representation version of the + ;; function with the compiled one. + ;; + #+ecmalisp (set-binding-value macro-binding compiled) + (setq expander compiled))) + (apply expander (cdr form))) form))) (defun compile-funcall (function args) -- 1.7.10.4