During an exchange of war stories, a colleague of mine told one from back in the days when Windows included a processor emulator for x86-32 on systems that natively ran some other processor. (This has happened many times. And no, I don’t know which processor this particular story applied to.)
This particular emulator employed binary translation, generating native code to perform the equivalent operations of the original x86-32 code. This offered a significant performance improvement over emulation via interpreter. You can imagine that x86-32 is just a bytecode, and the emulator is a JIT compiler.
Anyway, my colleague found that there was one program that needed to allocate around 64KB of memory on the stack and initialize it. The standard way of doing this is to perform a stack probe to ensure that 64KB of memory is available, then subtracting 65536 from the stack pointer, and then initializing the memory in a small, tight loop.
But using a loop to initialize the memory was too mundane for whatever compiler was used to compile this code. Instead of generating a loop to initialize each byte of the buffer, the compiler “optimized” the code by unrolling the loop into 65,536 individual “write byte to memory” instructions, each 4 bytes long.
All in all, it took this program 256 kilobytes of code to initialize 64 kilobytes of data.
This offended the team so much that they added special code to the translator to detect this horrible function and replace it with the equivalent tight loop.
@Raymond Chen
Come on Raymond, don’t leave us hanging, shame that compiler which did infinite loop unrolling?
Thanks?
.. is it just me, or does *EVERY SINGLE ONE* or the comments – other than mine – absolutely scream “I was written by a shitty AI comment bot” or no??
Says the guy using em-dashes in his writing.
In all seriousness, though, I didn’t see anything that screams “AI” to me.
There’s a bunch of technical stuff, but that’s to be expected on a post explicitly talking about technical details.
Microsoft’s blog software coverts normal dashes to emdashes. Take a guess why Microsoft would make that change.
I wanted to write that I am surprised people in 2026 don’t understand how replies work… not that the comments seem somewhat AI-ish.
Blame the commenting website software for that one.
There’s been tons of reports of people’s comments getting added to the wrong thread, or not added to a thread at all, or being shown out-of-order.
We did this a lot in the Xbox emulator on Xbox 360. Every Ubisoft Xbox game scanned the entire DVD twice to figure out its localization; some games had multithreading or memory management bugs; no games took advantage of WriteScatter/ReadGather; so many other obvious inefficiencies and bugs. Eventually, we got it so games loaded faster in the emulator than on the original console!
So nothing has changed in terms of game optimization 😄. Even games on medium settings are bringing top-of-the-line GPUs to their knees. That being said, we greatly appreciate the efforts you all on the emulation team are doing. 🙂