From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: emacs-devel@gnu.org
Subject: Re: Thoughts on getting correct line numbers in the byte compiler's warning messages
Date: Wed, 7 Nov 2018 12:35:10 +0000 [thread overview]
Message-ID: <20181107123510.GA3966@ACM> (raw)
In-Reply-To: <jwva7mmyol9.fsf-monnier+emacs@gnu.org>
Hello, Stefan.
On Tue, Nov 06, 2018 at 15:04:51 -0500, Stefan Monnier wrote:
> >> > Many of the original forms produced by the reader survive these
> >> > transformations.
> >> Yeah, that's why I thought of using a hash-table.
> > What I tried before (about two years ago) was having each
> > reader-produced form as a key, and the source position as a value. Each
> > time the source was transformed, the new form became a new key, and the
> > value stayed the same.
> >
> > I vaguely remember this being slow.
> Which part do you remember being slow (e.g. just performing a `read`
> that returns a sexp and fills that table along the way)?
Looking at notes I made at the time, I amended a small portion of e.g.
byte-optimize-body to make a new hash entry with the same value when a
form was transformed. The slowdown on just the byte optimiser was
around a factor of three. I think the comparison was with the
byte-optimiser in the released version (without any hash tables).
> > Maybe it would be better the other way around. The source position
> > would be the key, and the value would be a list of (equivalent) forms.
> > Building this table would be faster.
> I don't follow you: why would this be faster?
I don't think I follow myself here. I was thinking that accessing a
hash table element was slow, therefore keeping a table value current and
pushing transformed forms onto it would be faster than creating a new
hash table entry for these new forms. Looking at the code for hash
tables, the access time can not be all that long.
> > Finding a form in that table for a warning message would be much
> > slower, but that shouldn't matter.
> It could matter, but yeah, let's not worry about that for now.
> > In byte-compile-warn, if we can't find the current form in the above
> > table, we search for the containing form, get its source offset, put
> > point there and read the next N forms, moving forward in the source text
> > to the position we need. That this might be slow (I don't really think
> > it would be) is again unimportant.
> I lost you here as well: how is the location data propagated from the
> reader to the byte-compiler's phase that ends up running
> byte-compile-warn?
For objects created by the reader, they can be looked up in the hash
table. But your real question ....
> I mean, how is the location info preserved while going through
> macro-expansion, closure-conversion, and byte-optimize-form? Or are
> most objects left untouched in practice?
Either by making new entries in the table for transformed forms, or by
noting byte-compile-containing-form and "sub-form number 2" and using
read (or forward-sexp, even) on the source text to move forward to
sub-form 2.
> I guess we could limit the info (e.g. stored in a hash-table) to map
> "first cons-cell in a list" to its location info, and then change
> macroexp.el, cconv.el, and friends to preserve this info as much as
> possible (we may even come up with a `with-location-data` macro that
> encapsulates most of the work so the changes are easy to apply).
> Is that what you're thinking of?
That's the sort of thing, yes.
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2018-11-07 12:35 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-01 17:59 Thoughts on getting correct line numbers in the byte compiler's warning messages Alan Mackenzie
2018-11-01 22:45 ` Stefan Monnier
2018-11-05 10:53 ` Alan Mackenzie
2018-11-05 15:57 ` Eli Zaretskii
2018-11-05 16:51 ` Alan Mackenzie
2018-11-06 4:34 ` Herring, Davis
2018-11-06 8:53 ` Alan Mackenzie
2018-11-06 13:56 ` Stefan Monnier
2018-11-06 15:11 ` Alan Mackenzie
2018-11-06 16:29 ` Stefan Monnier
2018-11-06 19:15 ` Alan Mackenzie
2018-11-06 20:04 ` Stefan Monnier
2018-11-07 12:35 ` Alan Mackenzie [this message]
2018-11-07 17:11 ` Stefan Monnier
2018-11-07 17:00 ` Alan Mackenzie
2018-11-07 17:25 ` Stefan Monnier
2018-11-07 18:47 ` Alan Mackenzie
2018-11-07 19:12 ` Stefan Monnier
2018-11-08 14:08 ` Alan Mackenzie
2018-11-08 17:02 ` Stefan Monnier
2018-11-08 22:13 ` Alan Mackenzie
2018-11-11 12:59 ` Alan Mackenzie
2018-11-11 15:53 ` Eli Zaretskii
2018-11-11 20:12 ` Alan Mackenzie
2018-11-11 20:47 ` Stefan Monnier
2018-11-12 3:30 ` Eli Zaretskii
2018-11-12 16:19 ` Eli Zaretskii
2018-11-12 14:16 ` Alan Mackenzie
2018-11-12 15:44 ` Alan Mackenzie
2018-11-12 20:36 ` Stefan Monnier
2018-11-12 21:35 ` Alan Mackenzie
2018-11-14 13:34 ` Stefan Monnier
2018-11-15 16:32 ` Alan Mackenzie
2018-11-15 18:01 ` Stefan Monnier
2018-11-16 14:14 ` Alan Mackenzie
2018-11-08 4:47 ` Michael Heerdegen
2018-11-08 11:07 ` Alan Mackenzie
2018-11-09 2:06 ` Michael Heerdegen
2018-11-10 10:59 ` Alan Mackenzie
2018-11-10 13:20 ` Stefan Monnier
2018-11-11 7:56 ` Michael Heerdegen
2018-11-08 13:45 ` Stefan Monnier
2018-11-09 3:06 ` Michael Heerdegen
2018-11-09 16:15 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181107123510.GA3966@ACM \
--to=acm@muc.de \
--cc=emacs-devel@gnu.org \
--cc=monnier@IRO.UMontreal.CA \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.