From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Make purecopy create hash tables properly Date: Sun, 29 Jan 2017 12:58:23 -0500 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1485712781 2548 195.159.176.226 (29 Jan 2017 17:59:41 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 29 Jan 2017 17:59:41 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 29 18:59:36 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cXtl5-0007H0-65 for ged-emacs-devel@m.gmane.org; Sun, 29 Jan 2017 18:59:23 +0100 Original-Received: from localhost ([::1]:56209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cXtl8-000105-Ah for ged-emacs-devel@m.gmane.org; Sun, 29 Jan 2017 12:59:26 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cXtkY-0000zn-UI for emacs-devel@gnu.org; Sun, 29 Jan 2017 12:58:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cXtkV-0002hu-1U for emacs-devel@gnu.org; Sun, 29 Jan 2017 12:58:50 -0500 Original-Received: from [195.159.176.226] (port=33870 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cXtkU-0002ho-Qr for emacs-devel@gnu.org; Sun, 29 Jan 2017 12:58:46 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cXtkN-000411-E3 for emacs-devel@gnu.org; Sun, 29 Jan 2017 18:58:39 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 36 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:6gvHnFhGFW/FjgqSToP80/3lIiM= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:211731 Archived-At: > Based on these suggestions, I have made a few more modifications to the code: > * `gethash' now takes an additional :purecopy argument. If non-nil, the table > will/can be copied to pure storage when the Emacs binary is being dumped. > Since objects in pure storage are read only, gethash enforces that :weak and > :purecopy aren't non-nil at the same time, erroring out when the latter is true. Hmm... why do that in gethash? Why not just check NILP (obj->weak) when purecopying? > * All functions that modify hash tables (`puthash', `clrhash' and `remhash') > make sure that the table is not in pure storage (with CHECK_IMPURE). Good. > * `make_pure_hash_table' now also purecopies the hash table test, and enforces > the checks above with `eassert'. Sounds good. > * A new struct, `pinned_object' is used as a linked list to store objects that > should be marked before every GC cycle. For now, this is only used when > a hash table with the :purecopy property set to nil is passed to purecopy (but > should be usable for other objects in the future). An array would be significantly more efficient, but that sounds good. > Should this work, or is there anything else I need to do? I think this should work. > +make_pure_hash_table (struct Lisp_Hash_Table *table) { Nitpick: I'd call it `purecopy_hash_table`. Stefan