From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu 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 11:08:16 +0800 Message-ID: <87fs3cxjof.fsf@yahoo.com> 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> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39539"; 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: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 18 05:09:20 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 1qi4dU-000A60-GB for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 18 Sep 2023 05:09:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qi4d7-0005o9-7T; Sun, 17 Sep 2023 23:08:57 -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 1qi4d4-0005nz-RQ for bug-gnu-emacs@gnu.org; Sun, 17 Sep 2023 23:08:54 -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 1qi4d4-0007AL-IB for bug-gnu-emacs@gnu.org; Sun, 17 Sep 2023 23:08:54 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qi4dC-0006P9-Fz for bug-gnu-emacs@gnu.org; Sun, 17 Sep 2023 23:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Sep 2023 03:09: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.169500652224576 (code B ref 65491); Mon, 18 Sep 2023 03:09:02 +0000 Original-Received: (at 65491) by debbugs.gnu.org; 18 Sep 2023 03:08:42 +0000 Original-Received: from localhost ([127.0.0.1]:51743 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qi4cr-0006OK-KP for submit@debbugs.gnu.org; Sun, 17 Sep 2023 23:08:41 -0400 Original-Received: from sonic312-25.consmr.mail.ne1.yahoo.com ([66.163.191.206]:42340) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qi4cq-0006Nz-3n for 65491@debbugs.gnu.org; Sun, 17 Sep 2023 23:08:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1695006506; bh=evsDqaq8PUv2N4T0ZCibikkIxnXiuZSc0xbCx0cgsUk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=BHssxufJh1Y5Vi4P8uqmVZjYa90pR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4E1QJcFXMxLGx9dYFio4PUBTE0iq49fMfClccYNhiUdYKp4nG Tq7.taI.BQhvRJxP4LhlUdK9W7yyfNx52nkmCJmm4trguAPT59Zw.SEeiEWRQlHgx3COwW12z_iI 5hPnGWALEeHU3mvulpSOjOX5nogC5H3R6u4kw8IVqr5Z5NRuS33wAd66p5LFWmjbsp0VJnVSyA4H 9VQpxwnUvT2Vc2OfyH1kIUp1WOQGv2LpVV.yrqV4tQDoJnRWmVKNURSAH.WvIir6H_qsEutKMsz7 zRfHyOuIXXNgbc4WXyp01dkz9BZYfFjVWi8f7hWKe1xYDTd5ttew0wQQTXO.sPy76DUxcpuWzTbT zkXLaKw5mKCaaPrHiaMfV4P44Aj65uZTGKRq9nvkTyBB5ctwbsuWyC3X4o31S1.bksqE8eBAmIgc nLaclpVqzR_24VNY3pFtiHMm3_DqFIXoRgGa_qrQ3TgRClCL_aDVQfFTaIdm9W9LmrHOvP21o1eb DN2dETO0hRP68uttRie6ToWq.Jyl4RvGJ8qJR9jaQq3Ek5hikZbE1yP1tTIUq_ySxUsJN_2ev2l5 8at.PfTmEvpFQvsTf97s57PT5X9l4HcbHfW7WWIoYb X-Sonic-MF: X-Sonic-ID: d246218b-974e-497a-9889-30e14c95ac1b Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.ne1.yahoo.com with HTTP; Mon, 18 Sep 2023 03:08:26 +0000 Original-Received: by hermes--production-sg3-55c667b499-gg78d (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 95dd2425c22f76ba11f043122077d334; Mon, 18 Sep 2023 03:08:23 +0000 (UTC) In-Reply-To: (Stefan Monnier's message of "Sun, 17 Sep 2023 22:27:43 -0400") X-Mailer: WebService/1.1.21797 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo 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:270736 Archived-At: Stefan Monnier writes: >>> Even converting them back to their original pointer (which is what we do >>> with tag/untag pairs) is documented to be well-defined if you compile >>> using GCC. >> Only if the consequent pointer designates the same object as the initial >> pointer (of which I see no scrutable definition within GCC's >> documentation.) > > IIUC the "if" here is talking about the fact that if the object is > deallocated between the two casts, then you're on your own, of course. Nope, (gcc)Arrays and Pointers is quite unequivocal: * `The result of converting a pointer to an integer or vice versa (C90 6.3.4, C99 and C11 6.3.2.3).' A cast from pointer to integer discards most-significant bits if the pointer representation is larger than the integer type, sign-extends(1) if the pointer representation is smaller than the integer type, otherwise the bits are unchanged. A cast from integer to pointer discards most-significant bits if the pointer representation is smaller than the integer type, extends according to the signedness of the integer type if the pointer representation is larger than the integer type, otherwise the bits are unchanged. 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. and directly cites the apposite portions of the Standard. > IIUC Mattias bumped into this after he made a few "innocent looking" > changes to the vector allocation code. I'll let Mattias fill us in.