From 56c599183f17c696c52d9e1c7af71863b63a8ac6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Wed, 16 Jun 2021 16:22:40 +0200 Subject: [PATCH] :bug: Few bugfixes (spork and function pointers) --- src/emit/emit.c | 12 +++++++++--- src/lib/modules.c | 2 +- src/vm/shreduler.c | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index 28418664..42d650ca 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -498,7 +498,7 @@ ANN static m_bool _emit_symbol(const Emitter emit, const Symbol *data) { : emit_regpushbase(emit, size, exp_getvar(prim_exp(data))); instr->m_val = v->from->offset; if (GET_FLAG(v, late) && !exp_getvar(prim_exp(data)) && - isa(v->type, emit->gwion->type[et_object]) > 0) { + (isa(v->type, emit->gwion->type[et_object]) > 0 || is_fptr(emit->gwion, v->type))) { const Instr instr = emit_add_instr(emit, GWOP_EXCEPT); instr->m_val = -SZ_INT; } @@ -1458,11 +1458,13 @@ ANN m_bool emit_exp_call1(const Emitter emit, const Func f, if (vector_size(&emit->code->instr) && vflag(f->value_ref, vflag_member) && is_fptr(emit->gwion, f->value_ref->type)) { const Instr back = (Instr)vector_back(&emit->code->instr); - const Instr base = - back->opcode != eGWOP_EXCEPT + const bool is_except = back->opcode == eGWOP_EXCEPT; + const Instr base = !is_except ? back : (Instr)vector_at(&emit->code->instr, vector_size(&emit->code->instr) - 2); + if(is_except) + vector_pop(&emit->code->instr); const m_bit exec = base->opcode; const m_uint val = base->m_val; const m_uint val2 = base->m_val2; @@ -1472,6 +1474,10 @@ ANN m_bool emit_exp_call1(const Emitter emit, const Func f, const Instr instr = emit_add_instr(emit, (f_instr)(m_uint)exec); instr->m_val = val; instr->m_val2 = val2; + if(is_except) { + vector_add(&emit->code->instr, (m_uint)back); + back->m_val = -SZ_INT; + } } else if (f != emit->env->func && !f->code && !is_fptr(emit->gwion, f->value_ref->type)) { // not yet emitted static func diff --git a/src/lib/modules.c b/src/lib/modules.c index 11c319b7..76bffd3d 100644 --- a/src/lib/modules.c +++ b/src/lib/modules.c @@ -264,7 +264,7 @@ static INSTR(UsrUGenTick) { vmcode_addref(*(VM_Code *)(shred->reg - offset)); uu->shred->info->vm = shred->info->vm; code_prepare(vmcode_callback(shred->info->mp, uu->shred->code)); - shreduler_ini(uu->shred->info->vm->shreduler, uu->shred); + shreduler_ini(uu->shred->tick->shreduler, uu->shred); uu->prep = instr->m_val ? member_prep : global_prep; *(M_Object *)(shred->reg - SZ_INT) = o; } diff --git a/src/vm/shreduler.c b/src/vm/shreduler.c index 063db600..37bf9d50 100644 --- a/src/vm/shreduler.c +++ b/src/vm/shreduler.c @@ -31,7 +31,7 @@ ANN VM_Shred shreduler_get(const Shreduler s) { ANN static inline void shreduler_child(const Vector v) { for (m_uint i = vector_size(v) + 1; --i;) { const VM_Shred child = (VM_Shred)vector_at(v, i - 1); - shreduler_remove(child->info->vm->shreduler, child, true); + shreduler_remove(child->tick->shreduler, child, true); } } -- 2.43.0