From 04d121df63b103ab05f0b50614b8b7423e8f70ce Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Fri, 28 Oct 2022 05:10:34 +0200 Subject: [PATCH] :art: clean vm --- include/instr.h | 2 ++ include/opcode.h | 15 ++++----------- opcode.txt | 5 ++--- src/emit/emit.c | 2 +- src/vm/vm.c | 14 ++++++-------- src/vm/vm_code.c | 2 +- 6 files changed, 16 insertions(+), 24 deletions(-) diff --git a/include/instr.h b/include/instr.h index d85e5962..4217a4b6 100644 --- a/include/instr.h +++ b/include/instr.h @@ -73,4 +73,6 @@ INSTR(SetCtor); INSTR(dict_ctor_alt); INSTR(dict_lit_ctor); + +INSTR(DotTmplVal); #endif diff --git a/include/opcode.h b/include/opcode.h index 69679ea3..e34d3820 100644 --- a/include/opcode.h +++ b/include/opcode.h @@ -212,9 +212,8 @@ enum { eDebugPush, eDebugPop, eEOC, - eUnroll2, + eVM_IN, eOP_MAX, - eDotTmplVal, }; #define RegSetImm (f_instr)eRegSetImm @@ -428,9 +427,8 @@ enum { #define DebugPush (f_instr)eDebugPush #define DebugPop (f_instr)eDebugPop #define EOC (f_instr)eEOC -#define Unroll2 (f_instr)eUnroll2 +#define VM_IN (f_instr)eVM_IN #define OP_MAX (f_instr)eOP_MAX -#define DotTmplVal (f_instr)eDotTmplVal #ifndef __cplusplus ANN static inline void dump_opcodes(const VM_Code code) { gw_out("{Y}┏━━━━┓{0}{-Y} {+}%s{0}\n{Y}┃{0}\n", code->name); @@ -1414,17 +1412,12 @@ ANN static inline void dump_opcodes(const VM_Code code) { gw_out("{Y}┃{0}{-}% 4lu{0}: EOC ", j); gw_out("\n"); break; - case eUnroll2: - gw_out("{Y}┃{0}{-}% 4lu{0}: Unroll2 ", j); + case eVM_IN: + gw_out("{Y}┃{0}{-}% 4lu{0}: VM_IN ", j); gw_out("\n"); break; case eOP_MAX: gw_out("{Y}┃{0}{-}% 4lu{0}: OP_MAX ", j); - gw_out(" {-R}%-14p{0}", instr->m_val); - gw_out("\n"); - break; - case eDotTmplVal: - gw_out("{Y}┃{0}{-}% 4lu{0}: DotTmplVal ", j); gw_out("\n"); break; } diff --git a/opcode.txt b/opcode.txt index ddd0ebe8..34b74530 100644 --- a/opcode.txt +++ b/opcode.txt @@ -209,6 +209,5 @@ DebugValue DebugPush DebugPop EOC -Unroll2 -OP_MAX~p -DotTmplVal +VM_IN +OP_MAX diff --git a/src/emit/emit.c b/src/emit/emit.c index faff630e..ae359900 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -2245,7 +2245,7 @@ ANN static m_bool _unroll(const Emitter emit, Looper *loop) { const m_uint end = emit_code_size(emit); for (m_uint i = 1; i < loop->n; ++i) CHECK_BB(unroll_run(emit, loop)); unroll->m_val2 = end - start; - const Instr unroll2 = emit_add_instr(emit, Unroll2); + const Instr unroll2 = emit_add_instr(emit, VM_IN); unroll2->m_val = (m_uint)unroll; scoped_end(emit); return GW_OK; diff --git a/src/vm/vm.c b/src/vm/vm.c index 446e4772..fe130f5b 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -466,8 +466,8 @@ vm_prepare(const VM *vm, m_bit *prepare_code) { // lgtm [cpp/use-of-goto] &&unionother, &&unionaddr, &&staticint, &&staticfloat, &&staticother, &&dotfunc, &&gacktype, &&gackend, &&gack, &&try_ini, &&try_end, &&handleeffect, &&performeffect, &&noop, &&debugline, - &&debugvalue, &&debugpush, &&debugpop, &&eoc, &&unroll2, &&other, - &®pushimm}; + &&debugvalue, &&debugpush, &&debugpop, &&eoc, &&vmin, &&other}; +// &®pushimm}; if(!prepare_code) { PRAGMA_PUSH() @@ -1206,7 +1206,7 @@ vm_prepare(const VM *vm, m_bit *prepare_code) { // lgtm [cpp/use-of-goto] gack: VM_OUT gack(shred, VAL); - goto in; + goto vmin; try_ini: if (!shred->info->frame.ptr) // ??? vector_init(&shred->info->frame); @@ -1229,8 +1229,7 @@ vm_prepare(const VM *vm, m_bit *prepare_code) { // lgtm [cpp/use-of-goto] DISPATCH(); other: VM_OUT((f_instr)VAL2)(shred, (Instr)VAL); - unroll2: - in: + vmin: if (!s->curr) break; bytecode = (code = shred->code)->bytecode; reg = shred->reg; @@ -1311,8 +1310,7 @@ static void *_dispatch[] = { &&_unionother, &&_unionaddr, &&_staticint, &&_staticfloat, &&_staticother, &&_dotfunc, &&_gacktype, &&_gackend, &&_gack, &&_try_ini, &&_try_end, &&_handleeffect, &&_performeffect, &&_noop, &&_debugline, - &&_debugvalue, &&_debugpush, &&_debugpop, &&_eoc, &&_unroll2, &&_other, - &&_regpushimm}; + &&_debugvalue, &&_debugpush, &&_debugpop, &&_eoc, &&_vmin, &&_other}; #define PREPARE(a) \ _##a: \ @@ -1566,7 +1564,7 @@ _other: prepare_code += BYTECODE_SZ;\ goto *_dispatch[*(m_bit*)prepare_code]; } - PREPARE(unroll2); + PREPARE(vmin); PREPARE(debugline); PREPARE(debugvalue); PREPARE(debugpush); diff --git a/src/vm/vm_code.c b/src/vm/vm_code.c index c619f1b2..a6895f37 100644 --- a/src/vm/vm_code.c +++ b/src/vm/vm_code.c @@ -103,7 +103,7 @@ ANN static m_bit *tobytecode(MemPool p, const VM_Code code) { instr->m_val = next->m_val; next->opcode = eNoOp; } - } else if (instr->opcode == eUnroll2) { + } else if (instr->opcode == eVM_IN) { const Instr unroll = (Instr)instr->m_val; const m_uint pc = vector_find(v, (m_uint)unroll); m_uint reduce_pre = 0, reduce = 0; -- 2.43.0