Rosetta 2 explained

(This is my assumption on how Apple's new Rosetta 2 works.)

Rosetta 2 is not an emulator. It is a compiler that translates from one instruction set to another. This translation is part of the process where code and libraries are loaded into caches. Most likely Rosetta 2 is integrated into the dynamic linker dyld.

The compiled code should execute at nearly native speed. Microsoft has a similar system for its Windows 10 ARM version. It works both ways; ARM apps can be executed on Intel PCs.

The translation maps instructions and registers from one instruction set architecture to another. It is easy to compile from a limited instruction set to a more advanced instruction set. The Windows 10 implementation is good at translation 32-bit x86 and ARM core to 64-bit processors. It may not be able to translate 64-bit code.

Apple has depreciated 32-bit apps, so I believe Rosetta 2 should be able to handle 64-bit code. One way of making this possible might be to limit compiler output to a common subset of instructions and registers. (This may be one reason why Big Sur does not use AVX instructions.)

I believe the most difficult part in instruction set translation would be compiling from Big-Endian to Little-Endian code and vice versa. The compiler would need to know the semantics of the data. Luckily both Intel x86 and ARM are Little-Endian. PowerPC is is Big-Endian, which might have made translating from PPC to Intel difficult.

***

From the Microsoft site:

"x86 emulation works by compiling blocks of x86 instructions into ARM64 instructions with optimizations to improve performance. A service caches these translated blocks of code to reduce the overhead of instruction translation and allow for optimization when the code runs again. The caches are produced for each module so that other apps can make use of them on first launch."

Originally posted to Facebook on June 23, 2020. Posted here and backdated on December 28, 2020.

Comments

Popular posts from this blog

How to Atiflash on a Mac Pro without Windows or boot screen

The Paradox Machine

Is the Southbridge Dead?