[gclist] Stack allocation inneficiency.
Thu, 05 Dec 1996 10:20:09 +0000
Optimizing compilers make very wasteful
use of stack space with C.
aFun(lots, of, big, parms);
Becomes in psudo assembler
add #size_of_parms, %SP
But if this call is before the return that add at the
end is useless as the stack will be restored from a
register not arithmetic.
In general as long as the call isn't in a loop the
add will be optimized out. So we use more stack,
we reduce instruction count and increase speed.
If the compiler is smart enough to know that aFun
wont modify those parms on the stack they can even
be used from there rather than recalculate their values.
Charles Fiterman Geodesic Systems
Phone 312-728-7196 4745 N. Ravenswood Suite 111
Fax 312-728-6096 Chicago Il 60015
A computer language without garbage collection
is like a city without garbage collection.