Lisp HUG Maillist Archive

LW bytecode

Folks,

Please correct my understanding of the following points:

1. When I compile from the REPL then LW produces bytecode that is
saved somewhere in memory.

2. When I compile-file then LW produces a file of bytecode (NFASL).

3. Upon delivery LW converts my bytecode into processor instructions.

4. If my compiled code runs fast in the REPL then it should run even
faster after it's delivered.

Is my understanding correct?

    Thanks, Joel

-- 
Tenerife > Canary Islands > Spain


Re: LW bytecode

Unable to parse email body. Email id is 3422

Re: LW bytecode

On Fri, 14 Jan 2005 19:26:55 +0000, joel reymont <joelr1@gmail.com> wrote:

> Please correct my understanding of the following points:
>
> 1. When I compile from the REPL then LW produces bytecode that is
> saved somewhere in memory.
>
> 2. When I compile-file then LW produces a file of bytecode (NFASL).
>
> 3. Upon delivery LW converts my bytecode into processor
> instructions.
>
> 4. If my compiled code runs fast in the REPL then it should run even
> faster after it's delivered.
>
> Is my understanding correct?

No, there is no bytecode involved, compilation always results in
machine code.  Delivery just means that the resulting Lisp image is
massaged into something that the operating systems views as a
"stand-alone" executable.  A delivered application will generally not
run any faster than a compiled application executed from the IDE.

  CL-USER 1 > (defun plus (x y)
                (declare (optimize speed)
                         (fixnum x y))
                (+ x y))
  PLUS

  CL-USER 2 > (compile 'plus)
  PLUS
  NIL
  NIL

  CL-USER 3 > (disassemble 'plus)
  ; Loading fasl file C:\Program Files\Xanalys\LispWorks\lib\4-4-0-0\load-on-demand\pcl\util\disass.fsl
  ; Loading fasl file C:\Program Files\Xanalys\LispWorks\lib\4-4-0-0\load-on-demand\pcl\memory\findptr.fsl
  206ADFEA:
         0:      3B25BC150020     cmp   esp, [200015BC]  ; T
         6:      7614             jbe   L1
         8:      80FD02           cmpb  ch, 2
        11:      750F             jne   L1
        13:      55               push  ebp
        14:      89E5             move  ebp, esp
        16:      8B7D08           move  edi, [ebp+8]
        19:      897D08           move  [ebp+8], edi
        22:      C9               leave 
        23:      E9F4CA3200       jmp   209DAAFA         ; #<function SYSTEM:+$FIXNUM 209DAAFA>
  L1:   28:      E877A899FF       call  20048882         ; #<function 20048882>
        33:      90               nop   
  NIL

HTH,
Edi.


Re: LW bytecode

[...]
    JR> 1. When I compile from the REPL then LW produces bytecode that
    JR> is saved somewhere in memory.

No, it produces native code.

    JR> 2. When I compile-file then LW produces a file of bytecode
    JR> (NFASL).

It saves native code + possibly some housekeeping stuff.

    JR> 3. Upon delivery LW converts my bytecode into processor
    JR> instructions.

No, compiled code doesn't change, but now it is together with the runtime 
and the library in one file.

    JR> 4. If my compiled code runs fast in the REPL then it should
    JR> run even faster after it's delivered.

No, not in the sense you indicate.  One could, perhaps, come up with
rare cases where speed is measuably improved because of the way things
end up getting laid out in memory (think caches and TLBs and such).

    JR> Is my understanding correct?

It wasn't, but it was consistent.  Why did you think bytecodes were 
involved?

cheers,

BM


Re: LW bytecode

On Fri, 14 Jan 2005 22:45:00 +0200, Bulent Murtezaoglu <bm@acm.org> wrote:
>     JR> Is my understanding correct?
> 
> It wasn't, but it was consistent.  Why did you think bytecodes were
> involved?

I just thought it would be easier for LW to keep bytecodes around as
opposed to native code. In any case, thank you guys for your in-depth
explanations!

    Joel

-- 
Tenerife > Canary Islands > Spain


Updated at: 2020-12-10 08:53 UTC