At 11:26 AM +0200 6/9/02, Jerome Vouillon wrote:
>On Sat, Jun 08, 2002 at 02:34:19PM -0400, Dan Sugalski wrote:
>  > Indirect function calls will take maybe 50 cycles, so I'm not worried
>  > about their time. Compared to perl 5, that's fast.
>
>With a JIT compiler, this starts to be significant, though.

True, but that's less of a concern at the moment. As long as the 
semantics are sufficient without being wasteful, we can always trim 
the unnecessary stuff out later.

>  > >A continuation can be invoked just like any other function.  The first
>  > >opcode of its body can then switch the stack frames.  (The register do
>  > >not need to be switched if we specify that callcc does not preserve
>  > >them.)
>  >
>  > The thing with continuations is that the code we're invoking won't
>  > know its a continuation. That information's kept as metadata in the
>  > sub PMC.
>
>Why?  A continuation is captured by a "callcc" opcode.  So, we can
>require this intruction to be always followed by a "execcc" intruction
>that perform the context switch.  If the continuation is invoked, it
>will execute the "execc" intruction and switch to the right context.
>If "callcc" simply returns, it can just skip the "execcc" instruction.

callcc captures a current continuation and makes a sub call with it, true.
We're not restricting continuation capture to being at sub call points, though.

>  > (And we do need to restore the registers, otherwise we're
>>  going to see a lot of stack pushing and popping every time we take a
>>  continuation, and I don't know that it's worth it)
>
>I still don't understand this.  "callcc" performs a function call, so why
>should it preserve registers?

Who says we're only using callcc to capture continuations? We can do 
it anywhere, so we potentially need the registers stored so we can 
properly restore state when we're invoked.

-- 
                                         Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                       teddy bears get drunk

Reply via email to