]> Nishi Git Mirror - gwion.git/commitdiff
:art: Few improvments
authorfennecdjay <astor.jeremie@wanadoo.fr>
Mon, 4 Mar 2019 18:46:38 +0000 (19:46 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Mon, 4 Mar 2019 18:46:38 +0000 (19:46 +0100)
src/lib/instr.c
src/lib/vararg.c

index e3718421630076f24baa7f9cc228686766d6ce54..71b679ed32eed0b2cf8b0369773328ff460d7448 100644 (file)
@@ -66,10 +66,8 @@ INSTR(AutoLoopStart) { GWDEBUG_EXE
 }
 
 INSTR(AutoLoopEnd) { GWDEBUG_EXE
-  m_uint* idx = (m_uint*)MEM(instr->m_val);
-  ++*idx;
   const M_Object o =  *(M_Object*)REG(-SZ_INT);
-  if(*idx >= m_vector_size(ARRAY(o))) {
+  if(++*(m_uint*)MEM(instr->m_val) >= m_vector_size(ARRAY(o))) {
     shred->pc = instr->m_val2;
     POP_REG(shred, SZ_INT);
   }
@@ -78,7 +76,8 @@ INSTR(AutoLoopEnd) { GWDEBUG_EXE
 #ifdef OPTIMIZE
 INSTR(PutArgsInMem) { GWDEBUG_EXE
   POP_REG(shred, instr->m_val)
-  memcpy(shred->mem, shred->reg, instr->m_val);
+  for(m_uint i = 0; i < instr->m_val; i += SZ_INT)
+    *(m_uint*)(shred->mem + i) = *(m_uint*)(shred->reg + i);
 }
 #endif
 
index cdce3526b26ea7d55c2eac5baee10cf5d42dde0a..2128999cc853d5339e13a31fb0c4b27a850a429c 100644 (file)
@@ -37,7 +37,7 @@ INSTR(VarargIni) { GWDEBUG_EXE
   memcpy(arg->d, shred->reg - SZ_INT, instr->m_val);
   const Vector kinds = (Vector)instr->m_val2;
   arg->s = vector_size(kinds);
-  arg->k = (m_uint*)xcalloc(arg->s, SZ_INT);
+  arg->k = (m_uint*)xmalloc(arg->s * SZ_INT);
   memcpy(arg->k, kinds->ptr + OFFSET, arg->s * SZ_INT);
   *(struct Vararg_**)REG(-SZ_INT) = arg;
 }
@@ -54,7 +54,8 @@ INSTR(VarargEnd) { GWDEBUG_EXE
 
 INSTR(VarargMember) { GWDEBUG_EXE
   const struct Vararg_* arg = *(struct Vararg_**)MEM(instr->m_val);
-  memcpy(REG(0), (arg->d + arg->o), instr->m_val2);
+  for(m_uint i = 0; i < instr->m_val2; i += SZ_INT)
+    *(m_uint*)REG(0) = *(m_uint*)(arg->d + arg->o);
   PUSH_REG(shred, instr->m_val2);
 }