Subject: Re: Scheme compilation
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 1999/02/02
Newsgroups: comp.lang.scheme
Message-ID: <795oue$1iffi@fido.engr.sgi.com>
Matthias Blume  <blume@kurims.REMOVE.kyoto-u.ALLCAPS.ac.PARTS.jp> wrote:
+---------------
| rpw3@rigden.engr.sgi.com (Rob Warnock) writes:
| > | > Henry Baker's ``Cheney on the MTA''...
| > | ... (Is it usable with full call/cc ?)
| > +---------------
| > 
| > I think yes. The only trick is that call/cc must first do a stack-
| > generation GC (which includes the longjmp to reset the stack) to
| > get all of the useful history out of the C stack and into the heap...
| 
| No, you don't even have to do a round of GC.  Since the program is
| already in CPS (that's one of the prerequisites of Baker's CotMTA
| scheme), you can simply call the function that is an argument to
| call/cc with the cc as its argument.  This call will _further_ grow
| the stack, as will any other function call.  Eventually, the stack
| will try to grow beyond its limit, at which point the GC will kick in
| and copy all relevant live data to the "real" heap (the C stack is
| part of the "virtual" heap -- as its youngest generation).  The saved
| continuation, provided it is still reachable, will then also be copied
| correctly.
+---------------

I confess: I didn't spend much time carefully working work through all of
the implications to see if there were (or weren't) ways it might fail.
My concern was with what "might" happen if the captured continuation was
called (maybe more than once) *before* the next stack-GC (or maybe once before
and again after, or something even more pathological), but I "knew" it would
be safe if you forced a stack-GC first, so I copped out and said that.

But you're probably right, since the allocation patterns in CotMTA are
really no different than what you'd see with a generational GC with a
fixed "nursery" area [as suggested by Ungar, for caching considerations]...


-Rob

-----
Rob Warnock, 8L-855		rpw3@sgi.com
Applied Networking		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
2011 N. Shoreline Blvd.		FAX: 650-964-0811
Mountain View, CA  94043	PP-ASEL-IA