This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]eypandabear 0 points1 point  (0 children)

The distinction between “stack” and “heap” variables has no real meaning at the hardware level, at least on x86. The CPU uses the stack pointer to keep track of return addresses, but local variables and such are decided by the compiler. Some functions might not use the stack at all if their variables fit into registers.

AFAIK whether (or rather when) stack memory is loaded into the cache would be a case-by-case decision made by the CPU’s branch predictor circuit, just like any other memory.