On Mon, Jul 16, 2012 at 11:07 PM, <e...@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
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ecls-list mailing list
Ecls-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ecls-list

Reply via email to