]> git.eshelyaron.com Git - emacs.git/commit
Faster, more compact, and readable closure creation
authorMattias Engdegård <mattiase@acm.org>
Sun, 21 Feb 2021 14:24:41 +0000 (15:24 +0100)
committerMattias Engdegård <mattiase@acm.org>
Sun, 21 Feb 2021 20:58:25 +0000 (21:58 +0100)
commitd0c47652e527397cae96444c881bf60455c763c1
tree9dfa3ce23f5251726ebd287298486667a135101b
parent2790c6a572a905359c60f055c682b28ef5c8ff0d
Faster, more compact, and readable closure creation

Simplify closure creation by calling a single function at run time
instead of putting it together from small pieces.  This is faster
(by about a factor 2), takes less space on disk and in memory, and
makes internal functions somewhat readable in disassembly listings again.

This is done by creating a prototype function at compile-time whose
closure variables are placeholder values V0, V1... which can be seen
in the disassembly.  The prototype is then cloned at run time using
the new make-closure function that replaces the placeholders with
the actual closure variables.

* lisp/emacs-lisp/bytecomp.el (byte-compile-make-closure):
Generate call to make-closure from a prototype function.
* src/alloc.c (Fmake_closure): New function.
(syms_of_alloc): Defsubr it.
* src/data.c (syms_of_data): Defsym byte-code-function-p.
lisp/emacs-lisp/bytecomp.el
src/alloc.c
src/data.c