5 ms·
Static binary translation is relatively straightforward until you start doing indirect jumps (function pointers, C++ vtables, etc), then all hell breaks loose.
by Scaevolus 5y ago
Static binary translation is relatively straightforward until you start doing indirect jumps (function pointers, C++ vtables, etc), then all hell breaks loose.
At that point, the translator has to know precisely where the jump might go, and it becomes a total mess. Function pointers get encoded as data all the time, and you'd need to properly translate every address. Simple programs might not run into it, but telling users "sorry, we only support translating programs too simple for you to care about running" is not a good experience.
On the other hand, dynamic recompilation lets you easily hook indirect function calls to translate whatever new function is accessed on demand, and lets you reach really high compatibility.
- DeathArrow 5y agoThanks, that explained well, why it isn't done.
- astrange 5y ago> Static binary translation is relatively straightforward until you start doing indirect jumps (function pointers, C++ vtables, etc), then all hell breaks loose. It's not even possible on x86 with only static jumps, because you can jump into the middle of an instruction and turn it into a different one.
- colejohnson66 5y agoHow does Rosetta handle it? Has anyone tested jumping into the middle of an instruction on an M1 Mac?
- astrange 5y agoIt probably falls back to JIT, just like if you started doing self-modifying code. This isn't a common case, it's more for code golf and malware.
- Scaevolus 5y agoYou handle that by creating a new basic block.