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 12:04
Subject:
Re: Continuations, basic blocks, loops and register allocation
Message ID:
200411161943.iAGJhcK31475@thu8.leo.home
Jeff Clites <jclites@mac.com> wrote:

> sub B
> {
> 	a = 1
> 	foo()
> 	print a
> 	b = 2
> 	return b
> }

> If something called by foo() captures a continuation, and something
> invokes it after B() returns, then there's a hidden branch, in effect,
> from the return to the print, isn't there?

Yes. That's right and would cause problems. Again this is creating a
loop as you say from the return to the print statement.

OTOH looking at the scheme example, you can create such continuation
loops just for nested closures. All other usage would be like a "goto"
statement into the middle of some totally unrelated subroutine, which is
only solvable by going "the all gets refetched" road.

> But a RESUMABLE label seems like the information that's needed by the
> compiler. But on the other hand in an example like the above, the
> function B() may not be written to expect foo() to be resumed.

Yes. Again, the HLL language, that is creating the code has a clear
indication, what's going on. PIR code currently hasn't.

> ... With Scheme, it's only
> clear from the syntax what's going on locally--but you can invoke a
> continuation far from any call/cc, if that continuation was stored away
> into a variable.

So all closures inside that call/cc have to be emitted in such a way that
they can cope with it. It's IMHO nothing we can solve, except for
providing some syntax construct that clearly indicates the possible loop
for the CFG.

> JEff

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