emacs-devel
[Top][All Lists]
Advanced

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

Re: mark_stack () vs GCPROn


From: Dmitry Antipov
Subject: Re: mark_stack () vs GCPROn
Date: Thu, 06 Dec 2012 14:13:47 +0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

On 12/06/2012 01:00 PM, Sergey Mozgovoy wrote:

Emacs has a `mark_stack' function in alloc.c, which looks for (potential)
Lisp_Objects located on the current C stack.  Does it mean that GCPROn
mechanism is not necessary for local Lisp_Object variables now ?

If stack marking is supported, then yes in general; but GCPROs are also
used for debugging. This is controlled by GC_MARK_STACK in lisp.h.

It is quite clear that gcprolist is still necessary for static Lisp_Objects.

IIUC you mix staticpro and GCPRO.

What are the relationships between these 2 approaches for marking objects ?

In short, GCPRO is faster because you don't need to check whether the word
in memory is a Lisp_Object. But stack marking is much more useful because
you don't need to check whether C code calls Feval (and so potentially
Fgarbage_collect) and so you don't worry about protecting local Lisp_Objects.

BTW, the more important distinction is that the GCPRO-assisted collection
is exact: you always know where the Lisp_Objects are, and mark them. Stack
marking is conservative, e.g. treats everything which looks like
the valid Lisp_Object as Lisp_Object. For example, if you have Lisp_Object
at 0x12345678 and this object is not accessible from other objects, but
there is an integer value 0x12345678 somewhere on C stack, the object will
be marked. This way the collector doesn't reclaim some dead objects, which
is impossible if GCPRO is used.

Dmitry




reply via email to

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