From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: Buffer-/frame-local variables [Was: Re: Make buffer- and frame-locals a misc object]
Date: Fri, 17 Aug 2012 09:20:14 -0400 [thread overview]
Message-ID: <jwv7gsyqjjq.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <502C72CD.2050908@yandex.ru> (Dmitry Antipov's message of "Thu, 16 Aug 2012 08:10:53 +0400")
>>> For 1), my previous (and inglorious) attempt to hack around
>>> save-excursion shows that mixing explicitly allocated/freed objects
>>> with GC-managed objects is poor idea, so getting rid of xmalloc/xfree
>>> makes the things more predictable.
>> Fear of the unknown is not a good motivation for a change ;-)
>> Have you found out what was the problem?
> The problem was that the marker embedded into struct Lisp_Excursion
> can be linked to buffer's undo list; when struct Lisp_Excursion gets
> xfree'd, the marker pointer from undo list becomes dangling.
So, the problem is not that the Lisp_Excursion used malloc/free, but
that the marker used malloc/free (implicitly by being embedded in the
Lisp_Excursion) although it can get captured by other pointers.
> OK. So please consider attached patch for the trunk.
See comments below.
>> I do wonder, tho: do we need those write-barriers in the object-creation
>> function (e.g. make_buffer_local_value)?
> In general, no, since all just allocated objects are new by definition,
> and write barrier action is raised only if the pointer to new object is
> stored into an old one. So, the write barrier is installed but never
> raised;
Another reason is that until they're initialized, the fields contain
invalid values, so if the GC sees them we're in trouble, right?
- valcontents = BLV_VALUE (blv);
+ valcontents = XCDR (blv->valcell);
Please don't: BLV_VALUE is more clear and abstract (same applies to
other places where you replace BLV_VALUE with XCDR (blv->valcell)).
-#define BLV_FOUND(blv) \
+get_blv_found (struct Lisp_Buffer_Local_Value *blv)
Why add a "get_" prefix?
Elisp and Emacs generally uses "<type>-<field>" for accessors and
"set-<type>-<field>" for setters.
Stefan
next prev parent reply other threads:[~2012-08-17 13:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-15 10:50 Make buffer- and frame-locals a misc object Dmitry Antipov
2012-08-15 14:20 ` Stefan Monnier
2012-08-15 14:33 ` Dmitry Antipov
2012-08-15 16:02 ` Stefan Monnier
2012-08-16 4:10 ` Buffer-/frame-local variables [Was: Re: Make buffer- and frame-locals a misc object] Dmitry Antipov
2012-08-17 13:20 ` Stefan Monnier [this message]
2012-08-17 14:29 ` Dmitry Antipov
2012-08-21 17:35 ` Stefan Monnier
2012-08-17 17:11 ` Paul Eggert
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=jwv7gsyqjjq.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=dmantipov@yandex.ru \
--cc=emacs-devel@gnu.org \
/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).