Menu

Post image 1
Post image 2
Post image 3
Post image 4
Post image 5
1 / 5
502

The time the x86 emulator team found code so bad that they fixed it during emulation - The Old New Thing

#devblogs#code#memory#loop#initialize#windows
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More