3 ms·
By definition, everything on the heap got where it is dynamically, so the minimum number of pointers to chase to find it is 1. In contrast, what’s where on the
by twoodfin 3y ago
By definition, everything on the heap got where it is dynamically, so the minimum number of pointers to chase to find it is 1.
In contrast, what’s where on the stack can often be (and often must be) known statically by the compiler and accessed directly, even moved entirely out of memory and into a register. (It’s possible to do this with suitably constrained dynamic allocations, but the optimization is much harder.)
- cdcarter 3y agoSome architectures (e.g. the 65816, the 6502's "big brother" used in the Apple IIgs) include stack pointer relative addressing modes, which will complete the memory read and return data faster than the same instruction with a full address encoded.