all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* please help about the implementation of GC.
@ 2011-10-30 14:01 Alin Soare
  2011-10-30 16:56 ` Andreas Schwab
  0 siblings, 1 reply; 6+ messages in thread
From: Alin Soare @ 2011-10-30 14:01 UTC (permalink / raw)
  To: Emacs Dev

[-- Attachment #1: Type: text/plain, Size: 524 bytes --]

Hi,

I wish to read the algorithm of gc, and I cannot.

I understand that I have to have read about black-red trees, but what other
former requirement is necessary to understand the implementation ?

Can somebody help me step-by-step in order to understand it ? Or what
requirement is necessary to understand it ? I have already read about the
algorithm of "conservative stack scanning", but this is not enough. I still
do not understand almost anything from the gc of emacs... Please help.

Thanks a lot in advance,

Alin.

[-- Attachment #2: Type: text/html, Size: 592 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: please help about the implementation of GC.
  2011-10-30 14:01 please help about the implementation of GC Alin Soare
@ 2011-10-30 16:56 ` Andreas Schwab
  2011-10-30 17:53   ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2011-10-30 16:56 UTC (permalink / raw)
  To: Alin Soare; +Cc: Emacs Dev

Alin Soare <as1789@gmail.com> writes:

> I wish to read the algorithm of gc, and I cannot.

The Emacs gc is a simple mark and sweep collector.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: please help about the implementation of GC.
  2011-10-30 16:56 ` Andreas Schwab
@ 2011-10-30 17:53   ` Eli Zaretskii
  2011-10-30 18:27     ` Alin Soare
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2011-10-30 17:53 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: as1789, emacs-devel

> From: Andreas Schwab <schwab@linux-m68k.org>
> Date: Sun, 30 Oct 2011 17:56:15 +0100
> Cc: Emacs Dev <emacs-devel@gnu.org>
> 
> Alin Soare <as1789@gmail.com> writes:
> 
> > I wish to read the algorithm of gc, and I cannot.
> 
> The Emacs gc is a simple mark and sweep collector.

Right.

Alin, you can start by reading the node "Garbage Collection" in the
ELisp manual, and then proceed reading alloc.c, where you will see
many functions named mark_SOMETHING and then gc_sweep that does the
sweep stage.  If you want more background before reading the ELisp
manual, try googling "mark and sweep garbage collection".



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: please help about the implementation of GC.
  2011-10-30 17:53   ` Eli Zaretskii
@ 2011-10-30 18:27     ` Alin Soare
  2011-10-30 18:43       ` Andreas Schwab
  2011-10-30 22:05       ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Alin Soare @ 2011-10-30 18:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Andreas Schwab, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1012 bytes --]

> > > I wish to read the algorithm of gc, and I cannot.
> >
> > The Emacs gc is a simple mark and sweep collector.
>
> Right.
>
> Alin, you can start by reading the node "Garbage Collection" in the
> ELisp manual, and then proceed reading alloc.c, where you will see
> many functions named mark_SOMETHING and then gc_sweep that does the
> sweep stage.  If you want more background before reading the ELisp
> manual, try googling "mark and sweep garbage collection".
>

I have read the mark-sweep algorithm; I know it. However, I do not manage
making the connection with alloc.c.

For example, I cannot understand what kind of objects are kept in every
node of the red-black tree  (in books I never saw gc implemented with
red-black trees). I know that the objects are kept in obarrays. What link
is there between obarrays and red-black tree of gc ?

What happens to a Lisp_Object defined in C code? Is it freed if it is found
by conservative stack algorithm ? What is the link between GCPRO? macros
and the gc ?

[-- Attachment #2: Type: text/html, Size: 1324 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: please help about the implementation of GC.
  2011-10-30 18:27     ` Alin Soare
@ 2011-10-30 18:43       ` Andreas Schwab
  2011-10-30 22:05       ` Stefan Monnier
  1 sibling, 0 replies; 6+ messages in thread
From: Andreas Schwab @ 2011-10-30 18:43 UTC (permalink / raw)
  To: Alin Soare; +Cc: Eli Zaretskii, emacs-devel

Alin Soare <as1789@gmail.com> writes:

> What happens to a Lisp_Object defined in C code?

They always form a GC root, see staticpro.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: please help about the implementation of GC.
  2011-10-30 18:27     ` Alin Soare
  2011-10-30 18:43       ` Andreas Schwab
@ 2011-10-30 22:05       ` Stefan Monnier
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2011-10-30 22:05 UTC (permalink / raw)
  To: Alin Soare; +Cc: Eli Zaretskii, Andreas Schwab, emacs-devel

> For example, I cannot understand what kind of objects are kept in every
> node of the red-black tree  (in books I never saw gc implemented with
> red-black trees). I know that the objects are kept in obarrays. What link
> is there between obarrays and red-black tree of gc ?

Start by ignoring the conservative stack scanning (which is the one
that uses the red-black tree).  Also the fact that we use a red-black
tree is not important: it's just a map from addresses to information
about them (whether the address is allocated to Elisp data and if so to
which kind of data).


        Stefan



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-10-30 22:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-30 14:01 please help about the implementation of GC Alin Soare
2011-10-30 16:56 ` Andreas Schwab
2011-10-30 17:53   ` Eli Zaretskii
2011-10-30 18:27     ` Alin Soare
2011-10-30 18:43       ` Andreas Schwab
2011-10-30 22:05       ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.