From 5edc7aa0193ec73f757e85012273c159301f64a9 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sun, 25 Oct 2020 21:19:25 +0000 Subject: [PATCH] Fix defsubst effectiveness (bug#44209) * lisp/emacs-lisp/byte-run.el (defsubst): Fix macro definition. * test/src/comp-tests.el (comp-test-defsubst): New testcase. * test/src/comp-test-funcs.el (comp-test-defsubst-f): New function. --- lisp/emacs-lisp/byte-run.el | 8 ++++---- test/src/comp-test-funcs.el | 3 +++ test/src/comp-tests.el | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 042a26a2e31..1bc78391886 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -363,13 +363,13 @@ You don't need this. (See bytecomp.el commentary for more details.) (or (memq (get name 'byte-optimizer) '(nil byte-compile-inline-expand)) (error "`%s' is a primitive" name)) - ;; Never native-compile defsubsts as we need the byte - ;; definition in `byte-compile-unfold-bcf' to perform the - ;; inlining (Bug#42664). - (byte-run--set-speed name nil -1) `(prog1 (defun ,name ,arglist ,@body) (eval-and-compile + ;; Never native-compile defsubsts as we need the byte + ;; definition in `byte-compile-unfold-bcf' to perform the + ;; inlining (Bug#42664, Bug#43280, Bug#44209). + ,(byte-run--set-speed name nil -1) (put ',name 'byte-optimizer 'byte-compile-inline-expand)))) (defvar advertised-signature-table (make-hash-table :test 'eq :weakness 'key)) diff --git a/test/src/comp-test-funcs.el b/test/src/comp-test-funcs.el index 9285ed62c2a..35df46a9b84 100644 --- a/test/src/comp-test-funcs.el +++ b/test/src/comp-test-funcs.el @@ -345,6 +345,9 @@ (declare (speed 2)) (- x y)) +(defsubst comp-test-defsubst-f () + t) + ;;;;;;;;;;;;;;;;;;;; ;; Tromey's tests ;; diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index b9a0a8771e5..ae96e5d3868 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el @@ -426,6 +426,10 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html." (should (subr-native-elisp-p f)) (should (= (funcall f 2) 3)))) +(comp-deftest comp-test-defsubst () + ;; Bug#42664, Bug#43280, Bug#44209. + (should-not (subr-native-elisp-p (symbol-function #'comp-test-defsubst-f)))) + ;;;;;;;;;;;;;;;;;;;;; ;; Tromey's tests. ;; -- 2.39.5