]> git.eshelyaron.com Git - emacs.git/commitdiff
Redirect calls to `subr-native-elisp-p` to `native-comp-function-p`
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 22 May 2024 18:45:35 +0000 (14:45 -0400)
committerEshel Yaron <me@eshelyaron.com>
Wed, 29 May 2024 10:12:41 +0000 (12:12 +0200)
* test/src/comp-tests.el (comp-tests-bootstrap, lambda-return)
(lambda-return2, free-fun, free-fun2, free-fun-silly-name, speed--1)
(compile-forms, comp-test-defsubst, primitive-redefine-compile-44221)
(48029-1, 61917-1, tco, fw-prop-1, pure):
* test/lisp/help-fns-tests.el (help-fns-test-lisp-defun):
* lisp/subr.el (subr-primitive-p, primitive-function-p, symbol-file):
* lisp/help-fns.el (find-lisp-object-file-name):
* lisp/emacs-lisp/disass.el (disassemble-internal):
* lisp/emacs-lisp/comp.el (comp--call-optim-form-call):
* lisp/emacs-lisp/comp-run.el (comp-warn-primitives):
* lisp/emacs-lisp/comp-common.el (comp-function-type-spec):
* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns):
* lisp/emacs-lisp/bytecomp.el (<trailer>): Rename `subr-native-elisp-p`
to `native-comp-function-p`.

(cherry picked from commit fde8dc9287c0a81c6b942b5cf445f8f7aeba1207)

lisp/emacs-lisp/byte-opt.el
lisp/emacs-lisp/bytecomp.el
lisp/emacs-lisp/comp-common.el
lisp/emacs-lisp/comp-run.el
lisp/emacs-lisp/comp.el
lisp/emacs-lisp/disass.el
lisp/help-fns.el
lisp/subr.el
test/lisp/help-fns-tests.el
test/src/comp-tests.el

index 4095726d27681e9e3f202b122a59fe7939a94ec4..c060c8d676bc9a4a51bd254dd20c206e4826402e 100644 (file)
@@ -1876,9 +1876,10 @@ See Info node `(elisp) Integer Basics'."
          byteorder car-safe cdr-safe char-or-string-p char-table-p
          condition-variable-p consp eq floatp indirect-function
          integer-or-marker-p integerp keywordp listp markerp
-         module-function-p multibyte-string-p mutexp natnump nlistp null
+         module-function-p multibyte-string-p mutexp native-comp-function-p
+         natnump nlistp null
          number-or-marker-p numberp recordp remove-pos-from-symbol
-         sequencep stringp subr-native-elisp-p subrp symbol-with-pos-p symbolp
+         sequencep stringp subrp symbol-with-pos-p symbolp
          threadp type-of user-ptrp vector-or-char-table-p vectorp wholenump
          ;; editfns.c
          bobp bolp buffer-size buffer-string current-message emacs-pid
index 12b45f9f5b8836acb086271f52528907cf19c068..03cfbe6f4c91cc0d5efb20b66b24095ac976fced 100644 (file)
@@ -6028,7 +6028,7 @@ and corresponding effects."
       (let ((byte-optimize nil)                ; do it fast
            (byte-compile-warnings nil))
        (mapc (lambda (x)
-                (unless (subr-native-elisp-p x)
+                (unless (native-comp-function-p x)
                  (or noninteractive (message "compiling %s..." x))
                  (byte-compile x)
                  (or noninteractive (message "compiling %s...done" x))))
index 355988838c713216ca4a4450b9bdcea7aaf7c25a..ce6296953bfa06677057c0c77ed0b8098357a6f1 100644 (file)
@@ -518,7 +518,7 @@ itself."
         (if-let ((delc-type (function-get function 'function-type)))
             ;; Declared Lisp function
             (setf type-spec delc-type)
-          (when (subr-native-elisp-p f)
+          (when (native-comp-function-p f)
             ;; Native compiled inferred
             (setf kind 'inferred
                   type-spec (subr-type f))))))
index 5cc615790306ceda9c59b7d74b2cde4855235748..f159c5b1911225ba36f07797f82e127643802141 100644 (file)
@@ -341,7 +341,7 @@ display a message."
     (clrhash comp-deferred-pending-h)))
 
 (defconst comp-warn-primitives
-  '(null memq gethash and subrp not subr-native-elisp-p
+  '(null memq gethash and subrp not native-comp-function-p
          comp--install-trampoline concat if symbolp symbol-name make-string
          length aset aref length> mapcar expand-file-name
          file-name-as-directory file-exists-p native-elisp-load)
index 4c76f95a0e92dccf1d28ee4429db6ee039ef4b0c..32d4442ca1b1f107898101e2c17cae4a9d4bbb8d 100644 (file)
@@ -2847,7 +2847,7 @@ FUNCTION can be a function-name or byte compiled function."
              (subrp (subrp f))
              (comp-func-callee (comp--func-in-unit callee)))
         (cond
-         ((and subrp (not (subr-native-elisp-p f)))
+         ((and subrp (not (native-comp-function-p f)))
           ;; Trampoline removal.
           (let* ((callee (intern (subr-name f))) ; Fix aliased names.
                  (maxarg (cdr (subr-arity f)))
index 9142716613768e5b79be1fa3824050ea337bb2b5..07072f2a2be9727351a5f790e48c1fef39b5ff1e 100644 (file)
@@ -91,8 +91,8 @@ redefine OBJECT if it is a symbol."
        args)
     (setq obj (autoload-do-load obj name))
     (if (subrp obj)
-        (if (and (fboundp 'subr-native-elisp-p)
-                 (subr-native-elisp-p obj))
+        (if (and (fboundp 'native-comp-function-p)
+                 (native-comp-function-p obj))
             (progn
               (require 'comp)
               (let ((eln (native-comp-unit-file (subr-native-comp-unit obj))))
index 051362fcd78f0c3f290d350c5f80306d594a53be..040d82801e1a4d3d890b39813b62ca43262909e9 100644 (file)
@@ -521,7 +521,7 @@ the C sources, too."
     (cond
      ((and (not file-name)
            (subrp type)
-           (not (subr-native-elisp-p type)))
+           (not (native-comp-function-p type)))
       ;; A built-in function.  The form is from `describe-function-1'.
       (if (or (get-buffer " *DOC*")
               (and also-c-source
index 3b1145afdc2fd5e0c6fbf7e1a125d2abc874b6d4..12e3f605afb0ddcd080a7c2304e460dab44c57d4 100644 (file)
@@ -316,14 +316,14 @@ value of last one, or nil if there are none."
 Such objects can be functions or special forms."
   (declare (side-effect-free error-free))
   (and (subrp object)
-       (not (subr-native-elisp-p object))))
+       (not (native-comp-function-p object))))
 
 (defsubst primitive-function-p (object)
   "Return t if OBJECT is a built-in primitive function.
 This excludes special forms, since they are not functions."
   (declare (side-effect-free error-free))
   (and (subrp object)
-       (not (or (subr-native-elisp-p object)
+       (not (or (native-comp-function-p object)
                 (eq (cdr (subr-arity object)) 'unevalled)))))
 
 (defsubst xor (cond1 cond2)
@@ -3023,7 +3023,7 @@ This is to `put' what `defalias' is to `fset'."
 
 (defvar comp-native-version-dir)
 (defvar native-comp-eln-load-path)
-(declare-function subr-native-elisp-p "data.c")
+(declare-function native-comp-function-p "data.c")
 (declare-function native-comp-unit-file "data.c")
 (declare-function subr-native-comp-unit "data.c")
 (declare-function comp-el-to-eln-rel-filename "comp.c")
@@ -3072,7 +3072,7 @@ instead."
             (symbolp symbol)
             (native-comp-available-p)
             ;; If it's a defun, we have a shortcut.
-            (subr-native-elisp-p (symbol-function symbol)))
+            (native-comp-function-p (symbol-function symbol)))
        ;; native-comp-unit-file returns unnormalized file names.
        (expand-file-name (native-comp-unit-file (subr-native-comp-unit
                                                  (symbol-function symbol))))
index 82350a4bc7108e4724afe51814782737e52ac8e7..7393a2624fed845d697419e45debe6eb87da01f6 100644 (file)
@@ -67,7 +67,7 @@ Return first line of the output of (describe-function-1 FUNC)."
         (result (help-fns-tests--describe-function 'last)))
     (should (string-match regexp result))
     (should (member (match-string 1 result)
-                    '("subr-native-elisp" "byte-code-function")))))
+                    '("native-comp-function" "byte-code-function")))))
 
 (ert-deftest help-fns-test-lisp-defsubst ()
   (let ((regexp "a byte-code-function in .+subr\\.el")
index 5deff03fd846857486051e31c0cc9e05905856b2..dffb7097a3e26c81d3b141e5c45680949d49e06d 100644 (file)
@@ -85,13 +85,13 @@ Check that the resulting binaries do not differ."
         (copy-file comp-src comp2-src t)
         (let ((load-no-native t))
           (load (concat comp-src "c") nil nil t t))
-        (should-not (subr-native-elisp-p (symbol-function 'native-compile)))
+        (should-not (native-comp-function-p (symbol-function 'native-compile)))
         (message "Compiling stage1...")
         (let* ((t0 (current-time))
                (comp1-eln (native-compile comp1-src)))
           (message "Done in %d secs" (float-time (time-since t0)))
           (load comp1-eln nil nil t t)
-          (should (subr-native-elisp-p (symbol-function 'native-compile)))
+          (should (native-comp-function-p (symbol-function 'native-compile)))
           (message "Compiling stage2...")
           (let ((t0 (current-time))
                 (comp2-eln (native-compile comp2-src)))
@@ -325,15 +325,15 @@ Check that the resulting binaries do not differ."
 
 (comp-deftest lambda-return ()
   (let ((f (comp-tests-lambda-return-f)))
-    (should (subr-native-elisp-p f))
+    (should (native-comp-function-p f))
     (should (= (funcall f 3) 4))))
 
 (comp-deftest lambda-return2 ()
   "Check a nested lambda function gets native compiled."
   (let ((f (comp-tests-lambda-return-f2)))
-    (should (subr-native-elisp-p f))
+    (should (native-comp-function-p f))
     (let ((f2 (funcall f)))
-      (should (subr-native-elisp-p f2))
+      (should (native-comp-function-p f2))
       (should (= (funcall f2 3) 4)))))
 
 (comp-deftest recursive ()
@@ -391,7 +391,7 @@ Check that the resulting binaries do not differ."
         t)
   (native-compile #'comp-tests-free-fun-f)
 
-  (should (subr-native-elisp-p (symbol-function 'comp-tests-free-fun-f)))
+  (should (native-comp-function-p (symbol-function 'comp-tests-free-fun-f)))
   (should (= (comp-tests-free-fun-f) 3))
   (should (string= (documentation #'comp-tests-free-fun-f)
                    "Some doc."))
@@ -412,8 +412,8 @@ Check that the resulting binaries do not differ."
 
   (let* ((f (symbol-function 'comp-tests-free-fun-f2))
          (f2 (funcall f)))
-    (should (subr-native-elisp-p f))
-    (should (subr-native-elisp-p f2))
+    (should (native-comp-function-p f))
+    (should (native-comp-function-p f2))
     (should (string= (documentation f2) "Some doc."))
     (should (commandp f2))
     (should (equal (interactive-form f2) '(interactive nil)))
@@ -425,7 +425,7 @@ Check that the resulting binaries do not differ."
   "Check we are able to compile a single function."
   (eval '(defun comp-tests/free\fun-f ()) t)
   (native-compile #'comp-tests/free\fun-f)
-  (should (subr-native-elisp-p (symbol-function 'comp-tests/free\fun-f))))
+  (should (native-comp-function-p (symbol-function 'comp-tests/free\fun-f))))
 
 (comp-deftest bug-40187 ()
   "Check function name shadowing.
@@ -436,7 +436,7 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html."
 (comp-deftest speed--1 ()
   "Check that at speed -1 we do not native compile."
   (should (= (comp-test-speed--1-f) 3))
-  (should-not (subr-native-elisp-p (symbol-function 'comp-test-speed--1-f))))
+  (should-not (native-comp-function-p (symbol-function 'comp-test-speed--1-f))))
 
 (comp-deftest bug-42360 ()
   "<https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-07/msg00418.html>."
@@ -497,22 +497,22 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html."
   (should-error (native-compile '(+ 1 foo)))
   (let ((lexical-binding t)
         (f (native-compile '(lambda (x) (1+ x)))))
-    (should (subr-native-elisp-p f))
+    (should (native-comp-function-p f))
     (should (= (funcall f 2) 3)))
   (let* ((lexical-binding nil)
          (f (native-compile '(lambda (x) (1+ x)))))
-    (should (subr-native-elisp-p f))
+    (should (native-comp-function-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))))
+  (should-not (native-comp-function-p (symbol-function 'comp-test-defsubst-f))))
 
 (comp-deftest primitive-redefine-compile-44221 ()
   "Test the compiler still works while primitives are redefined (bug#44221)."
   (cl-letf (((symbol-function 'delete-region)
              (lambda (_ _))))
-    (should (subr-native-elisp-p
+    (should (native-comp-function-p
              (native-compile
               '(lambda ()
                  (delete-region (point-min) (point-max))))))))
@@ -564,7 +564,7 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html."
 
 (comp-deftest 48029-1 ()
   "<https://lists.gnu.org/archive/html/bug-gnu-emacs/2022-07/msg00666.html>"
-  (should (subr-native-elisp-p
+  (should (native-comp-function-p
            (symbol-function 'comp-test-48029-nonascii-žžž-f))))
 
 (comp-deftest 61917-1 ()
@@ -578,7 +578,7 @@ dedicated byte-op code."
         (setf x (native-compile
                  '(lambda ()
                     (delete-region 1 2))))
-      (should (subr-native-elisp-p x))
+      (should (native-comp-function-p x))
       (funcall x)
       (advice-remove #'delete-region f)
       (should (equal comp-test-primitive-redefine-args '(1 2))))))
@@ -874,7 +874,7 @@ Return a list of results."
                (comp-tests-tco-f (+ a b) a (- count 1))))
           t)
     (native-compile #'comp-tests-tco-f)
-    (should (subr-native-elisp-p (symbol-function 'comp-tests-tco-f)))
+    (should (native-comp-function-p (symbol-function 'comp-tests-tco-f)))
     (should (= (comp-tests-tco-f 1 0 10) 55))))
 
 (defun comp-tests-fw-prop-checker-1 (_)
@@ -901,7 +901,7 @@ Return a list of results."
                (length c))) ; <= has to optimize
           t)
     (native-compile #'comp-tests-fw-prop-1-f)
-    (should (subr-native-elisp-p (symbol-function 'comp-tests-fw-prop-1-f)))
+    (should (native-comp-function-p (symbol-function 'comp-tests-fw-prop-1-f)))
     (should (= (comp-tests-fw-prop-1-f) 6))))
 
 (defun comp-tests--type-lists-equal (l1 l2)
@@ -1556,10 +1556,10 @@ folded."
     (declare-function comp-tests-pure-caller-f nil)
     (declare-function comp-tests-pure-fibn-entry-f nil)
 
-    (should (subr-native-elisp-p (symbol-function 'comp-tests-pure-caller-f)))
+    (should (native-comp-function-p (symbol-function 'comp-tests-pure-caller-f)))
     (should (= (comp-tests-pure-caller-f) 4))
 
-    (should (subr-native-elisp-p (symbol-function 'comp-tests-pure-fibn-entry-f)))
+    (should (native-comp-function-p (symbol-function 'comp-tests-pure-fibn-entry-f)))
     (should (= (comp-tests-pure-fibn-entry-f) 6765))))
 
 (defvar comp-tests-cond-rw-checked-function nil