3 ms·
MemSQL and Smalltalk generate C at runtime.
by useranme 8y ago
MemSQL and Smalltalk generate C at runtime.
- floatboth 8y agoWhich Smalltalk?
- dfox 8y agoSmalltalk/X can fileout packages as C projects that are then compiled by C compiler. But AFAIK this was never meant to be used as JIT and is primarily an deployment mechanism and non-ancient versions use in-process code generator implemented in Smalltalk as JIT backend. There are Common Lisp implementations that support similar mechanism of generating C code (ECL, Kyoto CL...), but I don't think any of then compiles C into .so which then gets dlopened right away as poor-mans JIT.
- kazinator 8y agoKCL generates .c files and compiles those to .o object files. I played with this year ago (via the descendant GCL: GNU Common Lisp). The load function handles object files, like COFF or whatever. It's reminiscent of the Linux kernel modules. See here, starting on P. 36: http://www.softwarepreservation.org/projects/LISP/kcl/doc/kcl-report.pdf http://www.softwarepreservation.org/projects/LISP/kcl/doc/kc... When KCL compiles a lambda expression, it generates a C file called "gazonk.lsp" and compiles that. (The above paper report is a little confusing; in some places it claims that an object file has a .o suffix, but then with regard to this gazonk implicit name, it claims that the fasl file is gazonk.fasl.)
- lispm 8y agoExample with GCL: compile individual function to C, compile it with C to a .o (for example on my 32bit ARM it is a elf32-littlearm file) file and then load it: >(defun foo (a) (* a 42)) FOO >(compile 'foo) Compiling /tmp/gazonk_24158_0.lsp. End of Pass 1. End of Pass 2. OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3 Finished compiling /tmp/gazonk_24158_0.lsp. Loading /tmp/gazonk_24158_0.o start address -T 0x888488 Finished loading /tmp/gazonk_24158_0.o #<compiled-function FOO> NIL NIL
- pjmlp 8y agoIf you mean Squeak, it surely does not. Generating C is part of the bootstrapping process, it isn't used at runtime, the JIT generates the usual machine code directly.