]> git.eshelyaron.com Git - emacs.git/commitdiff
; byte(-opt, comp).el: Add more documentation for byte-switch code.
authorVibhav Pant <vibhavp@gmail.com>
Mon, 6 Feb 2017 07:56:25 +0000 (13:26 +0530)
committerVibhav Pant <vibhavp@gmail.com>
Mon, 6 Feb 2017 07:56:25 +0000 (13:26 +0530)
lisp/emacs-lisp/byte-opt.el
lisp/emacs-lisp/bytecomp.el

index 146fbcc1cb615d054b93ba4f9790bb61936b342c..888a5f85007d3f78cfe671808645de8306e84390 100644 (file)
@@ -1773,6 +1773,9 @@ If FOR-EFFECT is non-nil, the return value is assumed to be of no importance."
               ;;
              ((and (memq (car lap0) '(byte-goto byte-return))
                    (not (memq (car lap1) '(TAG nil)))
+                    ;; FIXME: Instead of deferring simply when jump-tables are
+                    ;; being used, keep a list of tags used for switch tags and
+                    ;; use them instead (see `byte-compile-inline-lapcode').
                     (not byte-compile-jump-tables))
               (setq tmp rest)
               (let ((i 0)
index 5aef82691c6c17a47df92e491bb10c5b9b9b2bb1..c70e1bf5ed84bf86a253b1199ed982f234cb146d 100644 (file)
@@ -3133,6 +3133,9 @@ for symbols generated by the byte compiler itself."
   ;; happens to be true for byte-code generated by bytecomp.el without
   ;; lexical-binding, but it's not true in general, and it's not true for
   ;; code output by bytecomp.el with lexical-binding.
+  ;; We also restore the value of `byte-compile-depth' and remove TAG depths
+  ;; accordingly when inlining byte-switch lap code, as documented in
+  ;; `byte-compile-cond-jump-table'.
   (let ((endtag (byte-compile-make-tag))
         last-jump-tag ;; last TAG we have jumped to
         last-depth ;; last value of `byte-compile-depth'
@@ -4061,6 +4064,22 @@ Return a list of the form ((TEST . VAR)  ((VALUE BODY) ...))"
                                                 (length cases)))
             default-tag (byte-compile-make-tag)
             donetag (byte-compile-make-tag))
+      ;; The structure of byte-switch code:
+      ;;
+      ;; varref var
+      ;; constant #s(hash-table purecopy t data (val1 (TAG1) val2 (TAG2)))
+      ;; switch
+      ;; goto DEFAUT-TAG
+      ;; TAG1
+      ;; <clause body>
+      ;; goto DONETAG
+      ;; TAG2
+      ;; <clause body>
+      ;; goto DONETAG
+      ;; DEFAULT-TAG
+      ;; <body for `t' clause, if any (else `constant nil')>
+      ;; DONETAG
+
       (byte-compile-variable-ref var)
       (byte-compile-push-constant jump-table)
       (byte-compile-out 'byte-switch)