[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lexical goto would include full continuations?
- From: Tony Finch <dot@...>
- Date: Tue, 12 Jul 2011 12:30:44 +0100
David Kastrup <dak@gnu.org> wrote:
> Tony Finch <dot@dotat.at> writes:
> >
> > Fully general first class continuations are difficult to implement
> > efficiently. They either put enormous stress on the garbage collector
> > or they require some kind of stack copying.
>
> It is not that bad. You put the return stack on the heap, and leave
> cleaning it up to the garbage collector. Since garbage collection is a
> major part of most dynamic languages (including Lua) anyway, the impact
> is tolerable.
It requires a heap allocation for all function calls and it destroys
the locality benefits you get from stack allocation. Freeing a stack
frame requires a gc rather than a pointer adjustment. To minimize the
overheads you need a bump allocator (so that heap allocation is as
efficient as stack allocation), you need to keep tight control of
pointers into the nursery (to make GC quick), and you need to make the
nursery a decent size (to amortize the cost of GC) but not so large that
it blows the CPU cache.
So I think it is that bad.
Tony.
--
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
Trafalgar: North or northwest 4 or 5, increasing 6 or 7. Slight or moderate,
becoming moderate or rough. Showers. Moderate or good.