summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/bytecomp.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp/bytecomp.el')
-rw-r--r--lisp/emacs-lisp/bytecomp.el43
1 files changed, 18 insertions, 25 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 9a5491b10fc..8f85c928399 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -565,7 +565,7 @@ Each element is (INDEX . VALUE)")
;; 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)
+ name c-name data lap)
(cl-defstruct byte-to-native-top-level
"All other top level forms."
form)
@@ -577,9 +577,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 nil
- "A-list to accumulate LAP.
-Each pair is (NAME . LAP)")
+(defvar byte-to-native-lap-h nil
+ "Hash byte-code -> LAP.")
(defvar byte-to-native-top-level-forms nil
"List of top level forms.")
(defvar byte-to-native-output-file nil
@@ -977,7 +976,11 @@ CONST2 may be evaluated multiple times."
;; it within 2 bytes in the byte string).
(puthash value pc hash-table))
hash-table))
- (apply 'unibyte-string (nreverse bytes))))
+ (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))
+ bytecode)))
;;; compile-time evaluation
@@ -1094,8 +1097,6 @@ message buffer `default-directory'."
(defvar byte-compile-current-file nil)
(defvar byte-compile-current-group nil)
(defvar byte-compile-current-buffer nil)
-(defvar byte-compile-not-top-level nil ; We'll evolve this for naming lambdas
- "Non nil if compiling something that is not top-level.")
;; Log something that isn't a warning.
(defmacro byte-compile-log (format-string &rest args)
@@ -2363,8 +2364,7 @@ list that represents a doc string reference.
(defun byte-compile-flush-pending ()
(if byte-compile-output
- (let* ((byte-compile-current-form nil)
- (form (byte-compile-out-toplevel t 'file)))
+ (let ((form (byte-compile-out-toplevel t 'file)))
(cond ((eq (car-safe form) 'progn)
(mapc 'byte-compile-output-file-form (cdr form)))
(form
@@ -2689,7 +2689,10 @@ 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))
+ (make-byte-to-native-function :name name
+ :data code
+ :lap (gethash (aref code 1)
+ byte-to-native-lap-h)))
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.
@@ -2918,7 +2921,6 @@ for symbols generated by the byte compiler itself."
;; args of `list'. Actually, compile it to get warnings,
;; but don't use the result.
(let* ((form (nth 1 int))
- (byte-compile-not-top-level t)
(newform (byte-compile-top-level form)))
(while (memq (car-safe form) '(let let* progn save-excursion))
(while (consp (cdr form))
@@ -3116,16 +3118,9 @@ for symbols generated by the byte compiler itself."
(not (delq nil (mapcar 'consp (cdr (car body))))))))
(setq rest (cdr rest)))
rest))
- (let* ((byte-compile-vector (byte-compile-constants-vector))
- (out (list 'byte-code (byte-compile-lapcode byte-compile-output)
- byte-compile-vector byte-compile-maxdepth)))
- (when (and byte-native-compiling
- (or (null byte-compile-not-top-level)
- (eq byte-native-compiling 'free-func)))
- ;; Spill LAP for the native compiler here
- (push (cons byte-compile-current-form byte-compile-output)
- byte-to-native-lap))
- out))
+ (let ((byte-compile-vector (byte-compile-constants-vector)))
+ (list 'byte-code (byte-compile-lapcode byte-compile-output)
+ byte-compile-vector byte-compile-maxdepth)))
;; it's a trivial function
((cdr body) (cons 'progn (nreverse body)))
((car body)))))
@@ -3175,8 +3170,7 @@ for symbols generated by the byte compiler itself."
;; byte-compile--for-effect flag too.)
;;
(defun byte-compile-form (form &optional for-effect)
- (let ((byte-compile--for-effect for-effect)
- (byte-compile-not-top-level t))
+ (let ((byte-compile--for-effect for-effect))
(cond
((not (consp form))
(cond ((or (not (symbolp form)) (macroexp--const-symbol-p form))
@@ -3950,8 +3944,7 @@ discarding."
;; and (funcall (function foo)) will lose with autoloads.
(defun byte-compile-function-form (form)
- (let ((f (nth 1 form))
- (byte-compile-not-top-level t))
+ (let ((f (nth 1 form)))
(when (and (symbolp f)
(byte-compile-warning-enabled-p 'callargs f))
(byte-compile-function-warn f t (byte-compile-fdefinition f nil)))