1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-08 15:30:40 -08:00

rework bytecomp spill code

This commit is contained in:
Andrea Corallo 2019-11-02 16:48:40 +01:00
parent d6ae5369b0
commit 5eb8d3dba1

View file

@ -564,14 +564,19 @@ Each element is (INDEX . VALUE)")
(defvar byte-compile-maxdepth 0 "Maximum 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 ;; These are use by comp.el to spill data out of here
(defvar byte-native-compiling nil) (cl-defstruct byte-to-native-function
"Named or anonymous function defined a top level."
name data)
(cl-defstruct byte-to-native-top-level
"All other top level forms."
form)
(defvar byte-native-compiling nil
"t while native compiling.")
(defvar byte-to-native-lap nil (defvar byte-to-native-lap nil
"Alist to accumulate lap. "A-list to accumulate LAP.
Each element is (NAME . LAP)") Each pair is (NAME . LAP)")
(defvar byte-to-native-bytecode nil (defvar byte-to-native-top-level-forms nil
"Alist to accumulate bytecode. "List of top level forms.")
Each element is (NAME . BYTECODE)")
(defvar byte-to-native-top-level-forms nil)
;;; The byte codes; this information is duplicated in bytecomp.c ;;; The byte codes; this information is duplicated in bytecomp.c
@ -2245,6 +2250,10 @@ Call from the source buffer."
;; defalias calls are output directly by byte-compile-file-form-defmumble; ;; defalias calls are output directly by byte-compile-file-form-defmumble;
;; it does not pay to first build the defalias in defmumble and then parse ;; it does not pay to first build the defalias in defmumble and then parse
;; it here. ;; it here.
(when byte-native-compiling
;; Spill output for the native compiler here
(push (make-byte-to-native-top-level :form form)
byte-to-native-top-level-forms))
(let ((print-escape-newlines t) (let ((print-escape-newlines t)
(print-length nil) (print-length nil)
(print-level nil) (print-level nil)
@ -2276,10 +2285,6 @@ we output that argument and the following argument
QUOTED says that we have to put a quote before the QUOTED says that we have to put a quote before the
list that represents a doc string reference. list that represents a doc string reference.
`defvaralias', `autoload' and `custom-declare-variable' need that." `defvaralias', `autoload' and `custom-declare-variable' need that."
(when (and byte-native-compiling name)
;; Spill bytecode output for the native compiler here
(push (cons name (apply #'vector form))
byte-to-native-bytecode))
;; We need to examine byte-compile-dynamic-docstrings ;; We need to examine byte-compile-dynamic-docstrings
;; in the input buffer (now current), not in the output buffer. ;; in the input buffer (now current), not in the output buffer.
(let ((dynamic-docstrings byte-compile-dynamic-docstrings)) (let ((dynamic-docstrings byte-compile-dynamic-docstrings))
@ -2496,9 +2501,6 @@ list that represents a doc string reference.
(setq form (copy-sequence form)) (setq form (copy-sequence form))
(setcar (cdr (cdr form)) (setcar (cdr (cdr form))
(byte-compile-top-level (nth 2 form) nil 'file)))) (byte-compile-top-level (nth 2 form) nil 'file))))
(when byte-native-compiling
;; Spill output for the native compiler here
(push form byte-to-native-top-level-forms))
form)) form))
(put 'define-abbrev-table 'byte-hunk-handler (put 'define-abbrev-table 'byte-hunk-handler
@ -2706,6 +2708,13 @@ not to take responsibility for the actual compilation of the code."
;; If there's no doc string, provide -1 as the "doc string ;; If there's no doc string, provide -1 as the "doc string
;; index" so that no element will be treated as a doc string. ;; index" so that no element will be treated as a doc string.
(if (not (stringp (documentation code t))) -1 4))) (if (not (stringp (documentation code t))) -1 4)))
(when byte-native-compiling
;; Spill output for the native compiler here.
(push (if macro
(make-byte-to-native-top-level
:form `(defalias ,name (macro . ,code) nil))
(make-byte-to-native-function :name name :data code))
byte-to-native-top-level-forms))
;; Output the form by hand, that's much simpler than having ;; Output the form by hand, that's much simpler than having
;; b-c-output-file-form analyze the defalias. ;; b-c-output-file-form analyze the defalias.
(byte-compile-output-docform (byte-compile-output-docform