[Ecls-list] Regular toplevel functions vs. labels

Matthew Mondor mm_lists at pulsar-zone.net
Sun Jul 4 20:24:54 UTC 2010


On Mon, 28 Jun 2010 17:25:18 -0500
Gabriel Dos Reis <gdr at integrable-solutions.net> wrote:

>   Is the ECL compilation scheme of functions defined by
> labels likely to yield better codes than those functions
> defined at toplevel?

When I read your mail I added on my TODO list to perform some
locality/global tests out of curiosity and see how ECL HEAD does now
with them.  I could do some testing today.

The following test code tests the difference between a dynamic global
variable versus a local closure one, as well as between a global
function and a local one.  The resulting C code is also attached.

It follows that for variables, *GLOBAL* and SHARED accesses are about
equivalent as they both require the environment (to obtain the closure
environment in the latter case).  However, ECL was able to optimize
away ecl_plus() calls in the SHARED case, unlike on *GLOBAL* despite an
additional redundant DECLARE to tell the compiler it holds a FIXNUM.

As for global vs local functions, they currently seem to be treated the
same in this particular case.

However, depending on the use case, it would be possible for global
functions to be called via a dispatcher routine, which is important
when a function is expected to be redefined dynamically (which is more
expensive than calling a C function directly, of course).
-- 
Matt
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: locality-tests.lisp
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20100704/7ac676d5/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: locality-tests.c
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20100704/7ac676d5/attachment.c>


More information about the ecl-devel mailing list