From b617d1b8eab5791784a4722afc253a5f85bba475 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Fri, 15 Feb 2019 17:44:34 +0100 Subject: [PATCH] :art: push switch map on the stack --- src/emit/emit.c | 3 +++ src/lib/instr.c | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index e0abb389..5607d957 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1168,6 +1168,9 @@ ANN static m_bool emit_switch_instr(const Emitter emit, Instr *instr) { CHECK_BB(emit_exp(emit, e, 0)) *instr = emit_add_instr(emit, SwitchIni); (*instr)->m_val = (m_uint)switch_vec(emit->env); + } else { + const Instr instr = emit_add_instr(emit, RegPushImm); + instr->m_val = (m_uint)switch_map(emit->env); } return GW_OK; } diff --git a/src/lib/instr.c b/src/lib/instr.c index 4ee856b7..3702658b 100644 --- a/src/lib/instr.c +++ b/src/lib/instr.c @@ -43,10 +43,9 @@ INSTR(SwitchIni) { } INSTR(BranchSwitch) { GWDEBUG_EXE - const m_uint offset = *(m_uint*)instr->ptr; - POP_REG(shred, SZ_INT + offset); - const Map map = !offset ?(Map)instr->m_val2 : *(Map*)REG(0); - shred->pc = map_get(map, *(m_uint*)REG(offset)); + POP_REG(shred, SZ_INT*2); + const Map map = *(Map*)REG(0); + shred->pc = map_get(map, *(m_uint*)REG(SZ_INT)); if(!shred->pc) shred->pc = instr->m_val; } -- 2.43.0