Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #934

Re: how to find gc roots in stack machine?

From "Nils M Holm" <nmh@t3x.org>
Newsgroups comp.compilers
Subject Re: how to find gc roots in stack machine?
Date 2013-07-01 17:33 +0200
Organization Compilers Central
Message-ID <13-07-003@comp.compilers> (permalink)

Show all headers | View raw


n.oje.bar@gmail.com:
> I am writing a simple compiler for a simple stack machine. Now I want
> to add a garbage collector. To do this I need a way to be able to find
> all roots in the stack at any given time (or at least at some special
> points in time).

Basically any value on the stack is a potential root. The real problem
is to distinguish values that point to addresses in the address space
of the virtual machine from literal values (which do not point to any
address or to an address outside of the scope of the GC).

A common approach is to check whether a value on the stack is in the
(collectable part of the) address space of the VM. If so, treat it as
a root. This approach is simple and does not require any meta
information. The drawback is, of course, that it may mark objects that
are not longer used. This is called the "conservative" approach to GC.

The other variant, the "precise" approach, usually sacrifices one bit
of information per stack element. This bit is then used to indicate
whether or not that value points to an address.

The book "Garbage Collection" by Jones & Lins is still a valuable
resource on that topic.
--
Nils M Holm  < n m h @ t 3 x . o r g >  www.t3x.org

Back to comp.compilers | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: how to find gc roots in stack machine? "Nils M Holm" <nmh@t3x.org> - 2013-07-01 17:33 +0200
  Re: how to find gc roots in stack machine? George Neuner <gneuner2@comcast.net> - 2013-07-04 11:57 -0400

csiph-web