Skip to content

Commit 71b41e4

Browse files
committed
Reduce number of JS <-> WASM jumps in core CPU loop
Similar to mihaip/dingusppc@d0ff52d, the use of setjmp/longjmp was leading to a lot of js-to-wasm and wasm-to-js due to invoke_vii. Move the inner loop to a separate non-inlined function. Reduces the boot times for NeXTSTEP 3.3. Likely some of the longer pauses are due to network and I/O timeouts, the CPU bound parts to feel a lot snappier. Before After Show ROM Monitor Window 3s 1s Show boot command 5s 2s Begin OS boot 14s 7s Hide OS boot window 50s 42s Workspace rendered 60s 49s
1 parent f45a747 commit 71b41e4

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

src/cpu/newcpu.c

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6273,23 +6273,18 @@ static void m68k_run_mmu060 (void)
62736273

62746274
#ifdef CPUEMU_31
62756275

6276-
/* Aranym MMU 68040 */
6277-
static void m68k_run_mmu040 (void)
6278-
{
6279-
struct flag_struct f;
6280-
int halt = 0;
6281-
6282-
check_halt();
6283-
#ifdef WINUAE_FOR_HATARI
6284-
Log_Printf(LOG_DEBUG, "m68k_run_mmu040\n");
6276+
static
6277+
// Don't inline this function under Emscripten, otherwise we will end up with
6278+
// very inefficient code generation due to the setjmp call in the parent
6279+
// ppc_exec() function.
6280+
#ifdef EMSCRIPTEN
6281+
__attribute__((noinline))
62856282
#endif
6286-
6287-
while (!halt) {
6288-
check_debugger();
6289-
TRY (prb) {
6283+
void m68k_run_mmu040_inner(struct flag_struct *f)
6284+
{
62906285
for (;;) {
6291-
f.cznv = regflags.cznv;
6292-
f.x = regflags.x;
6286+
f->cznv = regflags.cznv;
6287+
f->x = regflags.x;
62936288
mmu_restart = true;
62946289
regs.instruction_pc = m68k_getpc ();
62956290

@@ -6313,6 +6308,24 @@ static void m68k_run_mmu040 (void)
63136308
}
63146309
}
63156310
}
6311+
}
6312+
6313+
6314+
/* Aranym MMU 68040 */
6315+
static void m68k_run_mmu040 (void)
6316+
{
6317+
struct flag_struct f;
6318+
int halt = 0;
6319+
6320+
check_halt();
6321+
#ifdef WINUAE_FOR_HATARI
6322+
Log_Printf(LOG_DEBUG, "m68k_run_mmu040\n");
6323+
#endif
6324+
6325+
while (!halt) {
6326+
check_debugger();
6327+
TRY (prb) {
6328+
m68k_run_mmu040_inner(&f);
63166329
} CATCH (prb) {
63176330

63186331
if (mmu_restart) {

0 commit comments

Comments
 (0)