From: Jérémie Astor Date: Tue, 16 Nov 2021 20:55:36 +0000 (+0100) Subject: :bug: Fix literal dicts with non SZ_INT keys X-Git-Tag: nightly~407 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=2941c60f4730cbc87be80ecb2e1cb55e79d77e5d;p=gwion.git :bug: Fix literal dicts with non SZ_INT keys --- diff --git a/include/opcode.h b/include/opcode.h index 571b9196..356216dd 100644 --- a/include/opcode.h +++ b/include/opcode.h @@ -18,6 +18,7 @@ enum { eRegPushBase4, eReg2Reg, eReg2RegOther, + eReg2RegOther2, eReg2RegAddr, eReg2RegDeref, eStructMember, @@ -234,6 +235,7 @@ enum { #define RegPushBase4 (f_instr)eRegPushBase4 #define Reg2Reg (f_instr)eReg2Reg #define Reg2RegOther (f_instr)eReg2RegOther +#define Reg2RegOther2 (f_instr)eReg2RegOther2 #define Reg2RegAddr (f_instr)eReg2RegAddr #define Reg2RegDeref (f_instr)eReg2RegDeref #define StructMember (f_instr)eStructMember @@ -535,6 +537,12 @@ ANN static inline void dump_opcodes(const VM_Code code) { gw_out(" {-M}%-14"UINT_F"{0}", instr->m_val2); gw_out("\n"); break; + case eReg2RegOther2: + gw_out("{Y}┃{0}{-}% 4lu{0}: Reg2RegOther2", j); + gw_out(" {-R}%-14"UINT_F"{0}", instr->m_val); + gw_out(" {-M}%-14"UINT_F"{0}", instr->m_val2); + gw_out("\n"); + break; case eReg2RegAddr: gw_out("{Y}┃{0}{-}% 4lu{0}: Reg2RegAddr ", j); gw_out(" {-R}%-14"UINT_F"{0}", instr->m_val); diff --git a/opcode.txt b/opcode.txt index 460f60a6..38966b4e 100644 --- a/opcode.txt +++ b/opcode.txt @@ -15,6 +15,7 @@ RegPushBase3~p RegPushBase4~p Reg2Reg~u~u Reg2RegOther~u~u +Reg2RegOther2~u~u Reg2RegAddr~u~u Reg2RegDeref~u~u StructMember~u diff --git a/src/emit/emit.c b/src/emit/emit.c index 255caed3..ccb7e4d1 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -695,7 +695,7 @@ ANN static m_bool emit_prim_dict(const Emitter emit, Exp *data) { instr->m_val2 = -SZ_INT - val->size; regpush(emit, SZ_INT); } else { - const Instr instr = emit_add_instr(emit, Reg2RegOther); + const Instr instr = emit_add_instr(emit, Reg2RegOther2); instr->m_val = -key->size; instr->m_val2 = key->size; regpush(emit, key->size); diff --git a/src/vm/vm.c b/src/vm/vm.c index 2ada2d4c..f125e9ba 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -450,7 +450,7 @@ vm_run(const VM *vm) { // lgtm [cpp/use-of-goto] &®setimm, &®pushimm, &®pushfloat, &®pushother, &®pushaddr, &®pushmem, &®pushmemfloat, &®pushmemother, &®pushmemaddr, &®pushmemderef, &&pushnow, &&baseint, &&basefloat, &&baseother, - &&baseaddr, &®toreg, &®toregother, &®toregaddr, &®toregderef, + &&baseaddr, &®toreg, &®toregother, &®toregother2, &®toregaddr, &®toregderef, &&structmember, &&structmemberfloat, &&structmemberother, &&structmemberaddr, &&memsetimm, &&memaddimm, &&repeatidx, &&repeat, &®pushme, &®pushmaybe, &&funcreturn, &&_goto, &&allocint, @@ -584,6 +584,9 @@ vm_run(const VM *vm) { // lgtm [cpp/use-of-goto] regtoregother: memcpy(*(m_bit **)(reg - SZ_INT), reg + IVAL, VAL2); DISPATCH() + regtoregother2: + memcpy(reg - VAL2, reg + IVAL, VAL2); + DISPATCH() regtoregaddr: *(m_uint **)(reg + IVAL) = &*(m_uint *)(reg + IVAL2); DISPATCH()