I wrote:
> >I had guessed that the preamble of the procedure would allocate a stack
> >frame big enough for all of the local variables
and Aleksandar Donev <[log in to unmask]> wrote:
> But if you are using large arrays (as I expect you do), how is the
> procedure to allocate a stack space large enough? Besides, that would
> not speed the program up--stack space is also allocated/deallocated each
> time the procedure is called. If you can move the arrays outside of the
> interpolation routine (or make them saved), at least the cost of
> allocation/deallocation will be amortized?
The arrays aren't large -- but the processor can't know that in advance.
If in fact the arrays are allocated within the stack frame of the procedure,
I would expect one allocation for the entire stack frame, with the addresses
of the arrays in the stack frame computed after the allocation is done,
rather than one allocation per array.
Making the arrays saved variables was an alternative I considered. They
might be different sizes on each call, so I planned to inquire whether
they were big enough, and if not deallocate and reallocate them. Then
just use the amount necessary during the calculation.
But since the stack frame has to be allocated anyway, it ought to be cheaper
than to make the arrays saved variables.
|