emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/native-comp db354ff 06/11: Call `comp--subr-safe-advice' from th


From: Andrea Corallo
Subject: feature/native-comp db354ff 06/11: Call `comp--subr-safe-advice' from the advice machinery
Date: Thu, 24 Sep 2020 04:13:18 -0400 (EDT)

branch: feature/native-comp
commit db354ffd578a46d898cac161ea1de1b42f96d2a0
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    Call `comp--subr-safe-advice' from the advice machinery
    
        * lisp/emacs-lisp/nadvice.el (advice--add-function): Call
        `comp--subr-safe-advice' when necessary.
    
        * lisp/emacs-lisp/advice.el (ad-add-advice): Likewhise.
---
 lisp/emacs-lisp/advice.el  |  2 ++
 lisp/emacs-lisp/nadvice.el | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el
index 0ebd274..4c19197 100644
--- a/lisp/emacs-lisp/advice.el
+++ b/lisp/emacs-lisp/advice.el
@@ -2075,6 +2075,8 @@ mapped to the closest extremal position).
 If FUNCTION was not advised already, its advice info will be
 initialized.  Redefining a piece of advice whose name is part of
 the cache-id will clear the cache."
+  (when (subr-primitive-p (symbol-function function))
+    (comp--subr-safe-advice function))
   (cond ((not (ad-is-advised function))
          (ad-initialize-advice-info function)
         (ad-set-advice-info-field
diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el
index b779aa2..32b5df8 100644
--- a/lisp/emacs-lisp/nadvice.el
+++ b/lisp/emacs-lisp/nadvice.el
@@ -318,6 +318,22 @@ is also interactive.  There are 3 cases:
 
 ;;;###autoload
 (defun advice--add-function (where ref function props)
+  (when (and (boundp 'comp-ctxt)
+             (subr-primitive-p (gv-deref ref)))
+    (let ((subr-name (intern (subr-name (gv-deref ref)))))
+      ;; Requiring the native compiler to advice `macroexpand' cause a
+      ;; circular dependency in eager macro expansion.
+      ;; uniquify is advising `rename-buffer' while being loaded in
+      ;; loadup.el.  This would require the whole native compiler
+      ;; machinery but we don't want to include it in the dump.
+      ;; Because these two functions are already handled in
+      ;; `comp-never-optimize-functions' we hack the problem this way
+      ;; for now :/
+      (unless (memq subr-name '(macroexpand rename-buffer))
+        ;; Must require explicitly as during bootstrap we have no
+        ;; autoloads.
+        (require 'comp)
+        (comp--subr-safe-advice subr-name))))
   (let* ((name (cdr (assq 'name props)))
          (a (advice--member-p (or name function) (if name t) (gv-deref ref))))
     (when a



reply via email to

[Prev in Thread] Current Thread [Next in Thread]