if(is_obj && (is_array || !is_ref)) {
const Instr assign = emit_add_instr(emit, Assign);
assign->m_val = emit_var;
-// TODO: (test type)watch me: am I needed ?
- if(isa(type, emit->gwion->type[et_fork]) < 0) { // beware fork
- const Instr instr = emit_add_instr(emit, RegAddRef);
- instr->m_val = emit_var;
- }
+ const Instr instr = emit_add_instr(emit, RegAddRef);
+ instr->m_val = emit_var;
}
return GW_OK;
}
const Instr push = emit_add_instr(emit, RegPush);
push->m_val = SZ_INT;
}
+if(is_spork) {
+ const Instr spork = emit_add_instr(emit, is_spork ? SporkExp : ForkEnd);
+ spork->m_val = emit->code->stack_depth;
+} else {
const Instr spork = emit_add_instr(emit, is_spork ? SporkExp : ForkEnd);
- spork->m_val = emit->code->stack_depth;
+ spork->m_val = exp_self(unary)->emit_var;
+// spork->m_val2 = f->def->base->ret_type->size;
+}
} else {
if(GET_FLAG(f, member) && is_fptr(emit->gwion, f->value_ref->type)) {
const m_uint depth = f->def->stack_depth;
} else
emit_exp_spork_finish(emit, f->def->stack_depth);
const Instr end = emit_add_instr(emit, is_spork ? SporkEnd : ForkEnd);
+ end->m_val = exp_self(unary)->emit_var;
end->m_val2 = f->def->base->ret_type->size;
}
return ini;
ANN2(1) static m_bool emit_exp(const Emitter emit, Exp exp, const m_bool ref) {
do {
CHECK_BB(exp_func[exp->exp_type](emit, &exp->d))
- if(ref && isa(exp->type, emit->gwion->type[et_object]) > 0 && isa(exp->type, emit->gwion->type[et_shred]) < 0 ) { // beware fork
+ if(ref && isa(exp->type, emit->gwion->type[et_object]) > 0) {
const Instr instr = emit_add_instr(emit, RegAddRef);
instr->m_val = exp->emit_var;
}
if(stmt->val->exp_type == ae_exp_call && emit->env->func == stmt->val->d.exp_call.m_func)
return optimize_taill_call(emit, &stmt->val->d.exp_call);
CHECK_BB(emit_exp_pop_next(emit, stmt->val, 0))
- if(isa(stmt->val->type, emit->gwion->type[et_object]) > 0 && isa(stmt->val->type , emit->gwion->type[et_shred]) < 0) // beware shred
+ if(isa(stmt->val->type, emit->gwion->type[et_object]) > 0)
emit_add_instr(emit, RegAddRef);
}
vector_add(&emit->code->stack_return, (vtype)emit_add_instr(emit, Goto));
ANN static inline VM_Shred init_spork_shred(const VM_Shred shred, const VM_Code code) {
const VM_Shred sh = new_shred_base(shred, code);
vm_add_shred(shred->info->vm, sh);
+ vector_add(&shred->gc, sh->info->me);
sh->tick->parent = shred->tick;
if(!shred->tick->child.ptr)
vector_init(&shred->tick->child);
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, sh->info->me);
return sh;
}
*(m_uint*)(a.child->reg+VAL-SZ_INT*2) = *(m_uint*)(reg-SZ_INT*2);
a.child->reg += VAL;
DISPATCH()
-
-//exit(2);
sporkexp:
// LOOP_OPTIM
for(m_uint i = 0; i < VAL; i+= SZ_INT)
forkend:
fork_launch(vm, a.child->info->me, VAL2);
sporkend:
- *(M_Object*)(reg-SZ_INT) = a.child->info->me;
+ if(!VAL)
+ *(M_Object*)(reg-SZ_INT) = a.child->info->me;
+ else
+ *(M_Object**)(reg-SZ_INT) = &a.child->info->me;
DISPATCH()
brancheqint:
reg -= SZ_INT;