Piers Cawley <[EMAIL PROTECTED]> wrote: > The thing is, 'pushtop' is almost certainly the wrong thing to do. You > should only push the registers you care about onto the register > stacks.
Yes: $ time parrot -j oofib.imc fib(28) = 317811 3.050051s real 0m3.077s $ time parrot -j -Oc oofib.imc fib(28) = 317811 2.234049s real 0m2.262s C<savetop> becomes C<pushtopp> if only P-registers are used. Saving only 3 or 5 registers isn't possible yet. We have no opcodes for that. > The catch is that, whilst I know which registers *I* care about, I don't > know which registers IMCC cares about. So maybe IMCC's 'newcont' should > expand to: > save 'imcc_magic_register1' > save 'imcc_magic_register2' > target = newsub .Continuation, dest > restore 'imcc_magic_register2' > restore 'imcc_magic_register1' > Notice how making a continuation looks remarkably like making a function > call. The usage of above Continuation would be to pass it on into a subroutine and eventually return through it to an alternate position? If yes, then the Continuation should be created inside the call sequence to avoid duplicate register saving and restoring code: res = subroutine(args, NEWCONT) But that's only one side of the business. The code at the return label C<dest>) has to restore the same registers too. If the target of the Continuation isn't the function return, it has to look somethin like this: goto around_cont_ret cont_ret_target: restoretop # or whatever was saved around_cont_ret: > If the destination of the continuation is within the current > compilation unit (which it probably should be, or things get *very* > weird) then, potentially, IMCC knows what registers the continuation > target cares about and can automagically save the current .locals as > well. Yes. > Would it be possible to arrange things so that > $P0 = new .Continuation > $P0 = P1 # The current RetContinuation > makes $P0 into a full continuation equivalent to the RetContinuation? Sure. It depends on what part of the context should be copied into the Continuation: get_addr Idest, P1 set_addr $P0, Idest # assign dest - implemented or assign $P0, P1 # vtable->set_pmc (N/Y) which could do whatever is appropriate. ($P0 = P1 just aliases the two and isn't usable for assignment) leo