Theseus: Translating Win32 to WASM
2 days ago
- #win32 emulation
- #blocking synchronization
- #WebAssembly
- Theseus is a win32/x86 emulator that now generates WebAssembly output, enabling .exe files to run on the web, though it has bugs.
- The main challenge in translating to WebAssembly was handling blocking behavior, as WebAssembly on the main thread cannot block; this is resolved using web workers and shared memory with atomics for synchronization.
- Design decisions include using synchronous emulation with real OS threads for better debugging and performance, contrasting with an earlier asynchronous approach that had control overhead.
- The implementation uses a 'Host' API abstraction for cross-platform compatibility (SDL and web), with TypeScript for the web host due to better tooling and DOM interaction compared to WebAssembly.