]> Nishi Git Mirror - gwion.git/commitdiff
:art: RegPushImmX now uses m_val
authorfennecdjay <astor.jeremie@wanadoo.fr>
Fri, 15 Feb 2019 21:30:12 +0000 (22:30 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Fri, 15 Feb 2019 21:30:12 +0000 (22:30 +0100)
include/instr.h
src/emit/emit.c
src/vm/vm.c

index d85353792e4d46ac83c7ba0c5c8039001b6cc9cf..de356a805751bda94a564bc606375e71615959c2 100644 (file)
@@ -21,10 +21,10 @@ typedef struct Instr_     * Instr;
 typedef void (*f_instr)(const VM_Shred, const Instr);
 struct Instr_ {
   m_bit opcode;
-//  union {
-//    m_float f;
+  union {
+    m_float f;
     m_uint m_val;
-//  };
+  };
   m_uint m_val2;
   m_bit ptr[SZ_MINVAL];
   void (*execute)(const VM_Shred shred, const Instr instr);
index 5607d957a885d08a62b8e0ebd32cd209c7b65792..b23cb43e8e17e444debbc7afcc9f379d9d7b2656 100644 (file)
@@ -269,13 +269,10 @@ ANN static m_bool emit_symbol_builtin(const Emitter emit, const Exp_Primary* pri
       instr->m_val = (m_uint)v->d.ptr;
     } else if(v->d.ptr)
       instr->m_val = *(m_uint*)v->d.ptr;
-}
-else if(v->d.ptr)
-        memcpy(instr->ptr, v->d.ptr, v->type->size);
-//        memcpy(&instr->m_val, v->d.ptr, v->type->size);
+    } else if(v->d.ptr)
+      memcpy(&instr->m_val, v->d.ptr, v->type->size);
     else
-      *(m_uint**)instr->ptr = v->d.ptr;
-//      instr->m_val = v->d.ptr;
+      instr->m_val = v->d.ptr;
     instr->m_val2 = size;
   }
   return GW_OK;
@@ -399,7 +396,8 @@ ANN static m_bool prim_num(const Emitter emit, const Exp_Primary * primary) {
 
 ANN static m_bool prim_float(const Emitter emit, const Exp_Primary* primary) {
   const Instr instr = emit_add_instr(emit, RegPushImm2);
-  *(m_float*)instr->ptr = primary->d.fnum;
+//  *(m_float*)instr->ptr = primary->d.fnum;
+  instr->f = primary->d.fnum;
   return GW_OK;
 }
 
@@ -1194,7 +1192,7 @@ ANN static m_bool emit_stmt_switch(const Emitter emit, const Stmt_Switch stmt) {
   instr->m_val = switch_idx(emit->env) ?: emit_code_size(emit);
   if(push) {
     emit_switch_map(push, (Map)instr->m_val2);
-    *(m_uint*)instr->ptr = SZ_INT;
+//    *(m_uint*)instr->ptr = SZ_INT;
   }
   switch_end(emit->env);
   pop_vector(&emit->code->stack_break, emit_code_size(emit));
index 091de4479daa5197acef33442c9eb24c999e819e..c43f0fc8d600d1bc2e8449303872f729e8322363 100644 (file)
@@ -299,20 +299,17 @@ regpushimm:
   reg += SZ_INT;
   DISPATCH();
 regpushfloat:
-//  *(m_float*)reg = instr->f;
-  *(m_float*)reg = *(m_float*)instr->ptr;
+  *(m_float*)reg = instr->f;
   reg += SZ_FLOAT;
   DISPATCH();
 regpushother:
   LOOP_OPTIM
   for(m_uint i = 0; i <= instr->m_val2; i+= SZ_INT)
-//    *(m_bit**)(reg+i) = (m_bit*)(instr->m_val + i);
-    *(m_bit**)(reg+i) = (m_bit*)(instr->ptr + i);
+    *(m_bit**)(reg+i) = (m_bit*)(instr->m_val + i);
   reg += instr->m_val2;
   DISPATCH();
 regpushaddr:
-//  *(m_bit**)reg =  &instr->m_val;
-  *(m_bit**)reg =  instr->ptr;
+  *(m_bit**)reg =  &instr->m_val;
   reg += SZ_INT;
   DISPATCH()
 regpushmem: