[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lexical goto would include full continuations?
- From: David Kastrup <dak@...>
- Date: Tue, 12 Jul 2011 13:45:40 +0200
Tony Finch <dot@dotat.at> writes:
> 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.
"Freeing a stack frame" does not need continuous action on every
return. It is done when necessary, like heap collection.
> 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.
You need good garbage collection. Having a bad garbage collector and
hoping it will not show too much is not a good option for dynamic
languages with or without continuations.
--
David Kastrup