[EMAIL PROTECTED] (Leopold Toetsch) writes:

> Piers Cawley <[EMAIL PROTECTED]> wrote:
>
>> Remember how Leo wanted an example of how continuations were used?
>
> Great example - I don't understand how it wotks though :) - but I
> understand, why the PIR code might fail:
>
>> .sub _choose
>
> [ ... ]
>
>>      store_lex 1, "cc", P1
>
> You aren't allowed to do that. While P1 is the return continuation
> passed into C<_choose> it's not (or may be not) in P1 during the whole
> function body. That's not guranteed. It's guranteed that returning from
> the sub will use this continuation, that's all.
> You can't assume any fixed PASM register for some PIR item.
>
> WRT RetContinuation vs Continuation - they are still not the same. I'll
> try hard to keep the distinction that RetContinuations are only used
> once (which your program seems not to do). Having that distinction would
> give us more then 50% speed up in plain function (and method) calls.
>
> You can turn off this distinction in src/objects.c:782 with
>
>   #define DISBALE_RETC_RECYCLING 1
>
> or pass to _choose a real Continuation PMC in P1.
>
> (the program still fails, but now differently, I'll have a closer look
> at it tomorrow)

Okay, I fixed it (and slowed it down dramatically) by removing Return
Continuations and getting rid of the stack freelist (you can't stick a
stack frame on the freelist just because you've popped it, there might
be a continuation still looking at it). Honestly, with one item per
chunk, immutable stacks, there really is no point in having a special
case RetContinuation, you just need to maintain a continuation freelist.

I'm going to go through the DOD stuff to see about adding continuation
and stack chunk free lists to the interpreter structure. Then when the
DOD finds dead stack chunks or continuations during the course of its
job, it just shoves 'em onto the appropriate free list and carries on
its way. The new_return_continuation_pmc and new_stack_chunk or
whatever they're called can pull structures off the appropriate free
lists. 

Also, if stack chunks get garbage collected, which they should be,
there's little point in having a doubly linked stack (you can't have
'prev' link back to a free stack frame because the stack is actually a
tree).

Reply via email to