From ff021c85490b87e186f0e93b420eac52afaaa95d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Fri, 8 May 2020 21:52:40 +0200 Subject: [PATCH] :art: Improve vm and gack --- include/gack.h | 2 +- opcode.txt | 4 ++-- src/lib/gack.c | 4 ++-- src/vm/vm.c | 2 +- src/vm/vm_code.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/gack.h b/include/gack.h index be039776..106a0edc 100644 --- a/include/gack.h +++ b/include/gack.h @@ -1,6 +1,6 @@ #ifndef __GACK #define __GACK -ANN void gack(const VM_Shred, const Instr); +ANN void gack(const VM_Shred, const m_uint); #define INTERP_PRINTF(fmt, ...) { \ m_str ret = *(m_str*)(VALUE - SZ_INT);\ diff --git a/opcode.txt b/opcode.txt index 62c4fb4b..36ebfc0b 100644 --- a/opcode.txt +++ b/opcode.txt @@ -171,6 +171,6 @@ GackType GackEnd Gack NoOp -DotTmplVal -OP_MAX EOC +OP_MAX +DotTmplVal diff --git a/src/lib/gack.c b/src/lib/gack.c index d339529f..083d15a5 100644 --- a/src/lib/gack.c +++ b/src/lib/gack.c @@ -65,14 +65,14 @@ ANN static void prepare_call(const VM_Shred shred, const m_uint offset) { shred->pc = 0; } -ANN void gack(const VM_Shred shred, const Instr instr) { +ANN void gack(const VM_Shred shred, const m_uint offset) { const Type t = *(Type*)shred->reg; const VM_Code code = get_gack(t); if(GET_FLAG(code, builtin)) { ((f_gack)code->native_func)(t, (shred->reg - t->size), shred); POP_REG(shred, t->size); } else { - prepare_call(shred, instr->m_val2); + prepare_call(shred, offset); shred->code = code; POP_REG(shred, SZ_INT*2); } diff --git a/src/vm/vm.c b/src/vm/vm.c index 008a8425..bd20678c 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -871,7 +871,7 @@ gackend: } gack: VM_OUT - gack(shred, (Instr)VAL); + gack(shred, VAL); goto in; noop: DISPATCH(); diff --git a/src/vm/vm_code.c b/src/vm/vm_code.c index dcb7d47e..e2b8f6c3 100644 --- a/src/vm/vm_code.c +++ b/src/vm/vm_code.c @@ -47,7 +47,7 @@ ANN static m_bit* tobytecode(MemPool p, const VM_Code code) { instr->opcode = eRegPushImm; instr->m_val = (m_uint)code; } - if(instr->opcode < eGack) + if(instr->opcode < eOP_MAX) memcpy(ptr + i*BYTECODE_SZ, instr, BYTECODE_SZ); else { *(m_bit*)(ptr + (i*BYTECODE_SZ)) = instr->opcode; -- 2.43.0