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

Re: Continuations, basic blocks, loops and register allocation

Thread Previous | Thread Next
From:
Leopold Toetsch
Date:
November 16, 2004 07:57
Subject:
Re: Continuations, basic blocks, loops and register allocation
Message ID:
200411161537.iAGFb4F30285@thu8.leo.home
Matt Fowles <ubermatt@gmail.com> wrote:
> Leo~

> On Tue, 16 Nov 2004 09:23:24 +0100, Leopold Toetsch <lt@toetsch.at> wrote:

>>     i = 0
>>   lp:
>>     foo()
>>     inc i
>>     if i < 10 goto lp

> There is one thing I am not sure about here.  The loop will work
> correctly for each seperate invocation of the appropriate
> continuation.

No. Imagine, foo() is not a simple function anymore. Someone e.g. Jens
Rieks[1], discovers that the algoritm is simpler implemented with
continuations. So inside foo() the return continuation of foo() is
copyied, stored elsewhere, passed along to another function, and that
one now suddenly returns via this continuation to your loop.  If this
invocation of the continuation would restore registers suddenly the loop
will become an infinite one, as C<i> is always restored to zero.

[1] Have a look at runtime/parrot/library/Streams/Sub.imc

leo

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About