2 ms·
I understand that Rosetta 2 uses static recompilation "where possible" and only falls back to dynamic when necessary. This is purely speculative but I would as
by Cu3PO42 6y ago
I understand that Rosetta 2 uses static recompilation "where possible" and only falls back to dynamic when necessary.
This is purely speculative but I would assume that it statically recompiles the __TEXT segment of binaries or maybe whatever it can easily figure out is code by following all possible jumps, etc.
Then, whenever a page is mapped as executable they could then check if this is part of a memory mapped binary which is statically recompiled or otherwise recompile the code in the page and jump to the now native version.
That way JITs should work without fully falling back to interpreting instructions. Things would get tricky when you map some memory both writable and executable, but maybe they're pushing the limits on what the spec allows for instruction caches? I'd have to check my x86 reference manual. Or maybe this is another area where they have some hardware primitive to facilitate a partial recompilation.