[Ecls-list] Is ECL really interpreted ?

Juan Jose Garcia-Ripoll juanjose.garciaripoll at gmail.com
Mon Jul 16 21:14:31 UTC 2012


On Mon, Jul 16, 2012 at 11:07 PM, <ecky at ecky.fr> wrote:

> @Juan : Well now that is an interesting remark, as what I read (unless I'm
> mixing something up) I thought that ECL uses several steps to produce
> executable code (see http://ecls.sourceforge.net/ecldev/devel_5.html) and
> naively I figured that the compile function would trigger that process and
> somehow insert the machine-code compiled from generated c-code to the
> lisp-interpreter in order to replace the bytecode in order to speed up.
>

It is much simpler than that. If you do

(EVAL '(COS 1.0))

this is the equivalent of the following pseudocode

(FUNCALL (BYTECOMPILE '(COS 1.0)))

Now if you do

(EVAL '(DEFUN FOO (x) (1+ X)))

this is the equivalent of

(FUNCALL (BYTECOMPILE '(SETF (FDEFINITION FOO) #'(EXT:LAMBDA-BLOCK FOO (X)
(1+ X))))...

where the #'(EXT:LAMBDA-BLOCK ...) is a bytecompiled function too. This
assigns the bytecodes function to the symbol FOO.

It is now of course possible to compile the bytecodes using the C compiler.
If you do (REQUIRE :CMP) followed by (COMPILE 'FOO) then ECL will retrieve
the original list that was the definition of the function, convert it to C,
invoke the C compiler, and load the result as a library.

What I meant by ECL lacking a JIT compiler is that ECL has no intelligence
to do this by itself: it is up to you to tell the system which functions
you want compiled.

Note however one important thing: compilation to C is an expensive process.
If you need to optimize certain functions, then better put them all in one
file and call COMPILE-FILE once. This saves precious time and resources,
and it also consumes a lot less memory, because each compiled thingy is
loaded as a shared library object and this consumes operating system
resources.

Note also that bytecodes are quite fast for many purposes -- and the
bytecodes interpreter is simple enough that it could conceivably made
faster.

Cheers,

Juanjo

-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20120716/d4a111a8/attachment.html>


More information about the ecl-devel mailing list