Skip to content

Commit

Permalink
🎨 RegPushImmX now uses m_val
Browse files Browse the repository at this point in the history
  • Loading branch information
fennecdjay committed Feb 15, 2019
1 parent b617d1b commit 2096e78
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
6 changes: 3 additions & 3 deletions include/instr.h
Expand Up @@ -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);
Expand Down
14 changes: 6 additions & 8 deletions src/emit/emit.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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));
Expand Down
9 changes: 3 additions & 6 deletions src/vm/vm.c
Expand Up @@ -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:
Expand Down

0 comments on commit 2096e78

Please sign in to comment.