From 71c924866d7b1cb8552b486cccbb47ba00b8f7c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 27 Jun 2021 23:51:29 +0200 Subject: [PATCH] :art: Improve function ending --- src/emit/emit.c | 10 ---------- src/vm/vm_code.c | 1 + 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index 73267799..b1c8f71e 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -2524,15 +2524,6 @@ ANN static void emit_func_def_args(const Emitter emit, Arg_List a) { } while ((a = a->next)); } -ANN static void emit_func_def_ensure(const Emitter emit, const Func_Def fdef) { - const m_uint size = fdef->base->ret_type->size; - if (size) { - const Instr instr = emit_regpushimm(emit, size, false); - instr->m_val2 = size; - } - vector_add(&emit->code->stack_return, (vtype)emit_add_instr(emit, Goto)); -} - ANN static m_bool emit_func_def_return(const Emitter emit) { const m_uint val = emit_code_size(emit); CHECK_BB(emit_defers(emit)); @@ -2577,7 +2568,6 @@ ANN static m_bool emit_func_def_body(const Emitter emit, const Func_Def fdef) { if (fdef->base->args) emit_func_def_args(emit, fdef->base->args); if (fbflag(fdef->base, fbflag_variadic)) stack_alloc(emit); if (fdef->d.code) CHECK_BB(scoped_stmt(emit, fdef->d.code, 1)); - emit_func_def_ensure(emit, fdef); return GW_OK; } diff --git a/src/vm/vm_code.c b/src/vm/vm_code.c index b8233412..1178633e 100644 --- a/src/vm/vm_code.c +++ b/src/vm/vm_code.c @@ -139,6 +139,7 @@ ANN static m_bit *tobytecode(MemPool p, const VM_Code code) { map_set(&code->handlers, j, new_pc); } *(m_uint *)(data + SZ_INT) = new_pc; + instr->m_val = new_pc; } else if (opcode == eRecurs /*|| opcode == eSetCode*/) { *(uint16_t *)(final + j * BYTECODE_SZ + SZ_INT * 2) = instr->udata.one += j + 1; -- 2.43.0