On 2011-01-20, at 9:15 PM, Bradley Lucier wrote:
Marc:
I don't know why, but I got looking at the compiled code for fib, and it seems to use much more stack space than needed, 8 words per invocation, which seems counter-intuitive to me; is there a problem with the compiler? I'm using the latest git compiler.
Brad
The frame size (8 words) can be explained by the constraints on the frame in order to implement continuations efficiently. Specifically, the frames are aligned on multiples of 4 words and the last 3 slots of the frame are reserved for linking frames explicitly (these slots are only touched when the frames are captured by a call/cc and live when the GC runs).
In the case of fib, there are 2 live slots when the frame must be constructed for the recursive call. But because 3 extra slots must be reserved, that makes 5 slots. But this has to be rounded up to a multiple of 4, so that gives 8 slots.
Marc