[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master bba48d6 2/3: More robust optimisation of `ignore`
From: |
Mattias Engdegård |
Subject: |
master bba48d6 2/3: More robust optimisation of `ignore` |
Date: |
Mon, 6 Sep 2021 10:48:37 -0400 (EDT) |
branch: master
commit bba48d6ee5d90f326c70cbe8af19dfe6b00651ba
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
More robust optimisation of `ignore`
Treat `ignore` as any other function during source-level optimisation,
to avoid having its warning-suppression effects cancelled by repeated
passes. Instead, define a custom code generation function.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
Don't treat `ignore' specially here.
(side-effect-free-fns): Don't mark `ignore` as side-effect-free
or error-free (although it is), since that would allow the optimiser
to elide calls.
* lisp/emacs-lisp/bytecomp.el (ignore, byte-compile-ignore):
Define and register a code-gen function.
---
lisp/emacs-lisp/byte-opt.el | 11 +++--------
lisp/emacs-lisp/bytecomp.el | 6 ++++++
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 0c30d83..23c5a56 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -562,13 +562,6 @@ Same format as `byte-optimize--lexvars', with shared
structure and contents.")
`(catch ,(byte-optimize-form tag nil)
. ,(byte-optimize-body exps for-effect))))
- (`(ignore . ,exps)
- ;; Don't treat the args to `ignore' as being
- ;; computed for effect. We want to avoid the warnings
- ;; that might occur if they were treated that way.
- ;; However, don't actually bother calling `ignore'.
- `(progn ,@(mapcar #'byte-optimize-form exps) nil))
-
;; Needed as long as we run byte-optimize-form after cconv.
(`(internal-make-closure . ,_)
;; Look up free vars and mark them to be kept, so that they
@@ -1419,7 +1412,9 @@ See Info node `(elisp) Integer Basics'."
fixnump floatp following-char framep
get-largest-window get-lru-window
hash-table-p
- identity ignore integerp integer-or-marker-p interactive-p
+ ;; `ignore' isn't here because we don't want calls to it elided;
+ ;; see `byte-compile-ignore'.
+ identity integerp integer-or-marker-p interactive-p
invocation-directory invocation-name
keymapp keywordp
list listp
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 145cdba..8ea591b 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -4207,6 +4207,7 @@ discarding."
(byte-defop-compiler-1 funcall)
(byte-defop-compiler-1 let)
(byte-defop-compiler-1 let* byte-compile-let)
+(byte-defop-compiler-1 ignore)
(defun byte-compile-progn (form)
(byte-compile-body-do-effect (cdr form)))
@@ -4222,6 +4223,11 @@ discarding."
(if ,discard 'byte-goto-if-nil 'byte-goto-if-nil-else-pop))
,tag))
+(defun byte-compile-ignore (form)
+ (dolist (arg (cdr form))
+ (byte-compile-form arg t))
+ (byte-compile-form nil))
+
;; Return the list of items in CONDITION-PARAM that match PRED-LIST.
;; Only return items that are not in ONLY-IF-NOT-PRESENT.
(defun byte-compile-find-bound-condition (condition-param