aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Schmidt2023-11-20 23:42:01 +0100
committerAndrea Corallo2023-12-04 21:43:31 +0100
commite670412a3e101e70dc26e021f467faece8cb7f6b (patch)
treeee437a40654aae105241cfdaf3cc31330c22e65f
parentf5e45247081ab2489581c650423413a2b6c2caf9 (diff)
downloademacs-e670412a3e101e70dc26e021f467faece8cb7f6b.tar.gz
emacs-e670412a3e101e70dc26e021f467faece8cb7f6b.zip
Update handling of advices during preload
* lisp/emacs-lisp/comp-common.el (native-comp-never-optimize-functions): Remove macroexpand and rename-buffer from default value. * lisp/emacs-lisp/comp.el (comp-call-optim-form-call): Document call optimization for advised primitives. * lisp/emacs-lisp/nadvice.el (advice-add): Remove references to TODOs that were completed already earlier. * lisp/loadup.el: Disallow advices during preload. (Bug#67005)
-rw-r--r--lisp/emacs-lisp/comp-common.el9
-rw-r--r--lisp/emacs-lisp/comp.el8
-rw-r--r--lisp/emacs-lisp/nadvice.el2
-rw-r--r--lisp/loadup.el9
4 files changed, 21 insertions, 7 deletions
diff --git a/lisp/emacs-lisp/comp-common.el b/lisp/emacs-lisp/comp-common.el
index 6d94d1bd82e..b7a685223ed 100644
--- a/lisp/emacs-lisp/comp-common.el
+++ b/lisp/emacs-lisp/comp-common.el
@@ -49,11 +49,10 @@ This is intended for debugging the compiler itself.
49 :version "28.1") 49 :version "28.1")
50 50
51(defcustom native-comp-never-optimize-functions 51(defcustom native-comp-never-optimize-functions
52 '(eval 52 ;; We used to list those functions here that were advised during
53 ;; The following two are mandatory for Emacs to be working 53 ;; preload, but we now prefer to disallow preload advices in
54 ;; correctly (see comment in `advice--add-function'). DO NOT 54 ;; loadup.el (bug#67005).
55 ;; REMOVE. 55 '(eval)
56 macroexpand rename-buffer)
57 "Primitive functions to exclude from trampoline optimization. 56 "Primitive functions to exclude from trampoline optimization.
58 57
59Primitive functions included in this list will not be called 58Primitive functions included in this list will not be called
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 39e32d5142c..3e5ff195764 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -2789,6 +2789,14 @@ FUNCTION can be a function-name or byte compiled function."
2789 (symbol-function callee) 2789 (symbol-function callee)
2790 (cl-assert (byte-code-function-p callee)) 2790 (cl-assert (byte-code-function-p callee))
2791 callee)) 2791 callee))
2792 ;; Below call to `subrp' returns nil on an advised
2793 ;; primitive F, so that we do not optimize calls to F
2794 ;; with the funcall trampoline removal below. But if F
2795 ;; is advised while we compile its call, it is very
2796 ;; likely to be advised also when that call is executed.
2797 ;; And in that case an "unoptimized" call to F is
2798 ;; actually cheaper since it avoids the call to the
2799 ;; intermediate native trampoline (bug#67005).
2792 (subrp (subrp f)) 2800 (subrp (subrp f))
2793 (comp-func-callee (comp-func-in-unit callee))) 2801 (comp-func-callee (comp-func-in-unit callee)))
2794 (cond 2802 (cond
diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el
index 42027c01491..9f2b42f5765 100644
--- a/lisp/emacs-lisp/nadvice.el
+++ b/lisp/emacs-lisp/nadvice.el
@@ -509,8 +509,6 @@ HOW can be one of:
509<<>>" 509<<>>"
510 ;; TODO: 510 ;; TODO:
511 ;; - record the advice location, to display in describe-function. 511 ;; - record the advice location, to display in describe-function.
512 ;; - change all defadvice in lisp/**/*.el.
513 ;; - obsolete advice.el.
514 (let* ((f (symbol-function symbol)) 512 (let* ((f (symbol-function symbol))
515 (nf (advice--normalize symbol f))) 513 (nf (advice--normalize symbol f)))
516 (unless (eq f nf) (fset symbol nf)) 514 (unless (eq f nf) (fset symbol nf))
diff --git a/lisp/loadup.el b/lisp/loadup.el
index 07895228d0d..3b58d5fb9b7 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -393,6 +393,15 @@
393;; from the repository. It is generated just after temacs is built. 393;; from the repository. It is generated just after temacs is built.
394(load "leim/leim-list.el" t) 394(load "leim/leim-list.el" t)
395 395
396;; Actively disallow advised functions during preload since:
397;; - advices in Emacs's core are generally considered bad style;
398;; - `Snarf-documentation' looses docstrings of primitives advised
399;; during preload (bug#66032#20).
400(mapatoms
401 (lambda (f)
402 (and (advice--p (symbol-function f))
403 (error "Preload advice on %s" f))))
404
396;; If you want additional libraries to be preloaded and their 405;; If you want additional libraries to be preloaded and their
397;; doc strings kept in the DOC file rather than in core, 406;; doc strings kept in the DOC file rather than in core,
398;; you may load them with a "site-load.el" file. 407;; you may load them with a "site-load.el" file.