3 ms·
I wonder how often (golang, let's say) x, y = y, x Just becomes register renaming? What about array[i], array[j] = array[j], array[i] ?
by stcredzero 8y ago
I wonder how often (golang, let's say)
x, y = y, x
Just becomes register renaming? What about
array[i], array[j] = array[j], array[i]
?
- theoh 8y agoRegister renaming doesn't mean changing the name of registers you already have (which isn't really possible), it just adds new "virtual"/concurrent registers that conserve the semantics of operations. So what you say doesn't sound right to me: register renaming is actually a way of (re)labelling the results of small ALU jobs to be distributed for concurrent execution. It's not in any way about switching references around on live data as you suggest. Not 100% sure about this but the flavour of what I've read doesn't involve that kind of fancy footwork.
- brucedawson 8y agoIf the "x, y = y, x" is implemented using the x86 "swap" instruction then the CPU could implement the swap using register renaming, I think - with no execution unit activity required. I don't know if it does. But everything that golang (or C or C++ or whatever) does has to be expressed in assembly language, and assembly language doesn't directly control register renaming - it's a hidden implementation detail.
- stcredzero 8y agoThanks. That clarifies things.