Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: anton@mips.complang.tuwien.ac.at (Anton Ertl) Newsgroups: comp.compilers Subject: Re: how to find gc roots in stack machine? Date: Mon, 01 Jul 2013 15:54:01 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 20 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <13-07-004@comp.compilers> References: <13-07-002@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: leila.iecc.com 1372905647 43949 64.57.183.58 (4 Jul 2013 02:40:47 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Thu, 4 Jul 2013 02:40:47 +0000 (UTC) Keywords: GC Posted-Date: 03 Jul 2013 22:40:47 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:935 n.oje.bar@gmail.com writes: >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). Since you want it simple, my recommendation is one of: A) Use a conservative GC (e.g., Boehm's). B) Use a separate stack for pointers. Then you know that everything on that stack is a root (or null), and everything on the other stack is not. You still have complexity to identify roots in memory; so my overall recommendation is A. - anton -- M. Anton Ertl anton@mips.complang.tuwien.ac.at http://www.complang.tuwien.ac.at/anton/