3 ms·
> The variables on the stack are the most efficient after registers Why are variables on the stack more efficient than other memory accesses?
by roperj 4y ago
> The variables on the stack are the most efficient after registers
Why are variables on the stack more efficient than other memory accesses?
- MobiusHorizons 4y agoThe top of the stack should generally be already present in the cache, so stack memory would be faster than heap memory where objects aren’t necessary as close together or accessed as frequently.
- xgkickt 4y agoRegister renaming. Stack references are more likely to be in the register file.
- menaerus 4y agoI am not familiar with any other reason besides the fact that stack-pointer arithmetics are done through a dedicated HW, called stack-engine, which sits in the CPU frontend. This effectively means that stack-pointer uOps are going to be get executed quicker because they do not have to go all the way through the CPU backend processing. This also saves some of the bandwidth on the CPU backend side allowing other uOps to be processed sooner.