Compiled Stack Operation

A compiled stack is one or more areas of memory that are designated for automatic storage duration objects. Objects allocated space in the compiled stack are assigned a static address which can be accessed via a compiler-allocated symbol. This is the most efficient way of accessing stack-based objects, since it does not use a stack pointer.

Functions which allocate their stack-based objects in the compiled stack will not be reentrant, since each instance of the functions’ objects will be accessed via the same symbols (see Interaction between Assembly and C Code). Memory in a compiled stack can be reused, just like that in a conventional software stack. If two functions are never active at the same time, then their stack-based objects can overlap in memory with no corruption of data. The compiler can determine which functions could be active at the same time and will automatically reuse memory when possible. The compiler takes into account that interrupt functions, and functions they call, need their own dedicated memory (see also Function Duplication).

The size of the compiled stack can be determined at compile time, so available space can be confirmed by the compiler.