[Ecls-list] ECL generates huge C file.

Waldek Hebisch hebisch at math.uni.wroc.pl
Fri Feb 13 04:46:28 UTC 2009


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.

The Lisp file has about 950 lines (64 kb).  Using the following
definition of SPADCALL macro:

(defmacro SPADCALL (&rest L)
  (let ((args (butlast l)) 
        (fn (car (last l))) 
        (gi (gensym)))
     ;; (values t) indicates a single return value
    `(let ((,gi ,fn)) 
        (the (values t) 
             (funcall 
               (the (function ,(make-list (length l) :initial-element t) t) 
                  (car ,gi))
               , at args 
               (cdr ,gi))))))

the C output is 68 kb.  However, when I change definition of
SPADCALL to the following:

(defmacro SPADCALL (&rest L)
  (let ((args (butlast l)) 
        (fn (car (last l))) 
        (gi (gensym))
        (gif (gensym))
        (msym (intern (format nil "ECLCALL~d" (length l)))))
     ;; (values t) indicates a single return value
    `(let* ((,gi ,fn) (,gif (car ,gi)))
      (if (ECL-FIXED ,gif)
         (,msym ,gif , at args (cdr ,gi)) 
        (the (values t) 
         (funcall 
          (the (function ,(make-list (length l) :initial-element t) t) 
            (car ,gi))
          , at args 
          (cdr ,gi)))))))

with

(defmacro ECL-FIXED(f)
   `(null (ffi:c-inline (,f) (FFI:OBJECT) FFI:OBJECT
                  "(type_of(#0) == t_cfunfixed)?Cnil:Ct" :one-liner t)))

and ECLCALLx like:

(defmacro ECLCALL1(f x1)
   `(ffi:c-inline (,f ,x1) (FFI:OBJECT FFI:OBJECT)
                  FFI:OBJECT
                  "(*((#0)->cfun.entry))(#1)"
                  :one-liner t))

where I define a separate version for each possible number of
arguments, then I get 13Mb output file.

Since the file is larger than typical message I have put standalone
test file at:

http://www.math.uni.wroc.pl/~hebisch/fricas/alg2.lsp

-- as-is I get huge C output, using alternative (commented out)
definition of SPADCALL the output is reasonable.

-- 
                              Waldek Hebisch
hebisch at math.uni.wroc.pl 




More information about the ecl-devel mailing list