(A note--when this says "stack" I really mean all the stacks) Okay, I've been thinking about stacks and stack frames, and suchlike things. Well, calling them "stacks" is a bit of a misnomer, since they're really trees, and that's partially where things get nasty. Looking at them as trees does make some things clearer.
First, the assumptions: 1) Most parrot code will be machine generated 2) We may have continuations taken and called most any time 3) Subs we call might really be coroutines 4) We want to be fast So, then, the support. First we can presize the stack frame. We know, for most code, how many stack entries will be needed, on the generic stack, the register stacks, and the integer stack. Yes, for some code we can't tell, but for most we can. Adding a "newframe" op with a size will do it for us. newframe should also close off the current stack frame. (Which is to say, when we 'newframe' we stop using the current frame and set its 'free' count to 0, even if there are still some free slots) Second, we may potentially have to save the contents of the stacks, since we might need to reinstate them. The closing properties of newframe should help here--we just make sure that we have a closed off stack at the point we take a continuation. The third makes life easier if we guaranteed call a routine, any routine, with a closed stack. Since we're potentially passing parameters on the stack, this is somewhat problematic. I'm a little dodgy here, but I'm thinking that the topmost stack frame on call into a function becomes the property of that subroutine, which works except in those cases where there are too many entries for a single frame, at which point things get a bit odd. Finally, fast. Right now all the pushes and pops are all cautious, checking for space, autoextending, and suchlike things. We can add a set of quickpush and quickpop opcodes that don't bother checking in those cases where we know there's space. (For example, if we extend the stack by 10, the next 10 pushes don't need to check depth, and when we preextend the generic stack we can fill in what's needed on extend time to minimize what needs to go on the stack) -- Dan --------------------------------------"it's like this"------------------- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk