From: Jérémie Astor Date: Fri, 23 Jul 2021 10:52:51 +0000 (+0200) Subject: :art: Improve vararg mem usage X-Git-Tag: nightly~524 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=5ec5aa7a71a7afd2168527770e21344dd4224c0b;p=gwion.git :art: Improve vararg mem usage --- diff --git a/src/emit/emit.c b/src/emit/emit.c index 274dac81..0ef37ff6 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1006,11 +1006,12 @@ ANN static m_uint vararg_size(const Gwion gwion, const Exp_Call *exp_call, ANN static void emit_func_arg_vararg(const Emitter emit, const Exp_Call *exp_call) { const Instr instr = emit_add_instr(emit, VarargIni); - const Vector kinds = new_vector(emit->gwion->mp); - if ((instr->m_val = vararg_size(emit->gwion, exp_call, kinds))) - instr->m_val2 = (m_uint)kinds; + struct Vector_ kinds; + vector_init(&kinds); + if ((instr->m_val = vararg_size(emit->gwion, exp_call, &kinds))) + instr->m_val2 = (m_uint)kinds.ptr; else - free_vector(emit->gwion->mp, kinds); + vector_release(&kinds); } ANN static m_bool emit_func_args(const Emitter emit, const Exp_Call *exp_call) { diff --git a/src/lib/vararg.c b/src/lib/vararg.c index 0bed6204..8ab6c14e 100644 --- a/src/lib/vararg.c +++ b/src/lib/vararg.c @@ -70,7 +70,7 @@ INSTR(VarargIni) { POP_REG(shred, instr->m_val - SZ_INT) if ((*(m_uint *)(o->data + SZ_INT * 2) = instr->m_val)) { arg->d = (m_bit *)xmalloc(round2szint(instr->m_val)); - const Vector kinds = (Vector)instr->m_val2; + const Vector kinds = (Vector)&instr->m_val2; vector_copy2(kinds, &arg->t); m_uint offset = 0; for (m_uint i = 0; i < vector_size(&arg->t); ++i) { @@ -137,7 +137,7 @@ static OP_EMIT(opem_vararg_cast) { } static FREEARG(freearg_vararg) { - if (instr->m_val2) free_vector(((Gwion)gwion)->mp, (Vector)instr->m_val2); + if (instr->m_val2) vector_release((Vector)&instr->m_val2); } static ID_CHECK(idck_vararg) {