[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/native-comp 4bea0c0 2/7: * Allow for lambda forms as native comp
From: |
Andrea Corallo |
Subject: |
feature/native-comp 4bea0c0 2/7: * Allow for lambda forms as native compilation input |
Date: |
Wed, 14 Oct 2020 05:13:46 -0400 (EDT) |
branch: feature/native-comp
commit 4bea0c0b1d907d676cc9abc8d7048103c10b8d79
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>
* Allow for lambda forms as native compilation input
* lisp/emacs-lisp/comp.el (comp-spill-lap-function): Add new
specialized method for compiling a lambda form.
---
lisp/emacs-lisp/comp.el | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 26654a3..89b4230 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -698,6 +698,45 @@ clashes."
(puthash 0 (comp-func-frame-size func) (comp-func-array-h func))
(comp-add-func-to-ctxt func))))
+(cl-defmethod comp-spill-lap-function ((form list))
+ "Byte-compile FORM spilling data from the byte compiler."
+ (unless (eq (car-safe form) 'lambda)
+ (signal 'native-compiler-error
+ "Cannot native compile, form is not a lambda"))
+ (unless (comp-ctxt-output comp-ctxt)
+ (setf (comp-ctxt-output comp-ctxt)
+ (make-temp-file "comp-lambda-" nil ".eln")))
+ (let* ((byte-code (byte-compile form))
+ (c-name (comp-c-func-name "anonymous-lambda" "F"))
+ (func (if (comp-lex-byte-func-p byte-code)
+ (make-comp-func-l :c-name c-name
+ :doc (documentation form t)
+ :int-spec (interactive-form form)
+ :speed comp-speed)
+ (make-comp-func-d :c-name c-name
+ :doc (documentation form t)
+ :int-spec (interactive-form form)
+ :speed comp-speed))))
+ (let ((lap (byte-to-native-lambda-lap
+ (gethash (aref byte-code 1)
+ byte-to-native-lambdas-h))))
+ (cl-assert lap)
+ (comp-log lap 2)
+ (if (comp-func-l-p func)
+ (setf (comp-func-l-args func)
+ (comp-decrypt-arg-list (aref byte-code 0) byte-code))
+ (setf (comp-func-d-lambda-list func) (cadr form)))
+ (setf (comp-func-lap func) lap
+ (comp-func-frame-size func) (comp-byte-frame-size
+ byte-code))
+ (setf (comp-func-byte-func func) byte-code
+ (comp-ctxt-top-level-forms comp-ctxt)
+ (list (make-byte-to-native-func-def :name '--anonymous-lambda
+ :c-name c-name)))
+ ;; Create the default array.
+ (puthash 0 (comp-func-frame-size func) (comp-func-array-h func))
+ (comp-add-func-to-ctxt func))))
+
(defun comp-intern-func-in-ctxt (_ obj)
"Given OBJ of type `byte-to-native-lambda', create a function in
`comp-ctxt'."
(when-let ((byte-func (byte-to-native-lambda-byte-func obj)))
- 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 <=
- 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, 2020/10/14
- 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