unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Vibhav Pant <vibhavp@gmail.com>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: [PATCH] Make purecopy create hash tables properly
Date: Sat, 28 Jan 2017 09:58:55 -0500	[thread overview]
Message-ID: <jwv7f5fnt6b.fsf-monnier+Inbox@gnu.org> (raw)
In-Reply-To: <CA+T2Sh1YM1GcVTVV2ZvuSQB_WwfRMB1sD5kYR4dCajqyMbi2+g@mail.gmail.com> (Vibhav Pant's message of "Sat, 28 Jan 2017 15:55:08 +0530")

> Not sure if I'm correct here, but shouldn't we be *not* purecopying weak hash
> tables?

Good point.  So we should check NILP (old->weak) and signal an
error if set.  And thus old->next_weak should always be NULL and is
trivial to copy.

> I'd recommend skipping purecopy for hash tables altogether, and add an

That would imply we can't purecopy any object which ends up referencing
a hash-table.  Unless we arrange to keep track of those hash-tables
which are referenced from purespace.  We already do that for symbols, so
maybe we can extend/generalize that mechanism (probably a good idea).

> internal :read-only flag to (make-hash-table) for hash tables we know
> aren't going to be be written to, and are thus safe to be purecopied
> (this would obviously only be useful for hash tables that are defined
> using printed syntax).

For cons cells we do:

  CHECK_IMPURE (cell, XCONS (cell));

in `setcar', so we can do the same for hash-tables.  Since purespace is
contiguous, CHECK_IMPURE is pretty efficient, and since it only relies
on the pointer value, the CPU can compute it in parallel with the access to
the object (and the test itself is trivial to predict), so it should
have a negligible impact on performance.


        Stefan



  parent reply	other threads:[~2017-01-28 14:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-27 18:37 [PATCH] Make purecopy create hash tables properly Vibhav Pant
2017-01-27 22:06 ` Paul Eggert
2017-01-27 23:10 ` Stefan Monnier
2017-01-28 10:25   ` Vibhav Pant
2017-01-28 10:26     ` Vibhav Pant
2017-01-28 14:58     ` Stefan Monnier [this message]
2017-01-28 20:06       ` Vibhav Pant
2017-01-29  2:18         ` Stefan Monnier
2017-01-29 17:23       ` Vibhav Pant
2017-01-29 17:58         ` Stefan Monnier
2017-01-29 19:14           ` Vibhav Pant
2017-01-29 19:41             ` Stefan Monnier
2017-01-30 12:43               ` Vibhav Pant

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=jwv7f5fnt6b.fsf-monnier+Inbox@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=vibhavp@gmail.com \
    /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).