Jeff Clites <[EMAIL PROTECTED]> wrote:
> On Nov 10, 2004, at 3:08 PM, Leopold Toetsch wrote:

> But, in a tail-call-optimization case, we don't need to call
> new_register_frame() and copy_regs()--ex hypothesi, we can re-use the
> register frame already in-place. That's a big savings--that's the
> optimization I'm after.

Yes. As the return and the calling conventions are the same WRT register
setup, we've function arguments already in place. We still have to copy
the context, though.

> But in light of what you say here...

>> Whenever you see a continuation "on the surface", it's one that is
>> preserving the frames and the context. Eventually there isn't even a
>> RetContinuation object but just a pointer to the calling frame. But
>> whenever you can see a continuations it's a real one

> ...it sounds like we have an easy way to tell if a "real" continuation
> has a claim on the register frame, because creating such a real
> continuation can mark the frame,

There is no such mark. If ctx->current_cont isa(RetContinuation), then
it's save to do the tail call. This OTOH is meaning that we can do the
check only at runtime. Thus the C<tailcall> or C<tailcallmethod> opcodes
have to do plain calls if they detect such a situation.

> ... (In fact that mark should be a reference
> count,

That's really not needed. If you return from the function and you call
it next time, you've again a RetContinuation. If the continuation was
created somewhere deeper in the call chain, it's gone or not after the
GC cycle. And you know - starting with refcounting one objects ends up
with refcounting containers holding that item ...

> JEff

leo

Reply via email to