unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: 65491@debbugs.gnu.org, mattias.engdegard@gmail.com,
	monnier@iro.umontreal.ca
Subject: bug#65491: [PATCH] Improve performance allocating vectors
Date: Sun, 17 Sep 2023 08:18:41 +0300	[thread overview]
Message-ID: <83led5gyxa.fsf@gnu.org> (raw)
In-Reply-To: <8af6fa1c-4873-bd6e-e896-ab5bb8d012a2@cs.ucla.edu> (message from Paul Eggert on Sat, 16 Sep 2023 12:46:34 -0700)

> Date: Sat, 16 Sep 2023 12:46:34 -0700
> Cc: 65491@debbugs.gnu.org, monnier@iro.umontreal.ca
> From: Paul Eggert <eggert@cs.ucla.edu>
> 
> On 2023-09-16 10:09, Eli Zaretskii wrote:
> 
> > I also added Paul to the discussion, since he wrote most of the
> > involved macros.
> 
> Mattias and I had a private email discussion about XUNTAG last month, 
> and he's correct that Emacs's current code, which #defines XUNTAG(a, 
> type, ctype) to ((ctype *) ((char *) XLP (a) - LISP_WORD_TAG (type))), 
> violates the C standard due to calculating a pointer outside its 
> containing object's bounds, whereas the patch P that you just reverted, 
> which defines the same macro to ((ctype *) ((uintptr_t) XLP (a) - 
> (uintptr_t) LISP_WORD_TAG (type))), does not have that particular 
> undefined behavior.

First, may I ask that in the future such discussions be held on the
list, or at least their summary be posted?  You can see right here and
now how this practice of discussing purely technical issues in private
causes unnecessary friction and aggravation, let alone breakage.

Next, even if this was discussed, due to our experience with changes
in this area, it would have been prudent to post the proposed patch
before installing it, so that it could be tested in all the supported
configuration before risking such a fundamental breakage of the master
branch.  You personally do that all the time, and for good reasons,
but Mattias has yet to learn that, it seems.

More to the point: can you explain how this part

   ((uintptr_t) XLP (a) - (uintptr_t) LISP_WORD_TAG (type))

works in a 32-bit build --with-wide-int?  AFAIU, XLP(a) yields a
32-bit value, and LISP_WORD_TAG has all of its low 32 bits zero, so
why do we need the subtraction at all?  Aren't we subtracting a zero
from what XLP yields?  It seems to me that in a 32-bit build with wide
ints just

  #define XUNTAG(a, type, ctype) ((ctype *) XLP (a))

should be enough, since XLP yields a 'void *', no?

> I would not favor a two-pronged approach, in which patch P is present 
> but is used optionally. This would likely cause more trouble than it'd 
> cure, due to lack of testing of the extra combinations. Let's use just 
> one approach and keep it simple and more testable.

Not sure what you are alluding to here, but if by "two-pronged
approach" you mean my suggestion to use cpp conditionals, then what I
meant was to have a separate definition of XUNTAG for 32-bit builds
with wide ints (which could still remove the undefined behavior), just
without all the juggling of integer-to-pointer-and-back conversions,
which completely obscure what should be a simple operation of
extracting a pointer from an integer by masking some of its bits.  Why
do I need to fight with these macros each time I read this code, when
the job it does is so simple?

Thanks.





  reply	other threads:[~2023-09-17  5:18 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24  9:59 bug#65491: [PATCH] Improve performance allocating vectors Ihor Radchenko
2023-08-26  7:14 ` Eli Zaretskii
2023-08-26  7:27   ` Ihor Radchenko
2023-08-26  7:31     ` Eli Zaretskii
2023-08-26  7:51       ` Ihor Radchenko
2023-08-26  8:07         ` Ihor Radchenko
2023-08-26  9:01         ` Eli Zaretskii
2023-08-26  7:47     ` Ihor Radchenko
2023-08-26 12:01 ` Mattias Engdegård
2023-08-26 14:54   ` Ihor Radchenko
2023-08-26 14:55   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-27  9:54     ` Mattias Engdegård
2023-09-16 14:58     ` Mattias Engdegård
2023-09-16 16:12       ` Eli Zaretskii
2023-09-16 16:17         ` Eli Zaretskii
2023-09-16 16:32           ` Mattias Engdegård
2023-09-16 16:54             ` Eli Zaretskii
2023-09-16 17:03               ` Mattias Engdegård
2023-09-16 17:11                 ` Eli Zaretskii
2023-09-17  3:02                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-17 17:02                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-18  2:19                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-18  2:27                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-18  3:08                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-18  4:10                           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-16 16:54             ` Mattias Engdegård
2023-09-16 17:09               ` Eli Zaretskii
2023-09-16 17:22                 ` Mattias Engdegård
2023-09-16 18:19                   ` Eli Zaretskii
2023-09-16 19:04                     ` Mattias Engdegård
2023-09-16 19:46                 ` Paul Eggert
2023-09-17  5:18                   ` Eli Zaretskii [this message]
2023-09-17 15:22                     ` Paul Eggert
2023-09-17 16:15                       ` Eli Zaretskii
2023-09-17 16:37                         ` Paul Eggert
2023-09-17 16:44                           ` Eli Zaretskii
2023-09-18 16:10                             ` Mattias Engdegård
2023-09-18 17:13                               ` Eli Zaretskii
2023-09-19 13:28                               ` Mattias Engdegård
2023-09-19 14:04                                 ` Eli Zaretskii
2023-09-19 14:05                                   ` Mattias Engdegård
2023-09-25 16:06       ` Mattias Engdegård
2023-08-27 16:21 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-28 10:14   ` Ihor Radchenko
2023-08-28 16:32     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-28 12:47   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=83led5gyxa.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=65491@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=mattias.engdegard@gmail.com \
    --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 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).