[Ecls-list] ECL generates huge C file.
Juan Jose Garcia-Ripoll
juanjose.garciaripoll at googlemail.com
Fri Feb 13 14:58:11 UTC 2009
On Fri, Feb 13, 2009 at 5:46 AM, Waldek Hebisch
<hebisch at math.uni.wroc.pl> wrote:
> I have now created new, hopefully safe macro giving faster indirect
> calls. This macro works fine in the benchmark. However in one of
> my real files it causes huge increase in size of generated C file
> and consequently C compiler is no longer able to compile the file.
Your file contains a lot of recursion. Every SPADCALL statement takes
as input one or more SPADCALL statement and so on and so forth. If
instead of a single function call, which is the commented out version,
you now replace a SPADCALL by an IF statement, that means every node
of the call tree gets multiplied by 2. Due to the recursivity, if
SPADCALL calls a SPADCALL, that means 2*2, and so on and so forth,
until I presume you get a factor 2^8 in some of the code branches.
This version does what you want without the exponential growth
(defmacro SPADCALL (&rest L)
(let* ((args (butlast l))
(arg-pairs (loop for i in args collect (list (gensym) i)))
(arg-names (mapcar #'first arg-pairs))
(fn (car (last l)))
(gi (gensym))
(gif (gensym))
(msym (intern (format nil "ECLCALLX" (length l)))))
`(let* ((,gi ,fn) (,gif (car ,gi)) , at arg-pairs)
(if (ecl-fixed ,gif)
(,msym ,gif , at arg-names (cdr ,gi))
(funcall
(the (function ,(make-list (length l) :initial-element t) t)
,gif)
, at arg-names
(cdr ,gi))))))
Juanjo
--
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28009 (Spain)
http://juanjose.garciaripoll.googlepages.com
More information about the ecl-devel
mailing list