summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/bytecomp.el
diff options
context:
space:
mode:
authorVibhav Pant <vibhavp@gmail.com>2017-02-16 20:18:55 +0530
committerVibhav Pant <vibhavp@gmail.com>2017-02-16 20:30:04 +0530
commit501ad546263ed2a902be1c9d8c1bb3af5794066b (patch)
tree3f6d94eaf6703d59015e67344c6966d6e1247be4 /lisp/emacs-lisp/bytecomp.el
parent236648fe2623a10c8ca02637b79cd0ceffd0b6b9 (diff)
downloademacs-501ad546263ed2a902be1c9d8c1bb3af5794066b.tar.gz
bytecomp.el: Avoid unnecessary calculation for jump table addresses.
* lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode): Don't do redundant operations while calculating the correct jump addresses from TAGs in jump tables.
Diffstat (limited to 'lisp/emacs-lisp/bytecomp.el')
-rw-r--r--lisp/emacs-lisp/bytecomp.el9
1 files changed, 7 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 75e6b904aa6..e96ba0b6edd 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -911,16 +911,21 @@ CONST2 may be evaluated multiple times."
;; Patch tag PCs into absolute jumps.
(dolist (bytes-tail patchlist)
(setq pc (caar bytes-tail)) ; Pick PC from goto's tag.
+ ;; Splits PC's value into 2 bytes. The jump address is
+ ;; "reconstructued" by the `FETCH2' macro in `bytecode.c'.
(setcar (cdr bytes-tail) (logand pc 255))
(setcar bytes-tail (lsh pc -8))
;; FIXME: Replace this by some workaround.
(if (> (car bytes-tail) 255) (error "Bytecode overflow")))
+ ;; Similarly, replace TAGs in all jump tables with the correct PC index.
(dolist (hash-table byte-compile-jump-tables)
(maphash #'(lambda (value tag)
(setq pc (cadr tag))
- (puthash value (+ (logand pc 255) (lsh (lsh pc -8) 8))
- hash-table))
+ ;; We don't need to split PC here, as it is stored as a lisp
+ ;; object in the hash table (whereas other goto-* ops store
+ ;; it within 2 bytes in the byte string).
+ (puthash value pc hash-table))
hash-table))
(apply 'unibyte-string (nreverse bytes))))