From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Gerd_M=C3=B6llmann?= Newsgroups: gmane.emacs.devel Subject: Re: MPS: weak hash tables Date: Wed, 03 Jul 2024 08:11:48 +0200 Message-ID: References: <2syUQ04IbTWqDJjMfKSrtzWMWmFGq1GIOwSxv_r6BEyNDtk7ADADKjZk-90g9tSS9SKWppkiq6_zihUtsoE1spiopaOI6-v9inQrGxwMyCs=@protonmail.com> <87o77gvxz3.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24126"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Pip Cet , Eli Zaretskii , Emacs Devel To: Helmut Eller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jul 03 08:12:36 2024 Return-path: Envelope-to: ged-emacs-devel@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 1sOtEK-00068K-Ej for ged-emacs-devel@m.gmane-mx.org; Wed, 03 Jul 2024 08:12:36 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sOtDh-0000AB-9r; Wed, 03 Jul 2024 02:11: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 1sOtDf-00009m-71 for emacs-devel@gnu.org; Wed, 03 Jul 2024 02:11:55 -0400 Original-Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOtDd-0003ws-Ev; Wed, 03 Jul 2024 02:11:54 -0400 Original-Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3626c29d3f0so2495296f8f.1; Tue, 02 Jul 2024 23:11:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719987111; x=1720591911; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+mUquAbp+n1V3/xNQ/JHg2Kkcs4LcyM68suY1+vgnVU=; b=MMkWcFiQFzFkiln85Qgi/RN0/q/jTCrN/MAEjMI+apBdnyfYjehghUHxSC0BlHyVw4 +IYZ2vfqaEerTbuJF5g4rSIJZkIwfrjgHdktaxRHqkPoOa1qxmoYNuoM+CPh24SicZgp OznqZNFm7Sm/EAqn6nNBZMiqjiZvfqcuvgFmPJHEeWMqcIo5jzNIGZuxuSceYEuG3QLc o5imxrUIE3A1KEZxjxCLhib+l1zQHJ+xzutkH8Oi9YaIGZ4lEjqKqPi/oyPngWzerAS4 ZOwgxiECZGxv35sMHPtVgJ89yvgW2BDuXHmOYfR4JgNl6gVuJ2n/Xrt2+UzTJaYyEMC2 gUpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719987111; x=1720591911; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+mUquAbp+n1V3/xNQ/JHg2Kkcs4LcyM68suY1+vgnVU=; b=jS+Dj+4FM7VEUbX2Rswo6nOEVI00iAKVe8+ch1JFWZXWUjG5UmDoETkh67xaNnSFsQ 08Kn68lg9NFfiPgxtZ4omH46YihLoIlVSoC3ghIPksWuAU37OOUVISMwRl7EoUyFpjlM gHCnx1u+c71AovB0aex8eZrM5W9e5MUvMWcP9Zmvm2yLvnwM3H4kqf4cDo3z/6ddHjUQ niggfICyvQ5906K5tldjxFJbgE7Api6q5b2cC+eBpVX0jeMJqN8L2cphDzcjySgj3yge IC1HgeWhsHsSMPpbP1BHftFlTUqr9EZ1pEohMZHgmv1QESxnJAqDkN57dEeuOYYfaFxf caAg== X-Forwarded-Encrypted: i=1; AJvYcCUDHdecENyJXg+nqK1c/j7kadHkakAh/X1AW7BUMt6LXRoGa1Z6FpMV2mUqvD0YzT7EiKgUo7Lyknb3xxUzBlxRnj3lkPyVPhEP7uvvOgMkZRQ= X-Gm-Message-State: AOJu0Yzp38AWD4dpoqHJJ/xsobXfaax5nNrI8AVrcZR8sXaMh9esSMbS +4K8c0+W6xIbv2VS3XGYb9H9KYQSeyU14TZg34uJg1cA9bxwQGCUk39R8A== X-Google-Smtp-Source: AGHT+IHouo2iflVKPgrmZv0SyFVkuReh3aU/wsNXSYMF1dAV6XKrOnQ8I2+tkvzS1ZA2qVP4DkF1+g== X-Received: by 2002:a5d:64cc:0:b0:367:8f84:ee1d with SMTP id ffacd0b85a97d-3678f84ef1fmr1810479f8f.8.1719987110273; Tue, 02 Jul 2024 23:11:50 -0700 (PDT) Original-Received: from pro2.fritz.box (pd9e362dd.dip0.t-ipconnect.de. [217.227.98.221]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a1030dfsm14901361f8f.100.2024.07.02.23.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 23:11:49 -0700 (PDT) In-Reply-To: <87o77gvxz3.fsf@gmail.com> (Helmut Eller's message of "Tue, 02 Jul 2024 13:23:44 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=gerd.moellmann@gmail.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:321228 Archived-At: Helmut Eller writes: > On Tue, Jul 02 2024, Pip Cet wrote: > >> Also, there's the whole caution thing about weak objects containing >> only unaligned words or words pointing directly to a base object, >> which is only relevant on Unix/i386, IIRC. (MPS emulates instructions >> to simulate fine-grained barriers, which is a really cool idea; I'd >> still like an option to turn it off though...). That would mean we >> have to replace Lisp_Objects and use the ptr member of our union (and >> that's the reason I'm using fixnums rather than plain integers for the >> hash). > > Why do you think that the restriction only applies to 32-bit systems? > My interpretation of > > Section 7.4. Caution > ... > =E2=80=9CAligned pointer=E2=80=9D means a word whose numeric value (tha= t is, its value > when treated as an unsigned integer) is a multiple of the size of a > pointer. If you=E2=80=99re using a 64-bit architecture, that means that= an > aligned pointer is a multiple of 8 and its bottom three bits are zero. > ... > > is that it applies to 64-bit machines as well. OTOH, when I see this in a bit broader context, namely 7.3 ... =20=20 Emulation of accesses to protected objects happens when all of the following are true: The object is a weak object allocated in an AWL pool. =20=20 The MPS is running on Linux/IA-32 or Windows/IA-32. Extending this list to new (reasonable) operating systems should be tolerable (for example, macOS/IA-32). Extending this to new processor architectures requires more work. =20=20 The processor instruction that is accessing the object is of a suitable simple form. The MPS doesn=E2=80=99t contain an emulator for all possible instructions that might access memory, so currently it only recognizes and emulates a simple MOV from memory to a register or vice-versa. =20=20 Contact us if you need emulation of access to weak references for new operating systems, processor architectures, or memory access instructions. 7.4. Caution=EF=83=81 Because of the instruction emulation described in Protection faults ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ above, AWL places the following restriction on the format of objects allocated in it: Each slot in an object must either be a valid word-aligned reference, or else the bottom bits of the word must be non-zero so that it does not look like an aligned pointer. =E2=80=9CAligned pointer=E2=80=9D means... I'd bet that these restrictions don't matter when emulation is not done, which is the case for 64 bit processors, not IA32 etc. And indeed, on my machine with arm64 splatting in the marker vectors works just fine. I can understand that Ravenbrook documents these restrictions, for future (payed) developments and so on, but, you know... implementing them gets pretty ugly pretty quickly. (And I wonder if the emulation brings enough to warrant the effort.) It would be nice if the ugliness could be encapsulated so that one doesn't have to see it all the time, as far as that it possible in C :-). Or conditionalized, maybe, because with Helmut's idea (which I find the right one), we're using and additional word for weak references.