emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 9d35afed49: Extend LAP optimisations to more operations


From: Mattias Engdegård
Subject: master 9d35afed49: Extend LAP optimisations to more operations
Date: Wed, 10 Aug 2022 06:53:05 -0400 (EDT)

branch: master
commit 9d35afed49896928433bb28a781b6060bc1601b1
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Extend LAP optimisations to more operations
    
    Extend the set of eligible opcodes for certain peephole
    transformations, which then provide further optimisation
    opportunities.
    
    * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode):
    Optimise empty save-current-buffer in the same way as we already
    do for save-excursion and save-restriction.  This is safe
    because (save-current-buffer) is a no-op.
    (byte-compile-side-effect-and-error-free-ops): Add list3, list4 and
    listN.  These were all apparent oversights as list1 and list2 were
    already included.
    (byte-after-unbind-ops): Add stack-ref, stack-set, discard, list3,
    list4 and listN.  Stack manipulation is safe because unbind cannot
    read or modify stack entries.
---
 lisp/emacs-lisp/byte-opt.el | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 7a4bbf2e8a..a7edecfac7 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -1747,10 +1747,10 @@ See Info node `(elisp) Integer Basics'."
     byte-goto-if-not-nil-else-pop))
 
 (defconst byte-after-unbind-ops
-   '(byte-constant byte-dup
+   '(byte-constant byte-dup byte-stack-ref byte-stack-set byte-discard
      byte-symbolp byte-consp byte-stringp byte-listp byte-numberp byte-integerp
      byte-eq byte-not
-     byte-cons byte-list1 byte-list2   ; byte-list3 byte-list4
+     byte-cons byte-list1 byte-list2 byte-list3 byte-list4 byte-listN
      byte-interactive-p)
    ;; How about other side-effect-free-ops?  Is it safe to move an
    ;; error invocation (such as from nth) out of an unwind-protect?
@@ -1762,7 +1762,8 @@ See Info node `(elisp) Integer Basics'."
 (defconst byte-compile-side-effect-and-error-free-ops
   '(byte-constant byte-dup byte-symbolp byte-consp byte-stringp byte-listp
     byte-integerp byte-numberp byte-eq byte-equal byte-not byte-car-safe
-    byte-cdr-safe byte-cons byte-list1 byte-list2 byte-point byte-point-max
+    byte-cdr-safe byte-cons byte-list1 byte-list2 byte-list3 byte-list4
+    byte-listN byte-point byte-point-max
     byte-point-min byte-following-char byte-preceding-char
     byte-current-column byte-eolp byte-eobp byte-bolp byte-bobp
     byte-current-buffer byte-stack-ref))
@@ -2113,13 +2114,15 @@ If FOR-EFFECT is non-nil, the return value is assumed 
to be of no importance."
          (setcar (cdr rest) lap0)
          (setq keep-going t))
         ;;
-        ;; varbind-X unbind-N         -->  discard unbind-(N-1)
-        ;; save-excursion unbind-N    -->  unbind-(N-1)
-        ;; save-restriction unbind-N  -->  unbind-(N-1)
+        ;; varbind-X unbind-N            -->  discard unbind-(N-1)
+        ;; save-excursion unbind-N       -->  unbind-(N-1)
+        ;; save-restriction unbind-N     -->  unbind-(N-1)
+        ;; save-current-buffer unbind-N  -->  unbind-(N-1)
         ;;
         ((and (eq 'byte-unbind (car lap1))
               (memq (car lap0) '(byte-varbind byte-save-excursion
-                                 byte-save-restriction))
+                                 byte-save-restriction
+                                  byte-save-current-buffer))
               (< 0 (cdr lap1)))
          (if (zerop (setcdr lap1 (1- (cdr lap1))))
              (delq lap1 rest))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]