Luke Palmer <[EMAIL PROTECTED]> writes:

> Piers Cawley writes:
>> > You seem to be mixing up different issues with that statement. Using
>> > plain Continuation PMCs for returning just from subroutines was dead
>> > slow, w or w/o COWed stacks.
>> 
>> But when a Continuation is simply a collection of pointers to the tops
>> of the various stacks (and I really do think it should include P1 in
>> that list...) will it really be that slow? I'm surprised.
>
> I implemented this in the register stacks, but I didn't spend any time
> on optimization (and who knows, I may have even been marking the stacks
> COW unnecessarily).  Continuation creation, call, and return had great
> performance.  But the problem was that pushtop, etc. were much slower
> than with the current scheme.  

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. I still find it odd that pushing 16 register onto the stack is
quicker than pushing 3 (for appropriate values of 3) 

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.

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. 


> I would love to see RetContinuation leave, honestly.  One of the
> greatest things about CPS is that you can grab anybody's continuation
> that they passed you and store it somewhere.  RetContinuation is just a
> computed goto.

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?

Reply via email to