[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CPS in Parrot (was: A plea for a new old language)



At 4:47 PM -0700 8/5/03, Michael Vanier wrote:
>Also, Dan doesn't mention segmented stack architectures that are
>essentially a linked list of stacklets of finite size.  With this you can
>avoid most of the overhead of both stack copying (on the one hand) and
>heap-allocated individual frames (on the other hand).  PLT scheme uses this
>system.  There is a paper on this, but I can't find it right now.

A linked list of fixed sized stack frames is a nice thing, assuming 
your activation information'll fit into them. (They are annoying when 
the system stack is implemented this way if you're not in control all 
the way to the bottom, as we've found) That's not too tough if you 
map each frame to a page of memory, though in these days of 8K memory 
pages that can be a bit wasteful. Still, the wins from 
hardware-assisted COW and suchlike tricks will probably 
counterbalance this, and its not like control often goes so deep that 
it's an issue. (And when it does, it's often via tail calls of some 
sort, so the impact is less) Besides, systems with 8K pages generally 
have more than enough memory handy.

Variable-sized stack frames aren't too bad with a reasonably sized 
free memory pool. If you anchor the frames with a fixed-sized 
structure and have a copying collector, allocating a frame's 
reasonably cheap--you pull a struct off the free list and grab a hunk 
of memory off the top of the free pool, which is maybe two dozen 
instructions if nothing goes wrong and you inline everything. Not 
nearly as cheap as a stack offset twiddle, but not horrible, and for 
parrot's purposes a sub/method call is so darned expensive anyway, 
relatively speaking, that this isn't an issue, though I don't know 
that I'd want to do it in a compiler for a high-performance language.
-- 
                                         Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                       teddy bears get drunk