From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Rocky Bernstein Newsgroups: gmane.emacs.devel Subject: Re: Correct line/column numbers in byte compiler messages [Was: GNU is looking for Google Summer of Code Projects] Date: Thu, 19 Mar 2020 16:56:45 -0400 Message-ID: References: <20200319203449.GA4180@ACM> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000c1a6a505a13b680d" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="65795"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , emacs-devel To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Mar 19 21:57:49 2020 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 1jF2Ee-000H0u-Q6 for ged-emacs-devel@m.gmane-mx.org; Thu, 19 Mar 2020 21:57:48 +0100 Original-Received: from localhost ([::1]:43182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jF2Ed-0002Pw-QJ for ged-emacs-devel@m.gmane-mx.org; Thu, 19 Mar 2020 16:57:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43442) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jF2Dr-0001DY-M2 for emacs-devel@gnu.org; Thu, 19 Mar 2020 16:57:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jF2Dp-0006u4-Ul for emacs-devel@gnu.org; Thu, 19 Mar 2020 16:56:59 -0400 Original-Received: from mail-lf1-f54.google.com ([209.85.167.54]:41393) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jF2Dp-0006td-Kj for emacs-devel@gnu.org; Thu, 19 Mar 2020 16:56:57 -0400 Original-Received: by mail-lf1-f54.google.com with SMTP id z22so2822862lfd.8 for ; Thu, 19 Mar 2020 13:56:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KX/4d0gfDe3G9d8K+A0GTFxcVuTo/R1DoJdNKDctRd4=; b=U4KKYTUPrTJbZoxkvVrZU8ws6frfHMF6cqdDJizHAXFbAuCbFSEpTebWBLOhhHZZUv 7AqGI5MKnETJW4qhR7vOUqjWt3zg1voNEqTCyBt0I+qXY/pThbdOxc4uDyaGiKYqM8TT LisvcAl0ECUxctnkBXMDIoWsMNUGAXVIgRp4F63q6t+XvpXMvClzmLcO5d7B0gYyJ7eh MVFrqDZLrNRi94tTtd56XrV2TwJ5u+ZrLsGJCGoIFmm3RiBMRTPFRGYYkA6k6lkLx2Wd mffEeJR2PUpqmdHInDTYurW0A+q0Uuxq04VSQPIpYY/TUkCx7w3o2jZ0AHcmMhKvpZte 4hWA== X-Gm-Message-State: ANhLgQ2nX7giHPDSqhgyd6AgmhhEfXaBSEzs5gVi0gO9Eo/QrKQAA1/8 c5jD1XjTLTMwzOQZt1AU7kErZ1ZKFCdWClw/2ak= X-Google-Smtp-Source: ADFU+vvCxRVbij55kRzueMiQQMvw8CPDbOn0jE9yGskpP5ScZ+iozgIQYbMjVLbE/CB5nRVoC9eRCFnkxoMJKSVU0l4= X-Received: by 2002:a19:8093:: with SMTP id b141mr3335756lfd.184.1584651416215; Thu, 19 Mar 2020 13:56:56 -0700 (PDT) In-Reply-To: <20200319203449.GA4180@ACM> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.167.54 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:245589 Archived-At: --000000000000c1a6a505a13b680d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 19, 2020 at 4:35 PM Alan Mackenzie wrote: > Hello, Stefan. > > On Thu, Mar 19, 2020 at 13:35:08 -0400, Stefan Monnier wrote: > > [ .... ] > > > It should be easy (much smaller than a summer project) to change the C > > code so that a bytecode offset can be extracted from the backtrace. > > > The harder and more interesting part is how to propagate source > > information (line numbers and/or lexical variable names and location) > > to byte-code. There are many parts to this, so it's definitely > > possible to get some summer project(s) out of it. E.g. one such > > project is to change the reader so it outputs "fat cons cells" (i.e. > > cons-cells with line-num info), then arrange for that info to survive > > `macroexpand-all` and `cconv.el`. That could already be used to give > > more precise line numbers in bytecompiler warnings. > > "More precise line numbers" is a misconstruction, even though I've used > such language myself in the past. Line numbers don't come from a > physical instrument which measures with, say +-1% accuracy. CORRECT > line (and column) numbers are what we need. > A bytecode offset is exact and accurate. Right now this information unavailable. I think the interpreter uses C pointers stored in a register. So just recording the bytecode offset is a little bit of a slowdown, but not that much. I doubt it would even register as %1 slower. But just that would open the way for improvements. This is doable by a Summer student - Stefan thinks it trivial. But tas you point out there is overhead in getting it accepted and into GNU Emacs. Having access to the bytecode offset in a traceback there next are several options. At the lowest level there is just showing that along with a disassembly of the bytecode. And that I believe that is also doable by a summer student. Going further are a number of options that folks have mentioned so I won't expand on that. > You will recall that the output of correct line/column numbers for byte > compiler messages is a solved problem. I solved it and presented the > fix in December 2018. This fix was rejected because it made Emacs > slightly slower. > > In the 3=C2=BD years I've been grappling with this problem, I've tried al= l > sorts of things like "fat cons cells". They don't work, and can't work. > They can't work because large chunks of our software chew up and spit > out cons cells with gay abandon (I'm talking about the byte compiler and > things like cconv.el here). More to the point, users' macros chew up and > spit out cons cells, and we have no control over them. So whilst we > could, with a lot of tedious effort, clean up our own software to > preserve cons cells (believe me, I've tried), this would fail in users' > macros. > > Since then I've worked a fair bit on creating a "double" Emacs core, one > core being for normal use, the other for byte compiling. There's a fair > amount of work still to do on this, but I know how to do it. The problem > is that I have been discouraged by the prospect of having this solution > vetoed too, since it will make Emacs quite a bit bigger. > > I don't think it is fair to give this problem to a group of summer > coders. It is too hard a problem, both technically and politically. > Ok. So do you have a suggestion for what a summer student might do? > > [ .... ] > > > Stefan > > -- > Alan Mackenzie (Nuremberg, Germany). > --000000000000c1a6a505a13b680d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Thu, Mar 19, 2020 at 4:35 PM Alan = Mackenzie <acm@muc.de> wrote:
Hello, Stefan.

On Thu, Mar 19, 2020 at 13:35:08 -0400, Stefan Monnier wrote:

[ .... ]

> It should be easy (much smaller than a summer project) to change the C=
> code so that a bytecode offset can be extracted from the backtrace.
> The harder and more interesting part is how to propagate source
> information (line numbers and/or lexical variable names and location)<= br> > to byte-code.=C2=A0 There are many parts to this, so it's definite= ly
> possible to get some summer project(s) out of it.=C2=A0 E.g. one such<= br> > project is to change the reader so it outputs "fat cons cells&quo= t; (i.e.
> cons-cells with line-num info), then arrange for that info to survive<= br> > `macroexpand-all` and `cconv.el`.=C2=A0 That could already be used to = give
> more precise line numbers in bytecompiler warnings.

"More precise line numbers" is a misconstruction, even though I&#= 39;ve used
such language myself in the past.=C2=A0 Line numbers don't come from a<= br> physical instrument which measures with, say +-1% accuracy.=C2=A0 CORRECT line (and column) numbers are what we need.

=
A bytecode offset is exact and accurate.=C2=A0 Right now this informat= ion unavailable. I think the interpreter uses C pointers stored in a regist= er.
So just recording the bytecode offset is a little bit of a sl= owdown, but not that much. I doubt it would even register as %1 slower.=C2= =A0

But just that would open the way for improveme= nts. This is doable by a Summer student - Stefan thinks it trivial. But tas= you point out there is overhead in getting it accepted and into GNU Emacs.=

Having access to the bytecode offset in a traceba= ck there next are several options. At the lowest level there is just showin= g that along with a disassembly of the bytecode.
And that I belie= ve that is also doable by a summer student.=C2=A0

= Going further are a number of options that folks have mentioned so I won= 9;t expand on that.=C2=A0


You will recall that the output of correct line/column numbers for byte
compiler messages is a solved problem.=C2=A0 I solved it and presented the<= br> fix in December 2018.=C2=A0 This fix was rejected because it made Emacs
slightly slower.

In the 3=C2=BD years I've been grappling with this problem, I've tr= ied all
sorts of things like "fat cons cells".=C2=A0 They don't work,= and can't work.
They can't work because large chunks of our software chew up and spit out cons cells with gay abandon (I'm talking about the byte compiler an= d
things like cconv.el here).=C2=A0 More to the point, users' macros chew= up and
spit out cons cells, and we have no control over them.=C2=A0 So whilst we could, with a lot of tedious effort, clean up our own software to
preserve cons cells (believe me, I've tried), this would fail in users&= #39;
macros.

Since then I've worked a fair bit on creating a "double" Emac= s core, one
core being for normal use, the other for byte compiling.=C2=A0 There's = a fair
amount of work still to do on this, but I know how to do it.=C2=A0 The prob= lem
is that I have been discouraged by the prospect of having this solution
vetoed too, since it will make Emacs quite a bit bigger.

I don't think it is fair to give this problem to a group of summer
coders.=C2=A0 It is too hard a problem, both technically and politically.


Ok. So do you have a sugg= estion for what a summer student might do?=C2=A0
=C2=A0

[ .... ]

>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Stefan

--
Alan Mackenzie (Nuremberg, Germany).
--000000000000c1a6a505a13b680d--