GNU bug report logs -
#39709
28.0.50; [PATCH] substring and the byte compiler
Previous Next
Reported by: Mark Oteiza <mvoteiza <at> udel.edu>
Date: Fri, 21 Feb 2020 06:23:02 UTC
Severity: normal
Tags: patch
Found in version 28.0.50
Done: Mattias Engdegård <mattiase <at> acm.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 39709 in the body.
You can then email your comments to 39709 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39709
; Package
emacs
.
(Fri, 21 Feb 2020 06:23:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Mark Oteiza <mvoteiza <at> udel.edu>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 21 Feb 2020 06:23:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi,
I don't really understand the byte compiler, but I noticed in
disassembly that substring, despite having an opcode, is getting
call'd:
10 constant substring
11 stack-ref 3
12 constant 0
13 stack-ref 7
15 call 3
when really I'd expect to see something like
57 stack-ref 2
58 stack-ref 7
60 min
61 stack-ref 7
63 substring
The only relevant change I found is bug#33807. Enlightenment welcome.
Naive patch below.
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index fce5e4aed6..ec340cd451 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -3506,6 +3506,7 @@ byte-defop-compiler
(0-1 . byte-compile-zero-or-one-arg)
(1-2 . byte-compile-one-or-two-args)
(2-3 . byte-compile-two-or-three-args)
+ (1-3 . byte-compile-one-to-three-args)
)))
compile-handler
(intern (concat "byte-compile-"
@@ -3690,6 +3691,13 @@ byte-compile-two-or-three-args
((= len 4) (byte-compile-three-args form))
(t (byte-compile-subr-wrong-args form "2-3")))))
+(defun byte-compile-one-to-three-args (form)
+ (let ((len (length form)))
+ (cond ((= len 2) (byte-compile-one-arg form))
+ ((= len 3) (byte-compile-two-args form))
+ ((= len 4) (byte-compile-three-args form))
+ (t (byte-compile-subr-wrong-args form "1-3")))))
+
(defun byte-compile-noop (_form)
(byte-compile-constant nil))
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index fe0930c684..d3c84335ec 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -1511,11 +1511,11 @@ byte-compile-side-effect-and-error-free-ops
(defconst byte-compile-side-effect-free-ops
(nconc
'(byte-varref byte-nth byte-memq byte-car byte-cdr byte-length byte-aref
- byte-symbol-value byte-get byte-concat2 byte-concat3 byte-sub1 byte-add1
- byte-eqlsign byte-gtr byte-lss byte-leq byte-geq byte-diff byte-negate
- byte-plus byte-max byte-min byte-mult byte-char-after byte-char-syntax
- byte-buffer-substring byte-string= byte-string< byte-nthcdr byte-elt
- byte-member byte-assq byte-quo byte-rem)
+ byte-symbol-value byte-get byte-substring byte-concat2 byte-concat3
+ byte-sub1 byte-add1 byte-eqlsign byte-gtr byte-lss byte-leq byte-geq
+ byte-diff byte-negate byte-plus byte-max byte-min byte-mult byte-char-after
+ byte-char-syntax byte-buffer-substring byte-string= byte-string<
+ byte-nthcdr byte-elt byte-member byte-assq byte-quo byte-rem)
byte-compile-side-effect-and-error-free-ops))
;; This crock is because of the way DEFVAR_BOOL variables work.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39709
; Package
emacs
.
(Fri, 21 Feb 2020 11:49:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 39709 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
The missing 1-3 case seems to be a simple omission -- thanks for spotting it.
+(defun byte-compile-one-to-three-args (form)
+ (let ((len (length form)))
+ (cond ((= len 2) (byte-compile-one-arg form))
+ ((= len 3) (byte-compile-two-args form))
+ ((= len 4) (byte-compile-three-args form))
+ (t (byte-compile-subr-wrong-args form "1-3")))))
Not sure how this would work. Don't you need to add the missing arguments?
Cleaned-up patch attached.
(Unless, of course, there is evidence that the byte op has never been emitted --- then we have an opportunity to drop it instead.)
[0001-Generate-substring-byte-op-bug-39709.patch (application/octet-stream, attachment)]
Reply sent
to
Mattias Engdegård <mattiase <at> acm.org>
:
You have taken responsibility.
(Tue, 25 Feb 2020 15:43:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Mark Oteiza <mvoteiza <at> udel.edu>
:
bug acknowledged by developer.
(Tue, 25 Feb 2020 15:43:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 39709-done <at> debbugs.gnu.org (full text, mbox):
No objection arrived -- pushed to master.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 25 Mar 2020 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 5 years and 124 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.