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 13, 2004 19:20
Re: Continuations, basic blocks, loops and register allocation
Message ID:

On Sat, 13 Nov 2004 17:35:02 -0800, Jeff Clites <> wrote:
> Not all variables, but due to Leo's case (2), it should be all
> variables which are referenced after the first function call out of a
> subroutine, if there's a later function call; for instance, consider:
> ...
> foo();
> a = 10;
> b = 12;
> ... use a and b
> bar();
> ... never use a or b again
> c = 1;
> d = 2;
> ... use c and d
> baz();
> ... never use c or d again
> zoo();
> Normally, the lifetime of a and b would end at the call to bar, and
> that of c and d would end at the call to baz, but due to continuations,
> the call to zoo might resume at the op right after the call to foo
> (since the continuation created when calling foo may have been
> captured), so a,b,c,d have to persist at least until the last function
> call is made.

Yes, but in the case of the continuation resuming after foo, the
continuation should restore the frame to the point where it was taken.
 Thus all of the registers will be exactly as they were when the
continuation was taken (i.e. in the correct place).  Thus, it does not
matter if we reuse a register later in the function, the continuation
will restore the proper context for itself.

Exceptions handlers, on the other hand, are a different story, because
anything that is used in the catch block must be kept in the correct
place through out the entire try block.  However, the allocator will
figure this out for itself if we provide it the branch information. 
Another reasonable option is to mandate that the exception handler
starts without any preconception about the register contents and
fetches everything as needed.  This means that only lexicals can be
used in the handler, but it is a slightly softer requirement then only
lexicals everywhere.

"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