From 2096e78346499f4af77edd0b3d1527b03e3694bb Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Fri, 15 Feb 2019 22:30:12 +0100 Subject: [PATCH] :art: RegPushImmX now uses m_val --- include/instr.h | 6 +++--- src/emit/emit.c | 14 ++++++-------- src/vm/vm.c | 9 +++------ 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/include/instr.h b/include/instr.h index d85353792..de356a805 100644 --- a/include/instr.h +++ b/include/instr.h @@ -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); diff --git a/src/emit/emit.c b/src/emit/emit.c index 5607d957a..b23cb43e8 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -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)); diff --git a/src/vm/vm.c b/src/vm/vm.c index 091de4479..c43f0fc8d 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -299,20 +299,17 @@ clock_gettime(CLOCK_THREAD_CPUTIME_ID, &exec_ini); 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: