On Nov 28, 2004, at 2:48 AM, Piers Cawley wrote:

I just thought of a heuristic that might help with register
preservation:

A variable/register should be preserved over a function call if either of the
following is true:


1. The variable is referred to again (lexically) after the function has
   returned.
2. The variable is used as the argument of a function call within the
   current compilation unit.

That doesn't solve it, though you'd think it would. Here's the counter-example:


        x = 1
        foo()
        print x
        y = 2
        return y

You'd think that x and y could use the same memory location (register, variable--whatever), since ostensibly their lifetimes don't overlap. But continuation re-invocation can cause foo() to return multiple times, and each time it should print "1", but it won't if x and y use the same "slot" (it would print "2" each time after the first). In truth, their lifetimes do overlap, due to the hidden (potential) loops created by continuations.

The problem isn't preservation across calls per se, it's the implicit loops. Continuations are basically gumming up tons of potential optimizations.

JEff



Reply via email to