struct Vector_ reserved;
struct Map_ pass_map;
struct Vector_ pass;
+ struct Gwion_ *base;
} GwionData;
ANN GwionData* new_gwiondata(MemPool);
} else {
const Instr spork = emit_add_instr(emit, is_spork ? SporkExp : ForkEnd);
spork->m_val = exp_self(unary)->emit_var;
- if(!(spork->m_val = exp_self(unary)->emit_var))
-return NULL;// err_msg
}
} else {
if(GET_FLAG(f, member) && is_fptr(emit->gwion, f->value_ref->type)) {
} else
emit_exp_spork_finish(emit, f->def->stack_depth);
const Instr end = emit_add_instr(emit, is_spork ? SporkEnd : ForkEnd);
- if(!is_spork && !(end->m_val = exp_self(unary)->emit_var))
- return NULL;// err_msg
end->m_val2 = f->def->base->ret_type->size;
}
return ini;
}
static DTOR(fork_dtor) {
+ if(*(m_int*)(o->data + o_fork_done))
+ vector_rem2(&FORK_ORIG(o)->gwion->data->child, (vtype)o);
THREAD_JOIN(FORK_THREAD(o));
VM *vm = ME(o)->info->vm;
free_vm(vm);
} while(vm->bbq->is_running);
fork_retval(me);
MUTEX_LOCK(vm->shreduler->mutex);
-// MUTEX_LOCK(FORK_ORIG(me)->shreduler->mutex);
- vector_rem2(&FORK_ORIG(me)->gwion->data->child, (vtype)me);
-// MUTEX_UNLOCK(FORK_ORIG(me)->shreduler->mutex);
*(m_int*)(me->data + o_fork_done) = 1;
broadcast(*(M_Object*)(me->data + o_fork_ev));
MUTEX_UNLOCK(vm->shreduler->mutex);
}
void fork_launch(const VM* vm, const M_Object o, const m_uint sz) {
- o->ref += 2;
+ o->ref += 1;
if(!vm->gwion->data->child.ptr)
vector_init(&vm->gwion->data->child);
vector_add(&vm->gwion->data->child, (vtype)o);
#include "gwion.h"
ANN void vm_fork(const VM* src, const VM_Shred shred) {
- VM* vm = shred->info->vm = gwion_cpy(src);
+ VM* vm = (shred->info->vm = gwion_cpy(src));
shred->info->me = new_shred(shred, 0);
shreduler_add(vm->shreduler, shred);
+ vm->gwion->data->base = src->gwion;
}
__attribute__((hot))
ANN static inline VM_Shred init_fork_shred(const VM_Shred shred, const VM_Code code) {
const VM_Shred sh = new_shred_base(shred, code);
vm_fork(shred->info->vm, sh);
- assert(sh->info->me);
- vector_add(&shred->gc, (vtype)sh->info->me);
return sh;
}