Ok, I have just refined the "symbol garbage collector" so it handles
a couple of things it didn't before. I think this can only result
in removing even more symbols than before so it won't
solve the problem with nbody that a whole swag of code
is removed that shouldn't be. But it increases my confidence
that the algorithm is right, and that the real problem is
replacing variable references with their values when they're
used in an assignment.

Assignment of tuples/arrays in Felix is handled by a special
algorithm which does "parallel assignment optimisation".
This could be at fault, as well as the general lazy evaluation
code.

Basically parallel assignment optimises code like:

        a,b,c = b + 1, c, a

to use the minimum number of temporaries. By default
you have to do this:

        tmp0 = b + 1
        tmp1 = c
        tmp2 = a
        a = tmp0
        b = tmp1
        c = tmp2

Parallel assignment is vital, not for assignments, where it doesn't do
much, but for tail recursion optimisation. In that case we're re-assigning
new values to the function parameters and jumping to the start of the
function, instead of recursing. The number of temporaries used is absolutely
vital if one of the RHS calculations is itself recursive, since those 
temporaries
use up space on the stack, and hence in the cache, and for a deep recursion,
this means memory gets hit earlier, the more stack space that is wasted.

In the example we can do this:

        tmp = a
        a = b + 1
        b = c
        c = tmp

so one temporary is required, rather than three. The order of
evaluation matters too.


--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to