From 3cd53d7751f9a2966458e09079b7965d6c9559ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Thu, 31 Dec 2020 15:45:58 +0100 Subject: [PATCH] :bomb: Less ref move --- plug | 2 +- src/emit/emit.c | 16 ++++++++++++---- src/lib/modules.c | 1 - src/lib/string.c | 8 -------- src/lib/vararg.c | 1 + 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/plug b/plug index 79b4ed9c..7115000a 160000 --- a/plug +++ b/plug @@ -1 +1 @@ -Subproject commit 79b4ed9cbaeeb12455a7985f72fe7f6ef4ac7ef1 +Subproject commit 7115000a96593156c973aaf936153a74fb4005d9 diff --git a/src/emit/emit.c b/src/emit/emit.c index 39a9c8be..acfcbf6f 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -29,6 +29,7 @@ typedef struct Local_ { Type type; m_uint offset; + uint skip; } Local; static inline void emit_pop(const Emitter emit, const m_uint scope) { env_pop(emit->env, scope); } @@ -62,9 +63,10 @@ ANN static Local* new_local(MemPool p, const Type type) { return local; } -ANN static m_uint frame_local(MemPool p, Frame* frame, const Type t) { +ANN static m_uint frame_local(MemPool p, Frame* frame, const Type t, const uint skip) { Local* local = new_local(p, t); local->offset = frame->curr_offset; + local->skip = skip; frame->curr_offset += t->size; vector_add(&frame->stack, (vtype)local); return local->offset; @@ -156,6 +158,8 @@ ANN static m_int frame_pop(const Emitter emit) { Frame *frame = emit->code->frame; DECL_OB(const Local*, l, = (Local*)vector_pop(&frame->stack)) frame->curr_offset -= l->type->size; + if(l->skip) + return frame_pop(emit); if(tflag(l->type, tflag_struct)) { struct_pop(emit, l->type, l->offset); return frame_pop(emit); @@ -222,7 +226,11 @@ ANN m_uint emit_code_offset(const Emitter emit) { } ANN m_uint emit_local(const Emitter emit, const Type t) { - return frame_local(emit->gwion->mp, emit->code->frame, t); + return frame_local(emit->gwion->mp, emit->code->frame, t, 0); +} + +ANN m_uint emit_localn(const Emitter emit, const Type t) { + return frame_local(emit->gwion->mp, emit->code->frame, t, 1); } ANN void emit_ext_ctor(const Emitter emit, const Type t); @@ -908,7 +916,7 @@ ANN static void emit_func_arg_vararg(const Emitter emit, const Exp_Call* exp_cal ANN static m_bool emit_func_args(const Emitter emit, const Exp_Call* exp_call) { if(exp_call->args) { CHECK_BB(emit_exp(emit, exp_call->args)) - emit_exp_addref(emit, exp_call->args, -exp_totalsize(exp_call->args)); +// emit_exp_addref(emit, exp_call->args, -exp_totalsize(exp_call->args)); } const Type t = actual_type(emit->gwion, exp_call->func->type); if(isa(t, emit->gwion->type[et_function]) > 0 && @@ -1976,7 +1984,7 @@ ANN static void emit_func_def_args(const Emitter emit, Arg_List a) { do { const Type type = a->var_decl->value->type; emit->code->stack_depth += type->size; - a->var_decl->value->from->offset = emit_local(emit, type); + a->var_decl->value->from->offset = emit_localn(emit, type); } while((a = a->next)); } diff --git a/src/lib/modules.c b/src/lib/modules.c index ba336327..9784c31c 100644 --- a/src/lib/modules.c +++ b/src/lib/modules.c @@ -241,7 +241,6 @@ static MFUN(default_tick) { uu->shred = NULL; } UGEN(o)->module.gen.tick = id_tick; -// release(o, shred); } static INSTR(UsrUGenTick) { diff --git a/src/lib/string.c b/src/lib/string.c index fce5cff9..90b4c243 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -182,7 +182,6 @@ static MFUN(string_insert) { for(i = index; i < (m_int)len; i++) c[i + len_insert] = str[i]; c[len + len_insert] = '\0'; - release(arg, shred); *(M_Object*)RETURN = new_string(shred->info->vm->gwion->mp, shred, c);; } @@ -200,7 +199,6 @@ static MFUN(string_replace) { const m_uint len = strlen(str); len_insert = strlen(insert); if(index >= (m_int)len || index < 0 || (index + len_insert + 1) <= 0) { - release(arg, shred); *(M_Object*)RETURN = NULL; return; } @@ -210,7 +208,6 @@ static MFUN(string_replace) { for(i = 0; i < len_insert; i++) c[i + index] = insert[i]; c[index + len_insert] = '\0'; - release(arg, shred); *(M_Object*)RETURN = new_string(shred->info->vm->gwion->mp, shred, c);; } @@ -240,7 +237,6 @@ static MFUN(string_replaceN) { for(i = index + _len; i < (m_int)len; i++) c[i] = str[i]; c[len + _len - 1] = '\0'; - release(arg, shred); *(M_Object*)RETURN = new_string(shred->info->vm->gwion->mp, shred, c);; } @@ -273,7 +269,6 @@ static MFUN(string_findStr) { *(m_uint*)RETURN = str ? str - base : -1; } else *(m_uint*)RETURN = -1; - release(obj, shred); } static MFUN(string_findStrStart) { @@ -287,7 +282,6 @@ static MFUN(string_findStrStart) { *(m_uint*)RETURN = str ? str - pos- base : -1; } else *(m_uint*)RETURN = -1; - release(obj, shred); } static MFUN(string_rfind) { @@ -321,7 +315,6 @@ static MFUN(string_rfindStr) { *(m_uint*)RETURN = str ? str - base : -1; } else *(m_uint*)RETURN = -1; - release(obj, shred); } static MFUN(string_rfindStrStart) { @@ -337,7 +330,6 @@ static MFUN(string_rfindStrStart) { *(m_uint*)RETURN = str ? str - pos - base : -1; } else *(m_uint*)RETURN = -1; - release(obj, shred); } static MFUN(string_erase) { diff --git a/src/lib/vararg.c b/src/lib/vararg.c index a3c87d57..e24ac5e9 100644 --- a/src/lib/vararg.c +++ b/src/lib/vararg.c @@ -28,6 +28,7 @@ static DTOR(vararg_dtor) { if(*(m_uint*)(o->data + SZ_INT*2)) { m_uint offset = 0; for(m_uint i = 0; i < vector_size(&arg->t); ++i) { +// could be compound release const Type t = (Type)vector_at(&arg->t, i); if(isa(t, shred->info->vm->gwion->type[et_object]) > 0) release(*(M_Object*)(arg->d + offset), shred); -- 2.43.0