aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias EngdegÄrd2020-02-21 12:16:20 +0100
committerMattias EngdegÄrd2020-02-25 16:40:11 +0100
commit03c07c88d90b5747456b9d286bace2dd4a713aac (patch)
treebc5df98ed38273b010731c2c380b69758b237b56
parent64af3c94a6197cd0c6a283880c900eeb5bf12961 (diff)
downloademacs-03c07c88d90b5747456b9d286bace2dd4a713aac.tar.gz
emacs-03c07c88d90b5747456b9d286bace2dd4a713aac.zip
Generate 'substring' byte op (bug#39709)
The 'substring' byte op was not emitted, apparently by mistake. Fix. Suggested by Mark Oteiza <mvoteiza@udel.edu>. * lisp/emacs-lisp/bytecomp.el (byte-defop-compiler): Add '1-3' clause. (byte-compile-one-to-three-args): New. * lisp/emacs-lisp/byte-opt.el (byte-compile-side-effect-free-ops): Add 'byte-substring'. * test/lisp/emacs-lisp/bytecomp-tests.el (byte-opt-testsuite-arith-data): Test 'substring'.
-rw-r--r--lisp/emacs-lisp/byte-opt.el2
-rw-r--r--lisp/emacs-lisp/bytecomp.el10
-rw-r--r--test/lisp/emacs-lisp/bytecomp-tests.el7
3 files changed, 16 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index fe0930c684b..4f72251aed5 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -1515,7 +1515,7 @@
1515 byte-eqlsign byte-gtr byte-lss byte-leq byte-geq byte-diff byte-negate 1515 byte-eqlsign byte-gtr byte-lss byte-leq byte-geq byte-diff byte-negate
1516 byte-plus byte-max byte-min byte-mult byte-char-after byte-char-syntax 1516 byte-plus byte-max byte-min byte-mult byte-char-after byte-char-syntax
1517 byte-buffer-substring byte-string= byte-string< byte-nthcdr byte-elt 1517 byte-buffer-substring byte-string= byte-string< byte-nthcdr byte-elt
1518 byte-member byte-assq byte-quo byte-rem) 1518 byte-member byte-assq byte-quo byte-rem byte-substring)
1519 byte-compile-side-effect-and-error-free-ops)) 1519 byte-compile-side-effect-and-error-free-ops))
1520 1520
1521;; This crock is because of the way DEFVAR_BOOL variables work. 1521;; This crock is because of the way DEFVAR_BOOL variables work.
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 24a36393b2e..63348456a15 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -3487,7 +3487,7 @@ the opcode to be used. If function is a list, the first element
3487is the function and the second element is the bytecode-symbol. 3487is the function and the second element is the bytecode-symbol.
3488The second element may be nil, meaning there is no opcode. 3488The second element may be nil, meaning there is no opcode.
3489COMPILE-HANDLER is the function to use to compile this byte-op, or 3489COMPILE-HANDLER is the function to use to compile this byte-op, or
3490may be the abbreviations 0, 1, 2, 3, 0-1, or 1-2. 3490may be the abbreviations 0, 1, 2, 2-and, 3, 0-1, 1-2, 1-3, or 2-3.
3491If it is nil, then the handler is \"byte-compile-SYMBOL.\"" 3491If it is nil, then the handler is \"byte-compile-SYMBOL.\""
3492 (let (opcode) 3492 (let (opcode)
3493 (if (symbolp function) 3493 (if (symbolp function)
@@ -3506,6 +3506,7 @@ If it is nil, then the handler is \"byte-compile-SYMBOL.\""
3506 (0-1 . byte-compile-zero-or-one-arg) 3506 (0-1 . byte-compile-zero-or-one-arg)
3507 (1-2 . byte-compile-one-or-two-args) 3507 (1-2 . byte-compile-one-or-two-args)
3508 (2-3 . byte-compile-two-or-three-args) 3508 (2-3 . byte-compile-two-or-three-args)
3509 (1-3 . byte-compile-one-to-three-args)
3509 ))) 3510 )))
3510 compile-handler 3511 compile-handler
3511 (intern (concat "byte-compile-" 3512 (intern (concat "byte-compile-"
@@ -3690,6 +3691,13 @@ These implicitly `and' together a bunch of two-arg bytecodes."
3690 ((= len 4) (byte-compile-three-args form)) 3691 ((= len 4) (byte-compile-three-args form))
3691 (t (byte-compile-subr-wrong-args form "2-3"))))) 3692 (t (byte-compile-subr-wrong-args form "2-3")))))
3692 3693
3694(defun byte-compile-one-to-three-args (form)
3695 (let ((len (length form)))
3696 (cond ((= len 2) (byte-compile-three-args (append form '(nil nil))))
3697 ((= len 3) (byte-compile-three-args (append form '(nil))))
3698 ((= len 4) (byte-compile-three-args form))
3699 (t (byte-compile-subr-wrong-args form "1-3")))))
3700
3693(defun byte-compile-noop (_form) 3701(defun byte-compile-noop (_form)
3694 (byte-compile-constant nil)) 3702 (byte-compile-constant nil))
3695 3703
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el
index de11ae22d50..d4ceb47c36e 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -347,7 +347,12 @@
347 ((eq x 't) 99) 347 ((eq x 't) 99)
348 (t 999)))) 348 (t 999))))
349 '((a c) (b c) (7 c) (-3 c) (nil nil) (t c) (q c) (r c) (s c) 349 '((a c) (b c) (7 c) (-3 c) (nil nil) (t c) (q c) (r c) (s c)
350 (t c) (x "a") (x "c") (x c) (x d) (x e)))) 350 (t c) (x "a") (x "c") (x c) (x d) (x e)))
351
352 ;; `substring' bytecode generation (bug#39709).
353 (substring "abcdef")
354 (substring "abcdef" 2)
355 (substring "abcdef" 3 2))
351 "List of expression for test. 356 "List of expression for test.
352Each element will be executed by interpreter and with 357Each element will be executed by interpreter and with
353bytecompiled code, and their results compared.") 358bytecompiled code, and their results compared.")