From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Giraud Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Findirect_function Date: Mon, 17 Jan 2022 14:32:31 +0100 Message-ID: <87tue2jxn4.fsf@elite.giraud> References: <87tue61tz1.fsf@elite.giraud> <87r19a9sbk.fsf@elite.giraud> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3475"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (berkeley-unix) Cc: emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jan 17 16:08:45 2022 Return-path: Envelope-to: ged-emacs-devel@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 1n9Tcj-0000fx-He for ged-emacs-devel@m.gmane-mx.org; Mon, 17 Jan 2022 16:08:45 +0100 Original-Received: from localhost ([::1]:57660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9Tci-0008UG-5Z for ged-emacs-devel@m.gmane-mx.org; Mon, 17 Jan 2022 10:08:44 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:39812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9S87-0001zx-FI for emacs-devel@gnu.org; Mon, 17 Jan 2022 08:33:03 -0500 Original-Received: from ledu-giraud.fr ([51.159.28.247]:27370) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9S7z-0001Mc-7c for emacs-devel@gnu.org; Mon, 17 Jan 2022 08:33:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=1HXVZIRM+Xhy70JO zjxH1DeHQ65bTOJEqCPH2mzjDeU=; h=in-reply-to:date:references:subject: cc:to:from; d=ledu-giraud.fr; b=T28/cLOmkj0ldwSos8kVJ37+EufEIrFOrlBSAQ NlG3URkpJ42yDVKhr82YRQO+posV/6wBf32Arnqz6qd1GcwCwpZQhuXMX6vhbTBpTrFRm/ WRIVZGN5L2PoEsGWni18OeF9uWCfT8tmhAztsYk0XjnN8Hxu+YORULIp+X76xoP9NCoDf4 QxvV64wVhH65r48s6KE4Yz/1Nz277THi2rfYcMN9gqW39E4KMku2bOeNRLag2m8n+rC9KS cJDBLKsRDX7DbU7vKuQSc057FSZJ/Tiq9Oeo6RDD0xnirGF6a3R0NmnSPtTJsBS9DwDHNo qmKDterhFqO3gZIftANQVnvw== Original-Received: from elite.giraud ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id 8e9b05ed (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Mon, 17 Jan 2022 14:32:32 +0100 (CET) In-Reply-To: (Stefan Monnier's message of "Fri, 14 Jan 2022 12:39:55 -0500") Received-SPF: pass client-ip=51.159.28.247; envelope-from=manuel@ledu-giraud.fr; helo=ledu-giraud.fr X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:284881 Archived-At: --=-=-= Content-Type: text/plain Hi, So here are the results of `elisp-benchmarks-run' on one "emacs -Q" master and one patched with the attached patch: master: * Results | test | non-gc avg (s) | gc avg (s) | gcs avg | tot avg (s) | tot avg err (s) | |--------------------+----------------+------------+---------+-------------+-----------------| | inclist | 28.16 | 0.00 | 0 | 28.16 | 0.80 | | fibn-rec | 12.89 | 0.00 | 0 | 12.89 | 1.05 | | listlen-tc | 12.68 | 0.00 | 0 | 12.68 | 0.47 | | pack-unpack | 0.28 | 0.21 | 5 | 0.49 | 0.03 | | pidigits | 32.88 | 45.67 | 211 | 78.55 | 0.67 | | map-closure | 16.46 | 0.00 | 0 | 16.46 | 0.74 | | nbody | 5.05 | 17.50 | 416 | 22.56 | 0.94 | | dhrystone | 14.55 | 0.00 | 0 | 14.55 | 2.48 | | pack-unpack-old | 0.75 | 0.47 | 11 | 1.22 | 0.16 | | bubble | 8.54 | 9.90 | 234 | 18.44 | 1.61 | | inclist-type-hints | 28.42 | 0.00 | 0 | 28.42 | 0.55 | | bubble-no-cons | 20.45 | 0.05 | 1 | 20.50 | 1.34 | | fibn | 20.79 | 0.00 | 0 | 20.79 | 1.38 | | fibn-tc | 11.13 | 0.00 | 0 | 11.13 | 0.41 | | pcase | 21.63 | 0.00 | 0 | 21.63 | 0.25 | | flet | 20.92 | 0.00 | 0 | 20.92 | 0.11 | |--------------------+----------------+------------+---------+-------------+-----------------| | total | 255.58 | 73.80 | 878 | 329.38 | 4.10 | patched: * Results | test | non-gc avg (s) | gc avg (s) | gcs avg | tot avg (s) | tot avg err (s) | |--------------------+----------------+------------+---------+-------------+-----------------| | inclist | 27.89 | 0.00 | 0 | 27.89 | 0.20 | | fibn-rec | 11.29 | 0.00 | 0 | 11.29 | 0.20 | | listlen-tc | 12.71 | 0.00 | 0 | 12.71 | 0.98 | | pack-unpack | 0.26 | 0.25 | 10 | 0.51 | 0.04 | | pidigits | 32.27 | 45.05 | 382 | 77.32 | 1.37 | | map-closure | 16.71 | 0.00 | 0 | 16.71 | 1.15 | | nbody | 4.82 | 19.54 | 752 | 24.37 | 1.46 | | dhrystone | 13.38 | 0.00 | 0 | 13.38 | 0.60 | | pack-unpack-old | 0.72 | 0.51 | 20 | 1.23 | 0.08 | | bubble | 8.12 | 10.19 | 400 | 18.30 | 0.92 | | inclist-type-hints | 28.40 | 0.00 | 0 | 28.40 | 0.69 | | bubble-no-cons | 20.75 | 0.08 | 3 | 20.83 | 2.06 | | fibn | 20.04 | 0.00 | 0 | 20.04 | 1.90 | | fibn-tc | 11.02 | 0.00 | 0 | 11.02 | 1.03 | | pcase | 22.31 | 0.00 | 0 | 22.31 | 2.14 | | flet | 21.81 | 0.00 | 0 | 21.81 | 2.18 | |--------------------+----------------+------------+---------+-------------+-----------------| | total | 252.51 | 75.61 | 1568 | 328.13 | 5.13 | It seems that we are in the same ballpark. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Remove-unused-argument-to-Findirect_function.patch >From c0a250642dc998c35e8a3d471198fb13ff5bb54f Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Mon, 17 Jan 2022 11:16:09 +0100 Subject: [PATCH] Remove unused argument to Findirect_function. Use Findirect_function more where possible. --- src/callint.c | 2 +- src/data.c | 8 +++----- src/doc.c | 2 +- src/eval.c | 36 ++++++++++-------------------------- src/keymap.c | 2 +- 5 files changed, 16 insertions(+), 34 deletions(-) diff --git a/src/callint.c b/src/callint.c index ce77c893f4..f046d53e95 100644 --- a/src/callint.c +++ b/src/callint.c @@ -327,7 +327,7 @@ DEFUN ("call-interactively", Fcall_interactively, Scall_interactively, 1, 3, 0, /* If SPECS is not a string, invent one. */ if (! STRINGP (specs)) { - Lisp_Object funval = Findirect_function (function, Qt); + Lisp_Object funval = Findirect_function (function); uintmax_t events = num_input_events; Lisp_Object input = specs; /* Compute the arg values using the user's expression. */ diff --git a/src/data.c b/src/data.c index f287c38fcd..173f0fb54f 100644 --- a/src/data.c +++ b/src/data.c @@ -2365,13 +2365,13 @@ indirect_function (register Lisp_Object object) return hare; } -DEFUN ("indirect-function", Findirect_function, Sindirect_function, 1, 2, 0, +DEFUN ("indirect-function", Findirect_function, Sindirect_function, 1, 1, 0, doc: /* Return the function at the end of OBJECT's function chain. If OBJECT is not a symbol, just return it. Otherwise, follow all function indirections to find the final function binding and return it. Signal a cyclic-function-indirection error if there is a loop in the function chain of symbols. */) - (register Lisp_Object object, Lisp_Object noerror) + (register Lisp_Object object) { Lisp_Object result; @@ -2380,10 +2380,8 @@ DEFUN ("indirect-function", Findirect_function, Sindirect_function, 1, 2, 0, if (SYMBOLP (result) && !NILP (result) && (result = XSYMBOL (result)->u.s.function, SYMBOLP (result))) result = indirect_function (result); - if (!NILP (result)) - return result; - return Qnil; + return result; } /* Extract and set vector and string elements. */ diff --git a/src/doc.c b/src/doc.c index 0b12eb154d..3c8bb19eb6 100644 --- a/src/doc.c +++ b/src/doc.c @@ -325,7 +325,7 @@ DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0, raw); } - Lisp_Object fun = Findirect_function (function, Qnil); + Lisp_Object fun = Findirect_function (function); if (NILP (fun)) xsignal1 (Qvoid_function, function); if (CONSP (fun) && EQ (XCAR (fun), Qmacro)) diff --git a/src/eval.c b/src/eval.c index 5514583b6a..a8c69f43ee 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2344,7 +2344,7 @@ DEFUN ("autoload-do-load", Fautoload_do_load, Sautoload_do_load, 1, 3, 0, return Qnil; else { - Lisp_Object fun = Findirect_function (funname, Qnil); + Lisp_Object fun = Findirect_function(funname); if (!NILP (Fequal (fun, fundef))) error ("Autoloading file %s failed to define function %s", @@ -2667,15 +2667,10 @@ DEFUN ("apply", Fapply, Sapply, 1, MANY, 0, numargs += nargs - 2; - /* Optimize for no indirection. */ - if (SYMBOLP (fun) && !NILP (fun) - && (fun = XSYMBOL (fun)->u.s.function, SYMBOLP (fun))) - { - fun = indirect_function (fun); - if (NILP (fun)) - /* Let funcall get the error. */ - fun = args[0]; - } + fun = Findirect_function(fun); + if (NILP (fun)) + /* Let funcall get the error. */ + fun = args[0]; if (SUBRP (fun) && XSUBR (fun)->max_args > numargs /* Don't hide an error by adding missing arguments. */ @@ -3008,7 +3003,7 @@ FUNCTIONP (Lisp_Object object) { if (SYMBOLP (object) && !NILP (Ffboundp (object))) { - object = Findirect_function (object, Qt); + object = Findirect_function(object); if (CONSP (object) && EQ (XCAR (object), Qautoload)) { @@ -3068,11 +3063,7 @@ DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0, retry: - /* Optimize for no indirection. */ - fun = original_fun; - if (SYMBOLP (fun) && !NILP (fun) - && (fun = XSYMBOL (fun)->u.s.function, SYMBOLP (fun))) - fun = indirect_function (fun); + fun = Findirect_function(original_fun); if (SUBRP (fun) && !SUBR_NATIVE_COMPILED_DYNP (fun)) val = funcall_subr (XSUBR (fun), numargs, args + 1); @@ -3387,14 +3378,7 @@ DEFUN ("func-arity", Ffunc_arity, Sfunc_arity, 1, 1, 0, retry: - /* Optimize for no indirection. */ - function = original; - if (SYMBOLP (function) && !NILP (function)) - { - function = XSYMBOL (function)->u.s.function; - if (SYMBOLP (function)) - function = indirect_function (function); - } + function = Findirect_function(original); if (CONSP (function) && EQ (XCAR (function), Qmacro)) function = XCDR (function); @@ -3936,9 +3920,9 @@ get_backtrace_starting_at (Lisp_Object base) if (!NILP (base)) { /* Skip up to `base'. */ - base = Findirect_function (base, Qt); + base = Findirect_function(base); while (backtrace_p (pdl) - && !EQ (base, Findirect_function (backtrace_function (pdl), Qt))) + && !EQ (base, Findirect_function(backtrace_function (pdl)))) pdl = backtrace_next (pdl); } diff --git a/src/keymap.c b/src/keymap.c index ed69b1c427..7be0e3c155 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -1614,7 +1614,7 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr) } /* Get the keymap definition--or nil if it is not defined. */ - temp = Findirect_function (XCDR (assoc), Qt); + temp = Findirect_function(XCDR (assoc)); if (!NILP (temp)) { cmm_modes[i] = var; -- 2.34.1 --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=--