<div class="gmail_quote">On Mon, Jul 16, 2012 at 11:07 PM,  <span dir="ltr"><<a href="mailto:ecky@ecky.fr" target="_blank">ecky@ecky.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

@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 <a href="http://ecls.sourceforge.net/ecldev/devel_5.html" target="_blank">http://ecls.sourceforge.net/ecldev/devel_5.html</a>) 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.<br>

</blockquote><div><br></div><div>It is much simpler than that. If you do</div><div><br></div><div>(EVAL '(COS 1.0))</div><div><br></div><div>this is the equivalent of the following pseudocode</div><div><br></div><div>

(FUNCALL (BYTECOMPILE '(COS 1.0)))</div><div><br></div><div>Now if you do</div><div><br></div><div>(EVAL '(DEFUN FOO (x) (1+ X)))</div><div><br></div><div>this is the equivalent of</div><div><br></div><div>(FUNCALL (BYTECOMPILE '(SETF (FDEFINITION FOO) #'(EXT:LAMBDA-BLOCK FOO (X) (1+ X))))...</div>

<div><br></div><div>where the #'(EXT:LAMBDA-BLOCK ...) is a bytecompiled function too. This assigns the bytecodes function to the symbol FOO.</div><div><br></div><div>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.</div>

<div><br></div><div>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.</div><div><br></div><div>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.</div>

<div><br></div><div>Note also that bytecodes are quite fast for many purposes -- and the bytecodes interpreter is simple enough that it could conceivably made faster.</div><div><br></div><div>Cheers,</div><div><br></div>
<div>
Juanjo</div></div><div><br></div>-- <br>Instituto de Física Fundamental, CSIC<br>c/ Serrano, 113b, Madrid 28006 (Spain) <br><a href="http://juanjose.garciaripoll.googlepages.com" target="_blank">http://juanjose.garciaripoll.googlepages.com</a><br>