emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Buffer-/frame-local variables [Was: Re: Make buffer- and frame-local


From: Dmitry Antipov
Subject: Re: Buffer-/frame-local variables [Was: Re: Make buffer- and frame-locals a misc object]
Date: Fri, 17 Aug 2012 18:29:16 +0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120713 Thunderbird/14.0

On 08/17/2012 05:20 PM, Stefan Monnier wrote:

Another reason is that until they're initialized, the fields contain
invalid values, so if the GC sees them we're in trouble, right?

Not quite.  In our terms, the core thing for simple generational GC is:

struct Lisp_Foo
{
  Lisp_Object bar;
  Lisp_Object baz;
};

void
foo_set_bar (Lisp_Object foo, Lisp_Object bar)
{
  if (object_generation (foo) == OLD && object_generation (bar) == NEW)
    /* This function should record all pointer-type Lisp_Objects
       from new generation which are accessible from old generation.
       Such objects will be considered as a part of the root set at
       the next generational collection.  */
    record_intergenerational_object (bar);
  XFOO (foo)->bar = bar;
}

/* Likewise for foo_set_baz.  */

Lisp_Object
make_foo (Lisp_Object bar, Lisp_Object baz)
{
  Lisp_Object foo = allocate_foo ();    /* At this point, object_generation 
(foo) is always NEW.  */
  foo_set_bar (foo, bar);               /* Since foo is NEW, barrier action 
isn't raised whatever bar is;
                                           don't care about old (uninitialized) 
XFOO (foo)->bar here.  */
  foo_set_baz (foo, baz);               /* Likewise.  */
  return foo;
}


-           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.

Fixed and installed as 109660.

Dmitry




reply via email to

[Prev in Thread] Current Thread [Next in Thread]