]> Nishi Git Mirror - gwion.git/commitdiff
:bug: Fix literal dicts with non SZ_INT keys
authorJérémie Astor <fennecdjay@gmail.com>
Tue, 16 Nov 2021 20:55:36 +0000 (21:55 +0100)
committerJérémie Astor <fennecdjay@gmail.com>
Tue, 16 Nov 2021 20:55:36 +0000 (21:55 +0100)
include/opcode.h
opcode.txt
src/emit/emit.c
src/vm/vm.c

index 571b9196cb01649cbfae6e0c531c0440cd9ac4d8..356216dd6cc8d616c37d83c13aa5dc0041f5ee72 100644 (file)
@@ -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);
index 460f60a670160d6fab63754b36b62f0fc81927d8..38966b4e169f99660bdef5de8d1e79bb29aa65e5 100644 (file)
@@ -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
index 255caed3dbda85c8e131bacb1bc3098f721a3cd0..ccb7e4d1d94dcbc962a69d764479bd6362529fd8 100644 (file)
@@ -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);
index 2ada2d4c74ef6918c9a0fed5e93b3ffbbfa05260..f125e9bae5190b5d76ac92f9ea4f1085a20924be 100644 (file)
@@ -450,7 +450,7 @@ vm_run(const VM *vm) { // lgtm [cpp/use-of-goto]
       &&regsetimm, &&regpushimm, &&regpushfloat, &&regpushother, &&regpushaddr,
       &&regpushmem, &&regpushmemfloat, &&regpushmemother, &&regpushmemaddr,
       &&regpushmemderef, &&pushnow, &&baseint, &&basefloat, &&baseother,
-      &&baseaddr, &&regtoreg, &&regtoregother, &&regtoregaddr, &&regtoregderef,
+      &&baseaddr, &&regtoreg, &&regtoregother, &&regtoregother2, &&regtoregaddr, &&regtoregderef,
       &&structmember, &&structmemberfloat, &&structmemberother,
       &&structmemberaddr, &&memsetimm, &&memaddimm, &&repeatidx, &&repeat,
       &&regpushme, &&regpushmaybe, &&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()