develooper Front page | perl.perl6.internals | Postings from November 2004

Re: Continuations, basic blocks, loops and register allocation

Thread Previous | Thread Next
Matt Fowles
November 16, 2004 06:24
Re: Continuations, basic blocks, loops and register allocation
Message ID:

On Tue, 16 Nov 2004 09:23:24 +0100, Leopold Toetsch <> wrote:
> Matt Fowles <> wrote:
> [ continuations should restore registers ]
> > I am sorry, but I don't understand what you are trying to say here.
> > Would you mind rewording it for me?
> Imagine a simple loop:
>     i = 0
>   lp:
>     foo()
>     inc i
>     if i < 10 goto lp
> Looking at the loop counter a programmer or optimizer could easily
> decide that using an I-Reg for it instead of a P-Reg is fine. Now comes
> your proposed implementation for continuations: they copy the register
> frame on creation and restore it on invocation. Besides of the big cost
> of the memcpy's this simple loop above suddenly stops working, depending
> on the implementation of foo() - which might be outside your control.
> BTW in an early stage we had exactly this behavior of continuations.
> This was abandoned. The subject was IIRC something like "Should
> continuations close over registers". The answer was clearly "no".

There is one thing I am not sure about here.  The loop will work
correctly for each seperate invocation of the appropriate
continuation.  The first time you call foo i is 0.  The second time i
is 1.  If foo ever invokes the full continuations that it captured at
one of these points, then i will go back to whatever it was when that
continuation was captured.  All of this seems like reasonable behavior
to me.  In the general case our optimizer will not be able to downgrad
i from a P to an I register anyway, as foo could mess with $CALLER::i
or whatever.  Thus, I am not sure that I by your argument.

"Computer Science is merely the post-Turing Decline of Formal Systems Theory."

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About