From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#65491: [PATCH] Improve performance allocating vectors Date: Mon, 18 Sep 2023 00:10:25 -0400 Message-ID: References: <6B2EDD07-AAEB-40E8-B369-F634296BD3D9@gmail.com> <83v8cagkqv.fsf@gnu.org> <83ttrugkj2.fsf@gnu.org> <83sf7egitx.fsf@gnu.org> <871qexzelk.fsf@yahoo.com> <87jzsoxlya.fsf@yahoo.com> <87fs3cxjof.fsf@yahoo.com> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1589"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 65491@debbugs.gnu.org, Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , Eli Zaretskii To: Po Lu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 18 06:11:14 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1qi5bO-0000Gh-3r for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 18 Sep 2023 06:11:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi5b8-0003Ko-Pj; Mon, 18 Sep 2023 00:10:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qi5b6-0003Iq-7z for bug-gnu-emacs@gnu.org; Mon, 18 Sep 2023 00:10:56 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qi5b4-0003Jz-Gc for bug-gnu-emacs@gnu.org; Mon, 18 Sep 2023 00:10:56 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qi5bC-0008Lu-8I for bug-gnu-emacs@gnu.org; Mon, 18 Sep 2023 00:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Sep 2023 04:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65491 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 65491-submit@debbugs.gnu.org id=B65491.169501024332078 (code B ref 65491); Mon, 18 Sep 2023 04:11:02 +0000 Original-Received: (at 65491) by debbugs.gnu.org; 18 Sep 2023 04:10:43 +0000 Original-Received: from localhost ([127.0.0.1]:51794 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qi5at-0008LK-9s for submit@debbugs.gnu.org; Mon, 18 Sep 2023 00:10:43 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:52075) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qi5aq-0008L7-L2 for 65491@debbugs.gnu.org; Mon, 18 Sep 2023 00:10:41 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 36F838072D; Mon, 18 Sep 2023 00:10:27 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1695010226; bh=kz2EJuIURZAO2Sy9LFhAjYc56jYNZRkvFnEl6w76U6U=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=DpJPwn6xkAg35se0oEaKKrb9IxbZHfSFFUSRZqJOS7y6VMZ0iCnYDJ/ZfodY+AvTi E2YEJDB3iBe1pqRtMac79rLan8AK7XOcs8kYfMBtzNYigomNH57zVfAEFBN5ZjetVa HFZmEW6puNKeD6fEcwQWqTPAlXXgC4en78aNao4XDoVyodcNulNobZWTTa/gET3DE3 eXSsLm+4sGToUpIiwzQgw/ZKLCdSU5cF2HuZYKUtwNyhzQ6kKVu8qf2mJPHm/mrtZk DfuwywT1EEqEaq4hk/c5ne31EITgwGyBNFN190aSHO3CYsnHGNXD6fRqJ+vYDGWh/R XJY383ZC3zXoQ== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 1ED85802CD; Mon, 18 Sep 2023 00:10:26 -0400 (EDT) Original-Received: from pastel (unknown [45.72.220.249]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E577D1202E6; Mon, 18 Sep 2023 00:10:25 -0400 (EDT) In-Reply-To: <87fs3cxjof.fsf@yahoo.com> (Po Lu's message of "Mon, 18 Sep 2023 11:08:16 +0800") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:270738 Archived-At: > When casting from pointer to integer and back again, the resulting > pointer must reference the same object as the original pointer, > otherwise the behavior is undefined. That is, one may not use > integer arithmetic to avoid the undefined behavior of pointer > arithmetic as proscribed in C99 and C11 6.5.6/8. Then they're (still) warning about a different situation than ours, i.e. the case where the integer is not the same, e.g. you cast to integer, do some arithmetic giving you a *different* number and then cast it back to a pointer. The way they write it means that even if the number is different it can still be "well"-defined (in the case where the pointer is still pointing to the same object). I'd guess this can happen if you the integer arithmetic ends up moving from one slot to another inside an array, for example. But in any case our TAG+UNTAG is simpler since (barring bugs) we always cast back the exact same integer, so the condition that "the resulting pointer must reference the same object as the original pointer" can only fail if the object was deallocated in the mean time, or if the integer was too small to contain the pointer (and both of those conditions should be true in our case, barring bugs). Stefan