Permalink
Browse files

`super` may call context switching method like `send`; fix #3611

  • Loading branch information...
matz committed Apr 18, 2017
1 parent 05fceb5 commit f6c70bc6e8ea472f4d1620d38745da4be0722197
Showing with 24 additions and 6 deletions.
  1. +24 −6 src/vm.c
View
@@ -991,11 +991,14 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
CASE(OP_GETCONST) {
/* A Bx R(A) := constget(Syms(Bx)) */
mrb_value val;
int a = GETARG_A(i);
int bx = GETARG_Bx(i);
mrb_sym sym = syms[bx];
ERR_PC_SET(mrb, pc);
val = mrb_vm_const_get(mrb, syms[GETARG_Bx(i)]);
val = mrb_vm_const_get(mrb, sym);
ERR_PC_CLR(mrb);
regs[GETARG_A(i)] = val;
regs[a] = val;
NEXT;
}
@@ -1276,7 +1279,6 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
result = m->body.func(mrb, recv);
mrb_gc_arena_restore(mrb, ai);
if (mrb->exc) goto L_RAISE;
/* pop stackpos */
ci = mrb->c->ci;
if (!ci->target_class) { /* return from context modifying method (resume/yield) */
if (ci->acc == CI_ACC_RESUMED) {
@@ -1292,6 +1294,7 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
}
}
mrb->c->stack[0] = result;
/* pop stackpos */
mrb->c->stack = ci->stackent;
pc = ci->pc;
cipop(mrb);
@@ -1475,13 +1478,28 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
ci->nregs = n + 2;
}
v = m->body.func(mrb, recv);
mrb->c->stack[0] = v;
mrb_gc_arena_restore(mrb, ai);
if (mrb->exc) goto L_RAISE;
ci = mrb->c->ci;
if (!ci->target_class) { /* return from context modifying method (resume/yield) */
if (ci->acc == CI_ACC_RESUMED) {
mrb->jmp = prev_jmp;
return v;
}
else {
mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc));
proc = ci[-1].proc;
irep = proc->body.irep;
pool = irep->pool;
syms = irep->syms;
}
}
mrb->c->stack[0] = v;
/* pop stackpos */
mrb->c->stack = mrb->c->ci->stackent;
mrb->c->stack = ci->stackent;
pc = ci->pc;
cipop(mrb);
NEXT;
JUMP;
}
else {
/* fill callinfo */

0 comments on commit f6c70bc

Please sign in to comment.