Luke Palmer <[EMAIL PROTECTED]> wrote:
> Jeff Clites writes:

>>      a = 1
>>      foo()
>>      print a
>>      b = 10
>>      return b
>>
>> It would seem (w/o continuations) that b should be able to re-use a's
>> register, but if it does then we'll print 10 instead of 1 "the second
>> time".

> It can.  You can't reuse the same PMC (if you're using PMCs), but you
> can reuse the register.

No. With the presence of a continuation the "print a" can be executed
twice. If now C<b = 10> reuses a's register, it'll break.

> It all comes down to how the code is generated.  I've done this in a
> project of mine, and it takes a little thought, but it works.  When you
> take a continuation, you have to saveall before you take it, and
> restoreall at the point where the continuation is to resume.

Please forget C<saveall>. This was the way to go before we had register
frames.

> This is the trick I used (modulo brain code rot--I haven't written PIR
> in a really long time):

>     saveall
>     $P0 = new Continuation
>     set_addr $P0, RESUME
>     save $P0
>     restoreall
>     restore $P0

Sure. That's what we formerly used to do. Two memcpys á 640 bytes + 2
stack operations. The memcpys were killing performance.

This isn't needed anymore. A continuation does restore the register
frame. In your code above you emit all possible code to do the rigth
thing. I'm proposing a much simpler syntax:

  RESUMABLE: foo()
     # code here might be executed more then once

> Luke

leo

Reply via email to