Skip to content

Commit c1e06dc

Browse files
committed
Fix very slow emulation speed under Emscripten
The use of setjmp/longjmp to handle PPC exceptions results in WASM <-> JS jumps in generated Emscripten code. This should be fine (because there are not a lot of exceptions), but for reasons that I don't fully understand, we were crossing that boundary for every single instruction. Work around this by not allowing ppc_exec_inner to be inlined, which adds another function on the callstack and appears to keep the execution entirely on the WASM side. Timing of booting the 7.1.2 Disk Tools floppy: Before After Happy Mac 43s 17s Welcome to Power Macintosh 62s 24s Desktop Appears 100s 38s Finder is running 192s 70s
1 parent f16b81e commit c1e06dc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cpu/ppc/ppcexec.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,14 @@ void force_cycle_counter_reload()
321321

322322
/** Execute PPC code as long as power is on. */
323323
// inner interpreter loop
324-
static void ppc_exec_inner()
324+
static
325+
// Don't inline this function under Emscripten, otherwise we will end up with
326+
// very inefficient code generation due to the setjmp call in the parent
327+
// ppc_exec() function.
328+
#ifdef EMSCRIPTEN
329+
__attribute__((noinline))
330+
#endif
331+
void ppc_exec_inner()
325332
{
326333
uint64_t max_cycles;
327334
uint32_t page_start, eb_start, eb_end;

0 commit comments

Comments
 (0)