[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/native-comp 4f0e879 4/7: Rework `native-compile' interface so it
From: |
Andrea Corallo |
Subject: |
feature/native-comp 4f0e879 4/7: Rework `native-compile' interface so it can return compiled functions |
Date: |
Wed, 14 Oct 2020 05:13:47 -0400 (EDT) |
branch: feature/native-comp
commit 4f0e87903095da1225830e27ef27e61ba9ff08af
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>
Rework `native-compile' interface so it can return compiled functions
* lisp/emacs-lisp/comp.el (native-compile): Return the compiled
function when the input is a symbol or a form.
* test/src/comp-tests.el (free-fun, tco, fw-prop): Update tests
for new `native-compile' interface.
---
lisp/emacs-lisp/comp.el | 21 ++++++++++++++-------
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 98f5525..cd13c44 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -2854,12 +2854,16 @@ display a message."
;;;###autoload
(defun native-compile (function-or-file &optional with-late-load output)
"Compile FUNCTION-OR-FILE into native code.
-This is the entry-point for the Emacs Lisp native compiler.
-FUNCTION-OR-FILE is a function symbol or a path to an Elisp file.
-When WITH-LATE-LOAD non-nil mark the compilation unit for late load
-once finished compiling (internal use only).
-When OUTPUT is non-nil use it as filename for the compiled object.
-Return the compile object filename."
+This is the syncronous entry-point for the Emacs Lisp native
+compiler.
+FUNCTION-OR-FILE is a function symbol, a form or the
+filename of an Emacs Lisp source file.
+When WITH-LATE-LOAD non-nil mark the compilation unit for late
+load once finished compiling (internal use only). When OUTPUT is
+non-nil use it as filename for the compiled object.
+If FUNCTION-OR-FILE is a filename return the filename of the
+compiled object. If FUNCTION-OR-FILE is a function symbol or a
+form return the compiled function."
(comp-ensure-native-compiler)
(unless (or (functionp function-or-file)
(stringp function-or-file))
@@ -2888,7 +2892,10 @@ Return the compile object filename."
(signal (car err) (if (consp err-val)
(cons function-or-file err-val)
(list function-or-file err-val))))))
- data))
+ (if (stringp function-or-file)
+ data
+ ;; So we return the compiled function.
+ (native-elisp-load data))))
;;;###autoload
(defun batch-native-compile ()
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el
index 317a611..79bac3f 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."
(interactive)
3)
t)
- (load (native-compile #'comp-tests-free-fun-f))
+ (native-compile #'comp-tests-free-fun-f)
(should (subr-native-elisp-p (symbol-function #'comp-tests-free-fun-f)))
(should (= (comp-tests-free-fun-f) 3))
@@ -692,7 +692,7 @@ CHECKER should always return nil to have a pass."
b
(comp-tests-tco-f (+ a b) a (- count 1))))
t)
- (load (native-compile #'comp-tests-tco-f))
+ (native-compile #'comp-tests-tco-f)
(should (subr-native-elisp-p (symbol-function #'comp-tests-tco-f)))
(should (= (comp-tests-tco-f 1 0 10) 55))))
@@ -714,7 +714,7 @@ CHECKER should always return nil to have a pass."
(c (concat a b))) ; <= has to optimize
(length c))) ; <= has to optimize
t)
- (load (native-compile #'comp-tests-fw-prop-1-f))
+ (native-compile #'comp-tests-fw-prop-1-f)
(should (subr-native-elisp-p (symbol-function #'comp-tests-fw-prop-1-f)))
(should (= (comp-tests-fw-prop-1-f) 6))))
- feature/native-comp updated (237fd33 -> f8505fd), Andrea Corallo, 2020/10/14
- feature/native-comp 4bea0c0 2/7: * Allow for lambda forms as native compilation input, Andrea Corallo, 2020/10/14
- feature/native-comp fda7988 1/7: * Move context output computation in `comp-spill-lap-function', Andrea Corallo, 2020/10/14
- feature/native-comp 4f0e879 4/7: Rework `native-compile' interface so it can return compiled functions,
Andrea Corallo <=
- feature/native-comp e9c150b 5/7: * Add a test to verify form native compilation., Andrea Corallo, 2020/10/14
- feature/native-comp 03e98f9 6/7: Use form native compilation in `comp-trampoline-compile', Andrea Corallo, 2020/10/14
- feature/native-comp 8861ee8 3/7: Have `native-elisp-load' return the last registerd function, Andrea Corallo, 2020/10/14
- feature/native-comp f8505fd 7/7: Merge remote-tracking branch 'savannah/master' into HEAD, Andrea Corallo, 2020/10/14