From: fennecdjay Date: Thu, 28 Jul 2022 14:44:55 +0000 (+0200) Subject: :bug: Improve Dict typecheck X-Git-Tag: nightly~264^2~73 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=45fc8908412420fd34dcdc4a4fbe5d595eaffda2;p=gwion.git :bug: Improve Dict typecheck --- diff --git a/include/import.h b/include/import.h index 699edd7e..b173e819 100644 --- a/include/import.h +++ b/include/import.h @@ -92,7 +92,11 @@ static inline M_Object new_object_str(const Gwion gwion, const m_str str) { static inline Type dict_type(const Gwion gwion, const Type key, const Type val, const loc_t pos) { char c[1024]; + const m_str keyname = type2str(gwion, key, pos); + const m_str valname = type2str(gwion, key, pos); sprintf(c, "Dict:[%s,%s]", key->name, val->name); + free_mstr(gwion->mp, keyname); + free_mstr(gwion->mp, valname); return str2type(gwion, c, pos); } #endif diff --git a/src/lib/event.c b/src/lib/event.c index e833d177..98adc4f4 100644 --- a/src/lib/event.c +++ b/src/lib/event.c @@ -11,12 +11,19 @@ static CTOR(event_ctor) { vector_init(&EV_SHREDS(o)); } -static DTOR(event_dtor) { vector_release(&EV_SHREDS(o)); } +static DTOR(event_dtor) { + for (m_uint i = 0; i < vector_size(&EV_SHREDS(o)); i++) { + const VM_Shred sh = (VM_Shred)vector_at(&EV_SHREDS(o), i); + release(sh->info->me, sh); + } + vector_release(&EV_SHREDS(o)); +} static INSTR(EventWait) { POP_REG(shred, SZ_FLOAT); const M_Object event = *(M_Object *)REG(-SZ_INT); shreduler_remove(shred->tick->shreduler, shred, false); + shred->info->me->ref++; const Vector v = &EV_SHREDS(event); vector_add(v, (vtype)shred); *(m_int *)REG(-SZ_INT) = 1; @@ -29,12 +36,14 @@ static MFUN(event_signal) { shredule(sh->tick->shreduler, sh, GWION_EPSILON); vector_rem(v, 0); } + release(sh->info->me, sh); } ANN void broadcast(const M_Object o) { for (m_uint i = 0; i < vector_size(&EV_SHREDS(o)); i++) { const VM_Shred sh = (VM_Shred)vector_at(&EV_SHREDS(o), i); shredule(sh->tick->shreduler, sh, GWION_EPSILON); + release(sh->info->me, sh); } vector_clear(&EV_SHREDS(o)); } diff --git a/src/vm/shreduler.c b/src/vm/shreduler.c index 4525b155..7e647175 100644 --- a/src/vm/shreduler.c +++ b/src/vm/shreduler.c @@ -42,8 +42,8 @@ ANN static void tk_remove(const Shreduler s, struct ShredTick_ *const tk) { ANN static inline void child(const Shreduler s, const Vector v) { for (m_uint i = vector_size(v) + 1; --i;) { - const VM_Shred child = (VM_Shred)vector_at(v, i - 1); - struct ShredTick_ *const tk = child->tick; + const VM_Shred shred = (VM_Shred)vector_at(v, i - 1); + struct ShredTick_ *const tk = shred->tick; tk_remove(s, tk); shreduler_erase(s, tk); } @@ -60,6 +60,7 @@ ANN static void shreduler_erase(const Shreduler s, shred->info->frame.ptr ? vector_size(&shred->info->frame) : 0; unwind(shred, (Symbol)-1, size); vector_rem2(&s->active_shreds, (vtype)shred); + release(shred->info->me, shred); } ANN void shreduler_remove(const Shreduler s, const VM_Shred out, @@ -69,9 +70,8 @@ ANN void shreduler_remove(const Shreduler s, const VM_Shred out, tk_remove(s, tk); if (likely(!erase)) tk->prev = tk->next = NULL; else { - shreduler_erase(s, tk); if (tk->parent) vector_rem2(&tk->parent->child, (vtype)out); - release(out->info->me, out); + shreduler_erase(s, tk); } MUTEX_UNLOCK(s->mutex); }