Tromey: JIT Compilation for Emacs
On his blog, Tom Tromey looks at just-in-time (JIT) compilation for Emacs and what he has done differently in his implementation from what was done in earlier efforts. He also looks at potential enhancements to his JIT: "Calling a function in Emacs Lisp is quite expensive. A call from the JIT requires marshalling the arguments into an array, then calling Ffuncall; which then might dispatch to a C function (a "subr"), the bytecode interpreter, or the ordinary interpreter. In some cases this may require allocation.This overhead applies to nearly every call - but the C implementation of Emacs is free to call various primitive functions directly, without using Ffuncall to indirect through some Lisp symbol.Now, these direct calls aren't without a cost: they prevent the modification of some functions from Lisp. Sometimes this is a pain (it might be handy to hack on load from Lisp), but in many cases it is unimportant.So, one idea for the JIT is to keep a list of such functions and then emit direct calls rather than indirect ones."