diff options
Diffstat (limited to 'lisp/emacs-lisp/bytecomp.el')
-rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 86 |
1 files changed, 55 insertions, 31 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index c0662a6d280..f33c30e5742 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -562,13 +562,31 @@ Each element is (INDEX . VALUE)") (defvar byte-compile-depth 0 "Current depth of execution stack.") (defvar byte-compile-maxdepth 0 "Maximum depth of execution stack.") -;; These are use by comp.el to spill data out of here -(cl-defstruct byte-to-native-function - "Named or anonymous function defined a top level." - name c-name data lap) +;; The following is used by comp.el to spill data out of here. +;; +;; Spilling is done in 3 places: +;; +;; - `byte-compile-lapcode' to obtain the map bytecode -> LAP for any +;; code assembled. +;; +;; - `byte-compile-lambda' to obtain arglist doc and interactive spec +;; af any lambda compiled (including anonymous). +;; +;; - `byte-compile-file-form-defmumble' to obtain the list of +;; top-level forms as they would be outputted in the .elc file. +;; + +(cl-defstruct byte-to-native-lambda + byte-func lap) + +;; Top level forms: +(cl-defstruct byte-to-native-func-def + "Named function defined at top-level." + name c-name byte-func) (cl-defstruct byte-to-native-top-level - "All other top level forms." - form) + "All other top-level forms." + form) + (defvar byte-native-compiling nil "Non nil while native compiling.") (defvar byte-native-for-bootstrap nil @@ -577,8 +595,8 @@ Each element is (INDEX . VALUE)") ;; Because the make target is the later this has to be produced as ;; last to be resilient against build interruptions. ) -(defvar byte-to-native-lap-h nil - "Hash byte-code -> LAP.") +(defvar byte-to-native-lambdas-h nil + "Hash byte-code -> byte-to-native-lambda.") (defvar byte-to-native-top-level-forms nil "List of top level forms.") (defvar byte-to-native-output-file nil @@ -978,8 +996,9 @@ CONST2 may be evaluated multiple times." hash-table)) (let ((bytecode (apply 'unibyte-string (nreverse bytes)))) (when byte-native-compiling - ;; Spill LAP for the native compiler here - (puthash bytecode lap byte-to-native-lap-h)) + ;; Spill LAP for the native compiler here. + (puthash bytecode (make-byte-to-native-lambda :lap lap) + byte-to-native-lambdas-h)) bytecode))) @@ -2689,10 +2708,8 @@ not to take responsibility for the actual compilation of the code." (push (if macro (make-byte-to-native-top-level :form `(defalias ',name '(macro . ,code) nil)) - (make-byte-to-native-function :name name - :data code - :lap (gethash (aref code 1) - byte-to-native-lap-h))) + (make-byte-to-native-func-def :name name + :byte-func code)) byte-to-native-top-level-forms)) ;; Output the form by hand, that's much simpler than having ;; b-c-output-file-form analyze the defalias. @@ -2950,23 +2967,30 @@ for symbols generated by the byte compiler itself." reserved-csts))) ;; Build the actual byte-coded function. (cl-assert (eq 'byte-code (car-safe compiled))) - (apply #'make-byte-code - (if lexical-binding - (byte-compile-make-args-desc arglist) - arglist) - (append - ;; byte-string, constants-vector, stack depth - (cdr compiled) - ;; optionally, the doc string. - (cond ((and lexical-binding arglist) - ;; byte-compile-make-args-desc lost the args's names, - ;; so preserve them in the docstring. - (list (help-add-fundoc-usage doc arglist))) - ((or doc int) - (list doc))) - ;; optionally, the interactive spec. - (if int - (list (nth 1 int)))))))) + (let ((out + (apply #'make-byte-code + (if lexical-binding + (byte-compile-make-args-desc arglist) + arglist) + (append + ;; byte-string, constants-vector, stack depth + (cdr compiled) + ;; optionally, the doc string. + (cond ((and lexical-binding arglist) + ;; byte-compile-make-args-desc lost the args's names, + ;; so preserve them in the docstring. + (list (help-add-fundoc-usage doc arglist))) + ((or doc int) + (list doc))) + ;; optionally, the interactive spec. + (if int + (list (nth 1 int))))))) + (when byte-native-compiling + (setf (byte-to-native-lambda-byte-func + (gethash (cadr compiled) + byte-to-native-lambdas-h)) + out)) + out)))) (defvar byte-compile-reserved-constants 0) |