RE: extra space on stack allocated for recursive functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Meyer wrote: 

> I noticed that when I call a recursive function there is extra space
> allocated on the stack.

You mean this subl, say?

>	subl	$12, %esp
>	pushl	$3
>	call	factorial

It's keeping the stack pointer 16-byte aligned. If you passed two arguments
it would have subled $8 first, etc. This isn't unique to recursive
functions.

Why? It's probably so you can get all the arguments in a single L1 cache
load or something. I'd guess it's in the Intel's optimisation guide,
downloadable as part of the architecture docs.

Rup.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux