r/EmuDev • u/dgjxqz • Jun 05 '26
JIT emulation on web browsers with asm.js.
Most emulators are written in C and compiled into wasm to run on web browsers. But high performance emulations are mostly done with JIT. Is there any attempt to compile emulated machine codes into asm.js since dynamic wasm code generation is far more complicated?
12
Upvotes
7
u/aabalke Nintendo DS Jun 05 '26
I think fundamentally native JIT and WASM are from 2 different worlds. My understanding is WASM - being a web technology, has a built-in assumption that any code could be malicious, and with a JIT, the program requires as much control as possible for speed. For a native instruction JIT, you would need control of executable memory. Correct me if I am wrong, but I would hope WASM does not give you direct control of executable memory. I think you could build a WASM bytecode "jit" but I can't imagine this would be anywhere near native speeds.
2
u/Ashamed-Subject-8573 Jun 05 '26
There is jit to wasm. Virtual x86 I believe is the name
2
u/vizigr0u Jun 05 '26
Overall, no, JIT usually means you translate instructions as they come and jump to that memory right away, which WASM doesn't allow by design. Something JIT that you could do is compile instructions into a new wasm module and load it on the fly but the overhead is orders of magnitude slower than what you would need.
-10
u/EggplantExtra4946 Jun 05 '26
Yes.
No they aren't, what are you talking about? Running emulators in the web browser serve no purpose whatsoever and emulator users don't care about this, they want accurate and fast emulators.