3 ms·
>Rosetta 2 is not emulation, at all, it's AOT, static binary translation, backed by hardware that implements Intel specific behaviour from the latest chips down
by KptMarchewa 4y ago
>Rosetta 2 is not emulation, at all, it's AOT, static binary translation, backed by hardware that implements Intel specific behaviour from the latest chips down to the oldest 8080 or something.
So, it is hardware emulation.
- brookst 4y agoNo. Imagine you only speak English and you want to read a novel in French. Emulation: you hire a translator to read the novel to you. They translate each word while reading. Static translation: you hire a translator to transcribe the book from French to English. They give you a printed book purely in English. But simple French words like flâner and râler are expanded into lengthy passages because there is no simple English translation. Rosetta 2: you hire the translator to transcribe the book to English, but they leave in unique French words and teach you what they mean so you can understand them in an English phrase without even noticing that the word isn’t “real” English. Rosetta 2 isn’t emulation because no instruction is translated on the fly to a different ISA. It’s static translation plus ISA extensions. There is no lower level emulating anything.
- less_less 4y agoAs a slight correction, I believe Rosetta 2 also has a JIT mode, which is a bit more like conventional emulators. But it's used infrequently, eg when dealing with x86_64 apps that themselves use a JIT.
- lloeki 4y ago> I believe Rosetta 2 also has a JIT mode It does have JIT translation (not a JIT "mode" though, as it always use AOT translation, only relying on JIT translation at runtime for the parts that need it) > which is a bit more like conventional emulators Not at all†, Rosetta 2 does the same†† translation step on dynamic Intel code, whose arm64 output can be reused afterwards > But it's used infrequently, eg when dealing with x86_64 apps that themselves use a JIT Yes, although it's more like "exceedingly rarely" in practice since usually those interpreters are up to date enough to have a native arm64 release. See there for details: https://dougallj.wordpress.com/2022/11/09/why-is-rosetta-2-fast/ https://dougallj.wordpress.com/2022/11/09/why-is-rosetta-2-f... † Unless you've been meaning dynarec, but I would not call that "conventional" although it is a well-known technique https://en.wikipedia.org/wiki/Dynamic_recompilation https://en.wikipedia.org/wiki/Dynamic_recompilation †† IIUC minus a few things that can't be done when just-in-time because some assumptions are not guaranteed to be satisfied.
- brookst 4y agoThanks, that is definitely correct. Rosetta 2 can do JIT, and it gets exercised for native JIT / dynamic code. I could probably extend the metaphor to an avant garde French novel that asks the reader to look up and include today’s headlines from Le Monde, but it was already stretched.
- lloeki 4y ago>> implements Intel specific behaviour from the latest chips down to the oldest 8080 or something. > So, it is hardware emulation. It's more like there's a full Intel CPU in disguise, only with instructions and registers having another name.