mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Deduplicate bytecode strings in each top-level form
This cheap device enables sharing of byte-code for local functions that only differ in their constant vectors (and/or doc strings etc). It makes the .elc files smaller by about 150 KB, and should reduce in-memory usage a little as well. * lisp/emacs-lisp/bytecomp.el (bytecomp--code-strings): New. (byte-compile-from-buffer, byte-compile-flush-pending) (byte-compile-lambda): Hash-cons byte-code locally.
This commit is contained in:
parent
4b55e56232
commit
310ec70648
1 changed files with 14 additions and 2 deletions
|
|
@ -495,6 +495,9 @@ Filled in `cconv-analyze-form' but initialized and consulted here.")
|
||||||
|
|
||||||
(defvar byte-compiler-error-flag)
|
(defvar byte-compiler-error-flag)
|
||||||
|
|
||||||
|
(defvar bytecomp--code-strings nil
|
||||||
|
"List of unique bytecode strings in this top-level form, for deduplication.")
|
||||||
|
|
||||||
(defun byte-compile-recurse-toplevel (form non-toplevel-case)
|
(defun byte-compile-recurse-toplevel (form non-toplevel-case)
|
||||||
"Implement `eval-when-compile' and `eval-and-compile'.
|
"Implement `eval-when-compile' and `eval-and-compile'.
|
||||||
Return the compile-time value of FORM."
|
Return the compile-time value of FORM."
|
||||||
|
|
@ -2417,6 +2420,7 @@ With argument ARG, insert value in current buffer after the form."
|
||||||
(byte-compile-depth 0)
|
(byte-compile-depth 0)
|
||||||
(byte-compile-maxdepth 0)
|
(byte-compile-maxdepth 0)
|
||||||
(byte-compile-output nil)
|
(byte-compile-output nil)
|
||||||
|
(bytecomp--code-strings nil)
|
||||||
;; #### This is bound in b-c-close-variables.
|
;; #### This is bound in b-c-close-variables.
|
||||||
;; (byte-compile-warnings byte-compile-warnings)
|
;; (byte-compile-warnings byte-compile-warnings)
|
||||||
(symbols-with-pos-enabled t))
|
(symbols-with-pos-enabled t))
|
||||||
|
|
@ -2580,6 +2584,7 @@ Call from the source buffer."
|
||||||
byte-compile-depth 0
|
byte-compile-depth 0
|
||||||
byte-compile-maxdepth 0
|
byte-compile-maxdepth 0
|
||||||
byte-compile-output nil
|
byte-compile-output nil
|
||||||
|
bytecomp--code-strings nil
|
||||||
byte-compile-jump-tables nil))))
|
byte-compile-jump-tables nil))))
|
||||||
|
|
||||||
(defun byte-compile-preprocess (form &optional _for-effect)
|
(defun byte-compile-preprocess (form &optional _for-effect)
|
||||||
|
|
@ -3162,9 +3167,16 @@ lambda-expression."
|
||||||
(if lexical-binding
|
(if lexical-binding
|
||||||
(byte-compile-make-args-desc arglist)
|
(byte-compile-make-args-desc arglist)
|
||||||
bare-arglist)
|
bare-arglist)
|
||||||
|
;; code string, deduplicated
|
||||||
|
(let* ((code (cadr compiled))
|
||||||
|
(prev (member code bytecomp--code-strings)))
|
||||||
|
(if prev
|
||||||
|
(car prev)
|
||||||
|
(push code bytecomp--code-strings)
|
||||||
|
code))
|
||||||
(append
|
(append
|
||||||
;; byte-string, constants-vector, stack depth
|
;; constants-vector and stack depth
|
||||||
(cdr compiled)
|
(drop 2 compiled)
|
||||||
;; optionally, the doc string.
|
;; optionally, the doc string.
|
||||||
(when (or doc int) (list doc))
|
(when (or doc int) (list doc))
|
||||||
;; optionally, the interactive spec (and the modes the
|
;; optionally, the interactive spec (and the modes the
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue