; byte(-opt, comp).el: Add more documentation for byte-switch code.

This commit is contained in:
Vibhav Pant 2017-02-06 13:26:25 +05:30
parent ad70ca1dad
commit a12b416bca
2 changed files with 22 additions and 0 deletions

View 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)