Skip to content

Confusion about why ECL generates WebAssembly bytecode

I apologize in advance for any ignorance on my part.

My understanding of disassemble is limited only to what I know from the CLHS, where it's just used as a debugging tool to print the code that may be used to implement the target function.

SBCL produces x86 assembly, which runs directly by the machine. I understand this concept. ECL produces C code, which (I am guessing here, correct me if I'm wrong) correspond to the instructions which the ECL C runtime executes in order to simulate the target code. I may be completely wrong, but this is palpable to me as well.

Now, I compiled ECL to WASM, and ran it in the browser. I compiled a simple function, and got something which I did not expect:

image

What I did expect, is to get the same C code which my host ECL produced. I am not complaining, I am just confused/ignorant about some things:

  1. How does ECL know how to generate this WASM? Why did it not generate the normal C? I do not imagine there is a WASM disassembler included.
  2. Does this mean functions defined in the web ECL are compiled down to WASM? How? I expected them to be compiled down to the C, which would correspond to the "bytecode" of ECL.
  3. How is ECL even able to compile Lisp to WASM during runtime in the browser, if it does compile?
Edited by daedsidog