preparation for tail call optimization (still has bugs)

This commit is contained in:
Yukihiro "Matz" Matsumoto
2013-04-09 15:31:17 +09:00
parent 5306e4716e
commit 84acf4e3f3
2 changed files with 14 additions and 5 deletions
+8
View File
@@ -317,6 +317,14 @@ genop_peep(codegen_scope *s, mrb_code i, int val)
s->iseq[s->pc-1] = MKOP_A(c0, 0);
genop(s, MKOP_AB(OP_RETURN, 0, OP_R_NORMAL));
return;
#if 0
case OP_SEND:
if (GETARG_B(i) == OP_R_NORMAL && GETARG_A(i) == GETARG_A(i0)) {
s->iseq[s->pc-1] = MKOP_ABC(OP_TAILCALL, GETARG_A(i0), GETARG_B(i0), GETARG_C(i0));
return;
}
break;
#endif
default:
break;
}
+6 -5
View File
@@ -1195,9 +1195,11 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
NEXT;
}
L_RETURN:
i = MKOP_AB(OP_RETURN, GETARG_A(i), OP_R_NORMAL);
/* fall through */
CASE(OP_RETURN) {
/* A return R(A) */
L_RETURN:
if (mrb->exc) {
mrb_callinfo *ci;
int eidx;
@@ -1333,7 +1335,6 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
}
}
/* replace callinfo */
ci = mrb->ci;
ci->mid = mid;
@@ -1658,7 +1659,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
} while (0)
CASE(OP_EQ) {
/* A B C R(A) := R(A)<R(A+1) (Syms[B]=:<,C=1)*/
/* A B C R(A) := R(A)<R(A+1) (Syms[B]=:==,C=1)*/
int a = GETARG_A(i);
if (mrb_obj_eq(mrb, regs[a], regs[a+1])) {
SET_TRUE_VALUE(regs[a]);
@@ -1676,7 +1677,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
}
CASE(OP_LE) {
/* A B C R(A) := R(A)<R(A+1) (Syms[B]=:<,C=1)*/
/* A B C R(A) := R(A)<=R(A+1) (Syms[B]=:<=,C=1)*/
OP_CMP(<=);
NEXT;
}
@@ -1688,7 +1689,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
}
CASE(OP_GE) {
/* A B C R(A) := R(A)<R(A+1) (Syms[B]=:<,C=1)*/
/* A B C R(A) := R(A)<=R(A+1) (Syms[B]=:<=,C=1)*/
OP_CMP(>=);
NEXT;
}