Local variable allocation is up to the compiler. Obviously most local
variables can be allocated on the stack, but the compiler will make
sure that they are heap allocated if they need to be. (And taking the
address will trigger a heap allocation in 6g I believe, although 6g
might get smarter about this in the future.)
> What is the structure of stack then?
The stacks are heap-allocated and non-contiguous in memory. Each
function has a prelude that checks that there is enough stack space
remaining and allocates more if need be.
> Another issue is array allocation. Is array allocated on stack?
It might be. See above.
AGL
I think that the current, simple-but-it-works heuristic is that if you
ever have a pointer to something, the compiler ensures that the thing
pointed to is from the heap, not the stack. This may get tighter in
the future, with escape analysis.