3 ms·
I believe newer x86 actually has a set of registers that cache the top of the stack and is as fast as the other registers, but it's hard to find information abo
by userbinator 6y ago
I believe newer x86 actually has a set of registers that cache the top of the stack and is as fast as the other registers, but it's hard to find information about this feature. One of the ways in which this is visible is that using the push/pop instructions is faster than manually writing to memory at the stack pointer and then adjusting the stack pointer.
- obl 6y agoThat sounds very unlikely ? "The reason" why memory is slower than registers (apart from size obviously) is that register dependencies are static and can be easily tracked by the core. Memory is way harder since you don't know all the addresses in advance (any other random store could actually be storing to the stack). That's why they have to use costly (associative) structures like the store queue. The way cores track the stack is usually for return address prediction because it's a huge win for little cost and almost no well behaved program overwrites return addresses manually (low mispredict rate). As far as I know, all x86 cores emit 2 uops for a push or a pop (load/store + sp adjust). I guess it can save you some frontend bandwidth but that's about it.
- MaxBarraclough 6y ago> a set of registers that cache the top of the stack and is as fast as the other registers I could have sworn I'd read something like this - the 'top' words of the stack always being kept in a very low-level cache - but I was unable to find a source on it.
- recursivecaveat 6y agoThe (theoretical) MMIX architecture that Knuth books use has a register-stack.
- p_l 6y agoIt's a mechanism from few real-world RISC cpus that was used in MMIX, i.e. register windows which form a stack (RISC cpus otherwise usually didn't have a stack other than by convention). One CPU that used that approach was SPARC, although the difference is that MMIX has variable-length windows.