3 ms·
Rosetta is an emulator, that is correct. It consists of both an ahead-of-time translator that does fairly straightforward conversion of x86 code into ARM, albei
by saagarjha 5y ago
Rosetta is an emulator, that is correct. It consists of both an ahead-of-time translator that does fairly straightforward conversion of x86 code into ARM, albeit with a 1-to-1 mapping between registers rather than following AAPCS or any standard calling convention. At runtime, if new code is generated (e.g. a JIT compiler) it’s run through what’s essentially a runtime version of this process. Self-modifying code is detected on write (code page is marked as read-only if it looks like it’s code, and the write faults and indicates the page should be marked with read-write permissions) or indirect branch (code has been written out and needs to be executed, so page is translated and flipped back to read-only). Calling into arm64 code directly is not possible without thunks due to the mismatched ABI. The system libraries are actually provided as a translated shared cache, rather than being mapped in as “normal” code.
- xmodem 5y agoFascinating. Where can I read more about how it works?
- saagarjha 5y agohttps://ffri.github.io/ProjectChampollion/ https://ffri.github.io/ProjectChampollion/ is a good high-level resource. Random details are mostly strewn about the internet in a bunch of tweets and Discord messages that are hard to collate, so you’ll probably have better luck just asking your question than trying to piece that together.
- deleted 5y ago[deleted]