Leopold Toetsch writes:
> Luke Palmer <[EMAIL PROTECTED]> wrote:
> > In the spirit of getting real continuations working Just Right, this
> > modifies IMCC's PCC implementation to emit the updatecc *after* the
> > pushtop, so that the redundant pushtop isn't necessary when returning
> > with a real continuation.
>
> The PCC shortcuts in imcc only deal with normal Sub calls (Sub and
> Closure, Coroutines should be ok too). Full Continuations currenty need
> some hints by the programmer.
>
> Do you have an example what do you want to achieve?
Yep. For instance:
.sub _main
savetop # [1]
newsub $P0, .Continuation, ret
newsub $P1, .Closure, _other_sub
.pcc_begin
.pcc_call $P1, $P0
ret:
.pcc_end
end
.end
(And we'll assume that I really did need a real continuation here)
The savetop in [1] is redundant with the one that's called right before
invokecc. The latter is not necessary, and is just wasting time copying
over a COW stack. By swapping the positions of savetop (the one
generated by IMCC) and updatecc, the savetop may be called only once.
> > I'm also thinking that updatecc should cow_copy_context, not
> > save_context. Right?
>
> No, a RetContinuation is never changed, it has a copy of the
> interpreters context, which is restored on sub return.
Hmm, in that case, maybe swapping the roles isn't a good idea. You
might get a stack frame on top that belongs to the continuation but is
_not_ marked COW. Dangerous, indeed.
I'm not sure it's correct to assume that updatecc only applies to
RetContinuations.
Luke