Stack

LIFO: Stores values in the order it gets them, removes values in opposite order.

All values stored have a known size at compile time. For instance int, str, bool etc…

We also store references to heap, these also are known size at compile time.

Faster than storing to heap, don’t need to find location since it is always at top of the stack.

When code calls a function, the values are passed into the function, including pointers to data on the heap.

The function’s local variables get pushed onto the stack.

Stack frame

Stack pointer

Frame pointer

References: