upvote
I guess one could call it a "bare-metal/type 1 emulator" much like VMs can run in a "bare-metal/type 1 hypervisor".
reply
"An ahead-of-time and just-in-time compiler translates arm64e code to x86-64."

No, not the same, actually. It's more of a Rosetta, but other way round, if I understand this right.

reply
Rosetta is an emulator (or, I suppose, a series of emulators), i.e. a piece of software that makes a computer pretend to be another kind of computer. This is also a bit of lower level software that makes a (x86_64) computer pretend to be a different kind of computer (aarch64), in this case, by AoT and JIT translation, though that's an implementation detail. What distinction are you trying to make?
reply
This doesn't emulate a computer so that code in another architecture can run, it translates the other architecture'a code to native code. It's a small difference, but I guess it is a difference.
reply
Is this not how qemu works? Is rosetta not considered an emulation layer? For all its name suggests otherwise, I would certainly refer to wine as an emulator, and it also uses these techniques.
reply
Not to be That Guy, but WINE doesn't use those techniques, and thus isn't an emulator.

It lightly translates binary formats (Windows executables) into Linux-compatible executable code, and then runs that code against libraries that implement Windows APIs in terms of Linux underneath. It's not an emulator in the same way that your libc isn't emulating lockf(3) in terms of fcntl(2) underneath. In web-dev parlance, we'd call WINE a polyfill.

Rosetta and QEMU on the other hand are emulators--emulators, in this instance, being a term of art that implies interpreting bespoke meaning from machine code instructions written in another program. Some emulators translate instructions 1:1, some have optimized stencils, some (like Rosetta) have kernel support for emulating very quickly, and some (maybe like Rosetta; sources disagree) also have hardware support as well.

reply
WINE emulates an ABI, rather than a CPU or such, but I'd happily argue that that's an emulator. (In fairness, though it's not generally described that way, I would call web polyfills API emulation)
reply
It implements an ABI.

It "emulates a behaviour" and natural language is fluid, so sure, you could call WINE an emulator and I wouldn't be mad at you. But WINE is very different compared to what most emulators are. Usually the term is reserved for when you emulate in software what used to be hardware.

reply
Wine as a polyfill makes so much more sense
reply
I believe WINE doesn't actually translate any instructions; it's a Windows PE loader and a bunch of libraries that implement Windows APIs using Linux equivalents.
reply
How does it handle stuff like syscalls without altering the executed code?
reply
Windows apps don't use syscalls directly; they call into kernel32.dll, which is convenient for Wine. (Microsoft enforces this by scrambling the syscall numbers on OS updates [1].)

[1]: https://j00ru.vexillium.org/syscalls/nt/64/

reply
Huh, now I know. I suppose macos is the same way these days even if you can technically bypass it.
reply
Yes. Linux is the only major operating system where there is even a convention to directly access system calls. For macOS, everything goes through libSystem.
reply
It installs handlers. I don't have the exact name but there's support in the kernel to redirect syscalls to a Userland process
reply
https://www.phoronix.com/news/Wine-11.5-Released

"SUD" Syscall User Dispatch feature in Linux 5.11 +

reply
> It lightly translates binary formats (Windows executables) into Linux-compatible executable code,

Does this not involve transpilation? I guess I was grouping that in under dynamic recompilation and AOT techniques.

Regardless, I don't think that there's a benefit from defining emulation from an implementation rather than an empirical perspective. If it runs a chunk of code as if it were in a different environment, I'm kind of ok to call it an emulator. To the sibling's point, a polyfill would also fit as an emulation layer here.

reply
Not necessarily. It could just rewrite the outer portion to be an ELF loader that then calls into a runtime that actually shims the syscalls for example. I don't think WINE does exactly this but it's not really transpiling either.
reply
You don't even need that, really; just have wine load the PE binary into memory and hand it a bunch of DLLs that use Linux syscalls under the hood. It's less transpiler and more of a funky dynamic linker+loader plus libraries.
reply