From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: tomas@tuxteam.de Newsgroups: gmane.emacs.help Subject: Re: Knowing where a function has been used (bis) [Was: Re: Optimising Elisp code] Date: Sat, 6 Oct 2018 22:27:40 +0200 Message-ID: <20181006202740.GC7368@tuxteam.de> References: <638fb7dc-6fc5-4645-8793-97a00038a3a8@googlegroups.com> <8hxojvzzzzzz.m4h.xxuns.g6.gal@portable.galex-713.eu> <20181006192457.GB7368@tuxteam.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="VywGB/WGlW4DM4P8" X-Trace: blaine.gmane.org 1538857580 27451 195.159.176.226 (6 Oct 2018 20:26:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 6 Oct 2018 20:26:20 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) Cc: help-gnu-emacs@gnu.org, Stefan Monnier To: "Garreau, Alexandre" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Oct 06 22:26:15 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g8t9Q-0006zi-OE for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Oct 2018 22:26:12 +0200 Original-Received: from localhost ([::1]:40304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8tBX-0005LC-Eq for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Oct 2018 16:28:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8tB2-0005J5-4g for help-gnu-emacs@gnu.org; Sat, 06 Oct 2018 16:27:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8tAx-0007lB-Qo for help-gnu-emacs@gnu.org; Sat, 06 Oct 2018 16:27:52 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]:54777) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8tAx-0007kX-Gd for help-gnu-emacs@gnu.org; Sat, 06 Oct 2018 16:27:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=5WcQzyo4l+FLaIulA/EZmdiOGc8g6SoUOWBMzSSMUsU=; b=KVSaaYZfToEPSY4er9FoMndVP0rZjqDszohHe5wc6+p4u7aBbUZrJs13NfqM1ADs/JXWSCO/vQbhT2cEcpp6jTN5Tz9Qh78zwNQAk94ZVDoBrKDDDrd3VcOMg9yse3ev/gwzZQ4BdLu0iDse0BSZ10M+gzHVf+dYCEKF0C1c3NilIOfH3eTdn89BVim/lbfa8MsZL9mB2OO73oyhGReJncB87uY9vxj7C+yOyO9LSOeDfpOolAT/YMJAjhPI5xWjQPnGgvX4X2FoJP3K/rhNnmIEG1EfZekyiBPms6NcZBuy4k7PNguRf7XoG+Wnl+cdQAE9FofWf64v4o3t0rMW8w==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1g8tAq-0002kU-Lv; Sat, 06 Oct 2018 22:27:40 +0200 Content-Disposition: inline In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 5.199.139.25 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:118168 Archived-At: --VywGB/WGlW4DM4P8 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Oct 06, 2018 at 09:55:09PM +0200, Garreau, Alexandre wrote: > Le 06/10/2018 =C3=A0 21h24, tomas@tuxteam.de a =C3=A9crit=C2=A0: > > On Sat, Oct 06, 2018 at 06:55:54PM +0200, Garreau, Alexandre wrote: > >> Or would =E2=80=9Creevaluate every function that where defined with the > >> (now-redefined) inlined function inside=E2=80=9D work too? > > > > Hmm. Not reevaluate, but recompile, and not "inside", but rather > > "outside" -- like finding all places where this function was > > inlined=20 >=20 > I don=E2=80=99t get how =E2=80=9Coutside=E2=80=9D is the correct form her= e, as this is precisely > what I was meaning: I mentioned it in my other message titled =E2=80=9CKn= owing > where a function has been used (e.g. for optimizing)=E2=80=9D (message-id= : [0], > url: [1]), as I found a such functionality, symetrical to > find-definition, would be quite generally useful for lot of stuff. Then I didn't get you right: I gather we both mean the "context" where the function was "inlined into". If you're lucky, no optimization has happened *after" you've inlined. Otherwise, you'll have to recompile the whole context (i.e. parts of the caller). > > and do some magic there. >=20 > What other kind of magic than (maybe recursively) > reevaluating/recompiling could be needed there? In the case of a redefinition of the inlined function you'll have to find all call sites and do something. >=20 > > Perhaps doable, but not trivial. >=20 > I have really no precise idea of where and how is stored the place where > each function was defined Which functions you mean by "each function"? You mean the sites at which the inlined function is "called" (i.e. inlined), I guess. Well, I haven't a precise idea either, but for a pretty lucid description (in the context of Guile, but with pointers to other implementations), cf https://wingolog.org/archives/2018/02/07/design-notes-on-inline-caches-in= -guile > >> Why =E2=80=9Cundo=E2=80=9D? [...] [...] > So, except maybe wrt debugging (which there should imply reevaluation, you mean "recompile" > like with edebug-defun), reevaluating (or rather recompiling indeed, > since afaiu then, simple evaluation will never optimize anything, unlike > byte-compiling (right?)). Not only debugging, but any kind of redefinition. Emacs lisp is a dynamic language, and the users expect that when you redefine a function, the new definition is active; unless the magic is under user control (you've said "defmacro" or "def-inline", then you know you've to recompile the callers), the run system has to manage the mess, i.e. it has to remember all the sites where things have to be inlined, like in the "inline cache" from the reference above. Cheers -- t --VywGB/WGlW4DM4P8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlu5GrwACgkQBcgs9XrR2kax6ACdEEwbOQi2fjLxT/1AXD3Ri0Y6 jMsAnAkt68iAv6qECP+gZD9s7bbps5ma =jLCi -----END PGP SIGNATURE----- --VywGB/WGlW4DM4P8--