[Ecls-list] latest unboxing patch

Brian Spilsbury brian.spilsbury at gmail.com
Mon Sep 3 15:06:16 UTC 2007


Just posting this patch before I break things.

This patch seems to do things more or less the way I wanted.

(defun test5 ()
  (let ((x 0) (y 0))
    (declare (type fixnum x y))
    (flet ((test6 (a b)
             (declare (type fixnum a b)
                      (si::c-funboxed ("test6" (:fixnum :fixnum) :fixnum)))
             (incf x)
             (+ a b x y)))
      (declare (ftype (function (fixnum fixnum) fixnum) test6)
               (si::c-funboxed ("test6" (:fixnum :fixnum) :fixnum) test6))
      (test6 3 4))))

This will produce an unboxed local function with unboxed
lexicals.

The C code for lexicals (unescaping closures) looks like so.

        {cl_fixnum V5= lex0[0].unboxed_cl_fixnum;
        lex0[0].unboxed_cl_fixnum= (V5)+(1);}
        NVALUES = 1;
return((((V3)+(V4))+(lex0[0].unboxed_cl_fixnum))+(lex0[1].unboxed_cl_fixnum));
        }

The declarations required for unboxing are fairly ugly -- for lexical
functions they should probably be inferred transparently, since the
can't escape.

Proclaiming a function's interface does currently set up the
si::c-funboxed information required for inlining a global function.

I'll take a look at automatically setting up lexical functions for
unboxed calls, which is probably where the greatest win is.

I've been looking at type inference, but it does not look like it will
be very easy to add.

I'm kind of torn between trying to put type inference into the
compiler, and trying to attack it more portably.

Unboxed closures also look a little difficult -- the current mechanism
based on cons chains would need to be discareded, and there may be
some implications for GC.

There are also probably some issues in this code that I haven't hit
yet, so good luck. :)

Regards,
Brian.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.3
Type: application/octet-stream
Size: 33908 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20070904/2b4f9a5e/attachment.obj>


More information about the ecl-devel mailing list