unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Correct byte compiler error/warning positions.  The solution!
Date: Sat, 27 Nov 2021 23:05:12 +0000	[thread overview]
Message-ID: <YaK5qEGWqVJOGIue@ACM> (raw)
In-Reply-To: <83wnktzxb2.fsf@gnu.org>

Hello, Eli.

On Sat, Nov 27, 2021 at 12:51:13 +0200, Eli Zaretskii wrote:
> > Date: Sat, 27 Nov 2021 10:33:07 +0000
> > Cc: emacs-devel@gnu.org
> > From: Alan Mackenzie <acm@muc.de>

> > > > I meant that NILP will be implemented as a binary comparison against
> > > > zero, omitting the awkward test for symbols_with_position_enabled.

> > > Please don't write code that assumes Qnil is zero.  (Or maybe I still
> > > misunderstand what exactly you mean by the above.)

> > Don't worry!  The new code merely assumes Qnil is a symbol, and leaves it
> > to the compiler to optimise for Qnil being binary zero.

> Once again, you cannot compare structures with == in portable C.  And
> the Lisp_Object type can be struct.  As long as what you say above
> doesn't mean that you compare with ==, I'm okay with what you propose.

Sorry, I was perhaps a wee bit too informal when I said "==".  The
actual code in lisp.h looks like this:

    #define lisp_h_NILP(x) ((XLI (x) == XLI (Qnil)))

..

Anyhow, it's now working!  I can bootstrap the new code, although I
haven't tried it with native compilation, yet.  For timings, I've used
my favourite informal benchmark, M-; (time-scroll) on xdisp.c:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmacro time-it (&rest forms)
  "Time the running of a sequence of forms using `float-time'.
Call like this: \"M-: (time-it (foo ...) (bar ...) ...)\"."
  `(let ((start (float-time)))
    ,@forms
    (- (float-time) start)))

(defun time-scroll (&optional arg)
  (interactive "P")
  (message "%s"
           (time-it
            (condition-case nil
                (while t
                  (if arg (scroll-down) (scroll-up))
                  (sit-for 0))
              (error nil)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

The timings I have for scrolling in the forward direction (each time
preceded by M-x garbage-collect, and typing/erasing a character to clear
the font-lock settings) are:

(master branch, no native compilation):
20.847s, 21.609s, 19.459s, 21.570s, 21.651

(New code with correct warning messages, no native compilation):
21.284s, 42.152s ????, 19.927s, 19.960s, 22.259s, 22.198, 22.209s.

The input to configure was the same in both cases, namely

  ./configure --with-gif=no --with-tiff=no --with-gpm.

, and the timings were done on the Linux console.

No, I don't understand that 42s run.  A lot of garbage collection,
perhaps?  But otherwise, the timings are broadly similar, with the new
code being slightly slower.  But the variations between runs is more
significant than the variation between versions.

On bug ~9109 from Roland Winkler:

(unwind-protect
    (let ((foo "foo"))
      (insert foo))
  (setq foo "bar"))

Byte compiling this with M-x compile-defun on master produces this
warning message:

  Buffer winkler.el:2:12: Warning: assignment to free variable `foo'

The position 2:12 is clearly wrong.

Byte compiling it with the new code produces:

  Buffer winkler.el:2:12:4:9: Warning: assignment to free variable
`#<symbol foo at 67>'.

There, there are two positions the (old, temporary) 2:12 and the (new,
correct) 4:9.  There is a bit of tidying up of the mechanism to be done
here, obviously, but the correct position is demonstrated.

-- 
Alan Mackenzie (Nuremberg, Germany).



  reply	other threads:[~2021-11-27 23:05 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-26 19:56 Correct byte compiler error/warning positions. The solution! Alan Mackenzie
2021-11-27  5:53 ` Eli Zaretskii
2021-11-27  9:31   ` Alan Mackenzie
2021-11-27 10:07     ` Eli Zaretskii
2021-11-27 10:33       ` Alan Mackenzie
2021-11-27 10:51         ` Eli Zaretskii
2021-11-27 23:05           ` Alan Mackenzie [this message]
2021-11-28  7:25             ` Eli Zaretskii
2021-11-29 11:50               ` Alan Mackenzie
2021-11-29 12:45                 ` Eli Zaretskii
2021-11-29 19:39                   ` Alan Mackenzie
2021-12-01 15:58                     ` Alan Mackenzie
2021-12-01 16:49                       ` Eli Zaretskii
2021-12-01 16:58                         ` Alan Mackenzie
2021-12-01 17:04                           ` Lars Ingebrigtsen
2021-12-01 17:21                             ` Alan Mackenzie
2021-12-01 17:38                               ` Lars Ingebrigtsen
2021-12-01 20:28                                 ` Alan Mackenzie
2021-12-01 17:08                           ` Eli Zaretskii
2021-12-01 17:12                             ` Alan Mackenzie
2021-12-01 17:53                             ` Andrea Corallo
2021-12-01 17:57                               ` Eli Zaretskii
2021-12-02 11:21                               ` Alan Mackenzie
2021-12-02 16:31                                 ` Andrea Corallo
2021-12-02 20:35                                   ` Alan Mackenzie
2021-12-03 21:05                                     ` Alan Mackenzie
2021-12-04 19:22                                       ` Andrea Corallo
2021-12-04 19:39                                         ` Eli Zaretskii
2021-12-04 19:55                                           ` Andrea Corallo
2021-12-04 19:58                                             ` Eli Zaretskii
2021-12-04 20:06                                               ` Andrea Corallo
2021-12-14 14:29                                         ` Alan Mackenzie
2021-12-15  9:33                                           ` Andrea Corallo
2021-12-17 11:54                                             ` Alan Mackenzie
2021-12-20  8:24                                               ` Andrea Corallo
2021-12-21 17:48                                                 ` Alan Mackenzie
2021-11-29 13:24                 ` Robert Pluim
2021-11-29 19:16                   ` Alan Mackenzie
2021-11-30  9:52                     ` Robert Pluim
2021-11-28 20:15             ` Andrea Corallo
2021-12-01 16:18               ` Andrea Corallo
2021-12-01 16:46                 ` Alan Mackenzie

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YaK5qEGWqVJOGIue@ACM \
    --to=acm@muc.de \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).