diff options
| -rw-r--r-- | lisp/emacs-lisp/comp.el | 21 | ||||
| -rw-r--r-- | test/src/comp-tests.el | 6 |
2 files changed, 17 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 98f552599e9..cd13c44fa91 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el | |||
| @@ -2854,12 +2854,16 @@ display a message." | |||
| 2854 | ;;;###autoload | 2854 | ;;;###autoload |
| 2855 | (defun native-compile (function-or-file &optional with-late-load output) | 2855 | (defun native-compile (function-or-file &optional with-late-load output) |
| 2856 | "Compile FUNCTION-OR-FILE into native code. | 2856 | "Compile FUNCTION-OR-FILE into native code. |
| 2857 | This is the entry-point for the Emacs Lisp native compiler. | 2857 | This is the syncronous entry-point for the Emacs Lisp native |
| 2858 | FUNCTION-OR-FILE is a function symbol or a path to an Elisp file. | 2858 | compiler. |
| 2859 | When WITH-LATE-LOAD non-nil mark the compilation unit for late load | 2859 | FUNCTION-OR-FILE is a function symbol, a form or the |
| 2860 | once finished compiling (internal use only). | 2860 | filename of an Emacs Lisp source file. |
| 2861 | When OUTPUT is non-nil use it as filename for the compiled object. | 2861 | When WITH-LATE-LOAD non-nil mark the compilation unit for late |
| 2862 | Return the compile object filename." | 2862 | load once finished compiling (internal use only). When OUTPUT is |
| 2863 | non-nil use it as filename for the compiled object. | ||
| 2864 | If FUNCTION-OR-FILE is a filename return the filename of the | ||
| 2865 | compiled object. If FUNCTION-OR-FILE is a function symbol or a | ||
| 2866 | form return the compiled function." | ||
| 2863 | (comp-ensure-native-compiler) | 2867 | (comp-ensure-native-compiler) |
| 2864 | (unless (or (functionp function-or-file) | 2868 | (unless (or (functionp function-or-file) |
| 2865 | (stringp function-or-file)) | 2869 | (stringp function-or-file)) |
| @@ -2888,7 +2892,10 @@ Return the compile object filename." | |||
| 2888 | (signal (car err) (if (consp err-val) | 2892 | (signal (car err) (if (consp err-val) |
| 2889 | (cons function-or-file err-val) | 2893 | (cons function-or-file err-val) |
| 2890 | (list function-or-file err-val)))))) | 2894 | (list function-or-file err-val)))))) |
| 2891 | data)) | 2895 | (if (stringp function-or-file) |
| 2896 | data | ||
| 2897 | ;; So we return the compiled function. | ||
| 2898 | (native-elisp-load data)))) | ||
| 2892 | 2899 | ||
| 2893 | ;;;###autoload | 2900 | ;;;###autoload |
| 2894 | (defun batch-native-compile () | 2901 | (defun batch-native-compile () |
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index 317a6113af2..79bac3f711f 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el | |||
| @@ -359,7 +359,7 @@ Check that the resulting binaries do not differ." | |||
| 359 | (interactive) | 359 | (interactive) |
| 360 | 3) | 360 | 3) |
| 361 | t) | 361 | t) |
| 362 | (load (native-compile #'comp-tests-free-fun-f)) | 362 | (native-compile #'comp-tests-free-fun-f) |
| 363 | 363 | ||
| 364 | (should (subr-native-elisp-p (symbol-function #'comp-tests-free-fun-f))) | 364 | (should (subr-native-elisp-p (symbol-function #'comp-tests-free-fun-f))) |
| 365 | (should (= (comp-tests-free-fun-f) 3)) | 365 | (should (= (comp-tests-free-fun-f) 3)) |
| @@ -692,7 +692,7 @@ CHECKER should always return nil to have a pass." | |||
| 692 | b | 692 | b |
| 693 | (comp-tests-tco-f (+ a b) a (- count 1)))) | 693 | (comp-tests-tco-f (+ a b) a (- count 1)))) |
| 694 | t) | 694 | t) |
| 695 | (load (native-compile #'comp-tests-tco-f)) | 695 | (native-compile #'comp-tests-tco-f) |
| 696 | (should (subr-native-elisp-p (symbol-function #'comp-tests-tco-f))) | 696 | (should (subr-native-elisp-p (symbol-function #'comp-tests-tco-f))) |
| 697 | (should (= (comp-tests-tco-f 1 0 10) 55)))) | 697 | (should (= (comp-tests-tco-f 1 0 10) 55)))) |
| 698 | 698 | ||
| @@ -714,7 +714,7 @@ CHECKER should always return nil to have a pass." | |||
| 714 | (c (concat a b))) ; <= has to optimize | 714 | (c (concat a b))) ; <= has to optimize |
| 715 | (length c))) ; <= has to optimize | 715 | (length c))) ; <= has to optimize |
| 716 | t) | 716 | t) |
| 717 | (load (native-compile #'comp-tests-fw-prop-1-f)) | 717 | (native-compile #'comp-tests-fw-prop-1-f) |
| 718 | (should (subr-native-elisp-p (symbol-function #'comp-tests-fw-prop-1-f))) | 718 | (should (subr-native-elisp-p (symbol-function #'comp-tests-fw-prop-1-f))) |
| 719 | (should (= (comp-tests-fw-prop-1-f) 6)))) | 719 | (should (= (comp-tests-fw-prop-1-f) 6)))) |
| 720 | 720 | ||