From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Mark Oteiza Newsgroups: gmane.emacs.bugs Subject: bug#39709: 28.0.50; [PATCH] substring and the byte compiler Date: Fri, 21 Feb 2020 01:22:06 -0500 Message-ID: <87zhdcmpdd.fsf@udel.edu> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="42412"; mail-complaints-to="usenet@ciao.gmane.io" To: 39709@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 21 07:23:13 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j51iT-000Aug-IC for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Feb 2020 07:23:13 +0100 Original-Received: from localhost ([::1]:52702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j51iS-0004X4-HR for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Feb 2020 01:23:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36935) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j51iJ-0004Wv-Qo for bug-gnu-emacs@gnu.org; Fri, 21 Feb 2020 01:23:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j51iI-00035f-Nz for bug-gnu-emacs@gnu.org; Fri, 21 Feb 2020 01:23:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40303) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j51iI-00034Q-Hy for bug-gnu-emacs@gnu.org; Fri, 21 Feb 2020 01:23:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j51iI-0008Ij-Di for bug-gnu-emacs@gnu.org; Fri, 21 Feb 2020 01:23:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mark Oteiza Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Feb 2020 06:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 39709 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.158226613531830 (code B ref -1); Fri, 21 Feb 2020 06:23:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Feb 2020 06:22:15 +0000 Original-Received: from localhost ([127.0.0.1]:46276 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j51hW-0008HK-UV for submit@debbugs.gnu.org; Fri, 21 Feb 2020 01:22:15 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:48952) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j51hU-0008HB-EN for submit@debbugs.gnu.org; Fri, 21 Feb 2020 01:22:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33611) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j51hS-0004Sg-Vy for bug-gnu-emacs@gnu.org; Fri, 21 Feb 2020 01:22:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j51hR-0006yU-F7 for bug-gnu-emacs@gnu.org; Fri, 21 Feb 2020 01:22:10 -0500 Original-Received: from mail-qv1-xf2f.google.com ([2607:f8b0:4864:20::f2f]:42883) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j51hR-0006oT-22 for bug-gnu-emacs@gnu.org; Fri, 21 Feb 2020 01:22:09 -0500 Original-Received: by mail-qv1-xf2f.google.com with SMTP id dc14so548167qvb.9 for ; Thu, 20 Feb 2020 22:22:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=udel-edu.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version; bh=upQU0pEWO2I0Y4Bnyzqip36hjjbYtgNlB5QXBF7Fzio=; b=J7zoPh1m7pvKi2GpttGZqsjgpWQnaMh/pXq8zZWlSigSwcgr1MVjyWNNMeJXfUO6/B 9JJpEA8EpbYLKDuwAAXfRHb3X5TE7hHGo1wlN73S+BtjrdFUAwAbq8g10oUA3vclrDB1 ncj/89GJbhDVv22nfreZh4K8XYT1kKpffqyoyF5zm3s+ciwbUiWlELzBFdf3mIlSw318 wBWcqfmbgW11hur2hnynmFu5pPP8ogX+x1ilAxskvoeqX8+zd2RPC9FLcGkRBmiw2zMa J48YOCVL5sAKSceJQbH6GTQVEC2naW4uqQLSy+CqrI0gX1eyOEvjz4fYnPQueSFc4Z+V ukcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=upQU0pEWO2I0Y4Bnyzqip36hjjbYtgNlB5QXBF7Fzio=; b=SjiGH+TOIkd0Q6kil/T/bWGX1XvqyzJp0XthLAiOx34vF4eh2whBu1J8lsy+7BgGY/ jd4ftluZ+fo6evvvC+rN17M6Ach66kMuV4D8ZPg4kB6HflwgNFAxHMlizJRzM8UZPTR+ hD7kiQyp4xyZqBpYBcabAinOKntrdXdtHMtvSwFTzNvexLUVUqbBRvobc60NVw0kQ8L3 vIrojIVeQUzAxPt6H2z/ctEqACPwpg8u62jy5SQRQ+ita0yw8P3dMhjEslkR4es4+3Qs qUqvqAtY2mqtU+FC1S+dXl66Mss16DVhEdSCBdY8Nr2VPF+ZWY8V9xHi7ysGGq1CAZjy xcLA== X-Gm-Message-State: APjAAAVpnm8uX59qoJLYn7rNUsrrFn2gOkiSo8IvmH6QKqRNavEKYfHY 8kt3GnSeQNdMvBaiikExvYbfUE0IuXM= X-Google-Smtp-Source: APXvYqxMsQimrN+5vlHkFNX2tZVMS0wjm4DDCu/AMEmjYiat3PwJ5SXxJJVDP9pqmckb9xH8lkTdWg== X-Received: by 2002:a0c:ab8f:: with SMTP id j15mr28882275qvb.223.1582266127639; Thu, 20 Feb 2020 22:22:07 -0800 (PST) Original-Received: from holos.localdomain (c-69-251-56-176.hsd1.md.comcast.net. [69.251.56.176]) by smtp.gmail.com with ESMTPSA id x41sm1064677qtj.52.2020.02.20.22.22.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2020 22:22:07 -0800 (PST) Original-Received: by holos.localdomain (Postfix, from userid 1000) id 8B4C266BE0; Fri, 21 Feb 2020 01:22:06 -0500 (EST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:176342 Archived-At: 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.