Anyway, our issues. We burn a lot of time doing pushes and pops of register frames. Besides the memory copy times, which aren't insignificant, there's the actual pushing of the pieces onto the stacks, which takes time as well. This is unavoidable at least to some extent since the register contents need saving. Not a huge deal with regular sub calls, but it kills us with vtable calls, since we have to save off everything.
So, instead, lets try this one on for size.
1) The interpreter pointer gets another level of indirection, it points to a pointer to the interpreter. (We'll see why in a bit) I loathe this one, it burns about 3-4% performance right off the bat, but there's nothing for it. Dammit.
2) We realize that there *is* no return statement, there is only the invocation of continuations. This is important.
3) Subs, methods, coroutines, continuations, and closures are all continuations. This is also important.
4) Each continuation has a *template* interpreter structure attached to it. For return continuations the template is the current interpreter structure.
5) When a continuation is invoked, a *new* interpreter structure is allocated and the contents of the template are copied into it. The interpreter handle is changed to point to the new interpreter structure. The destination interpreter has its top register half left alone, while the bottom half is copied from the current interpreter.
The place where we get the big win is #5, especially with vtable invocations. Because continuations are *not* valid across C/parrot boundaries (which is where all the uncertainty comes in) we don't have to worry about anything holding onto the return continuation for the initial entry, which means that when it's invoked we just use the interpreter structure rather than copying it.
There's still an awful lot of copying going on, but I think it'll make some things a little simpler.
--
Dan
--------------------------------------it's like this------------------- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk