Commit ea033526 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #3151 from okkez/use-stack-directly

Use stack directly
parents 8f0c1c7d d4ee409a
...@@ -766,7 +766,6 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc) ...@@ -766,7 +766,6 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
mrb_irep *irep = proc->body.irep; mrb_irep *irep = proc->body.irep;
mrb_value *pool = irep->pool; mrb_value *pool = irep->pool;
mrb_sym *syms = irep->syms; mrb_sym *syms = irep->syms;
mrb_value *regs = NULL;
mrb_code i; mrb_code i;
int ai = mrb_gc_arena_save(mrb); int ai = mrb_gc_arena_save(mrb);
struct mrb_jmpbuf *prev_jmp = mrb->jmp; struct mrb_jmpbuf *prev_jmp = mrb->jmp;
...@@ -809,8 +808,8 @@ RETRY_TRY_BLOCK: ...@@ -809,8 +808,8 @@ RETRY_TRY_BLOCK:
mrb->jmp = &c_jmp; mrb->jmp = &c_jmp;
mrb->c->ci->proc = proc; mrb->c->ci->proc = proc;
mrb->c->ci->nregs = irep->nregs; mrb->c->ci->nregs = irep->nregs;
regs = mrb->c->stack;
#define regs (mrb->c->stack)
INIT_DISPATCH { INIT_DISPATCH {
CASE(OP_NOP) { CASE(OP_NOP) {
/* do nothing */ /* do nothing */
...@@ -916,7 +915,6 @@ RETRY_TRY_BLOCK: ...@@ -916,7 +915,6 @@ RETRY_TRY_BLOCK:
ERR_PC_SET(mrb, pc); ERR_PC_SET(mrb, pc);
val = mrb_vm_const_get(mrb, syms[GETARG_Bx(i)]); val = mrb_vm_const_get(mrb, syms[GETARG_Bx(i)]);
ERR_PC_CLR(mrb); ERR_PC_CLR(mrb);
regs = mrb->c->stack;
regs[GETARG_A(i)] = val; regs[GETARG_A(i)] = val;
NEXT; NEXT;
} }
...@@ -935,7 +933,6 @@ RETRY_TRY_BLOCK: ...@@ -935,7 +933,6 @@ RETRY_TRY_BLOCK:
ERR_PC_SET(mrb, pc); ERR_PC_SET(mrb, pc);
val = mrb_const_get(mrb, regs[a], syms[GETARG_Bx(i)]); val = mrb_const_get(mrb, regs[a], syms[GETARG_Bx(i)]);
ERR_PC_CLR(mrb); ERR_PC_CLR(mrb);
regs = mrb->c->stack;
regs[a] = val; regs[a] = val;
NEXT; NEXT;
} }
...@@ -1169,7 +1166,7 @@ RETRY_TRY_BLOCK: ...@@ -1169,7 +1166,7 @@ RETRY_TRY_BLOCK:
} }
} }
mrb->c->stack[0] = result; mrb->c->stack[0] = result;
regs = mrb->c->stack = ci->stackent; mrb->c->stack = ci->stackent;
pc = ci->pc; pc = ci->pc;
cipop(mrb); cipop(mrb);
JUMP; JUMP;
...@@ -1226,7 +1223,7 @@ RETRY_TRY_BLOCK: ...@@ -1226,7 +1223,7 @@ RETRY_TRY_BLOCK:
if (mrb->exc) goto L_RAISE; if (mrb->exc) goto L_RAISE;
/* pop stackpos */ /* pop stackpos */
ci = mrb->c->ci; ci = mrb->c->ci;
regs = mrb->c->stack = ci->stackent; mrb->c->stack = ci->stackent;
regs[ci->acc] = recv; regs[ci->acc] = recv;
pc = ci->pc; pc = ci->pc;
cipop(mrb); cipop(mrb);
...@@ -1252,7 +1249,6 @@ RETRY_TRY_BLOCK: ...@@ -1252,7 +1249,6 @@ RETRY_TRY_BLOCK:
else { else {
stack_extend(mrb, irep->nregs, ci->argc+2); stack_extend(mrb, irep->nregs, ci->argc+2);
} }
regs = mrb->c->stack;
regs[0] = m->env->stack[0]; regs[0] = m->env->stack[0];
pc = irep->iseq; pc = irep->iseq;
JUMP; JUMP;
...@@ -1320,7 +1316,7 @@ RETRY_TRY_BLOCK: ...@@ -1320,7 +1316,7 @@ RETRY_TRY_BLOCK:
mrb_gc_arena_restore(mrb, ai); mrb_gc_arena_restore(mrb, ai);
if (mrb->exc) goto L_RAISE; if (mrb->exc) goto L_RAISE;
/* pop stackpos */ /* pop stackpos */
regs = mrb->c->stack = mrb->c->ci->stackent; mrb->c->stack = mrb->c->ci->stackent;
cipop(mrb); cipop(mrb);
NEXT; NEXT;
} }
...@@ -1340,7 +1336,6 @@ RETRY_TRY_BLOCK: ...@@ -1340,7 +1336,6 @@ RETRY_TRY_BLOCK:
else { else {
stack_extend(mrb, irep->nregs, ci->argc+2); stack_extend(mrb, irep->nregs, ci->argc+2);
} }
regs = mrb->c->stack;
pc = irep->iseq; pc = irep->iseq;
JUMP; JUMP;
} }
...@@ -1532,7 +1527,7 @@ RETRY_TRY_BLOCK: ...@@ -1532,7 +1527,7 @@ RETRY_TRY_BLOCK:
} }
if (ci->ridx == 0) { if (ci->ridx == 0) {
if (mrb->c == mrb->root_c) { if (mrb->c == mrb->root_c) {
regs = mrb->c->stack = mrb->c->stbase; mrb->c->stack = mrb->c->stbase;
goto L_STOP; goto L_STOP;
} }
else { else {
...@@ -1558,7 +1553,7 @@ RETRY_TRY_BLOCK: ...@@ -1558,7 +1553,7 @@ RETRY_TRY_BLOCK:
irep = proc->body.irep; irep = proc->body.irep;
pool = irep->pool; pool = irep->pool;
syms = irep->syms; syms = irep->syms;
regs = mrb->c->stack = ci[1].stackent; mrb->c->stack = ci[1].stackent;
pc = mrb->c->rescue[--ci->ridx]; pc = mrb->c->rescue[--ci->ridx];
} }
else { else {
...@@ -1640,7 +1635,7 @@ RETRY_TRY_BLOCK: ...@@ -1640,7 +1635,7 @@ RETRY_TRY_BLOCK:
} }
cipop(mrb); cipop(mrb);
acc = ci->acc; acc = ci->acc;
regs = mrb->c->stack = ci->stackent; mrb->c->stack = ci->stackent;
if (acc == CI_ACC_SKIP) { if (acc == CI_ACC_SKIP) {
mrb->jmp = prev_jmp; mrb->jmp = prev_jmp;
return v; return v;
...@@ -1714,7 +1709,6 @@ RETRY_TRY_BLOCK: ...@@ -1714,7 +1709,6 @@ RETRY_TRY_BLOCK:
else { else {
stack_extend(mrb, irep->nregs, ci->argc+2); stack_extend(mrb, irep->nregs, ci->argc+2);
} }
regs = mrb->c->stack;
pc = irep->iseq; pc = irep->iseq;
} }
JUMP; JUMP;
...@@ -2215,7 +2209,6 @@ RETRY_TRY_BLOCK: ...@@ -2215,7 +2209,6 @@ RETRY_TRY_BLOCK:
CASE(OP_STRCAT) { CASE(OP_STRCAT) {
/* A B R(A).concat(R(B)) */ /* A B R(A).concat(R(B)) */
mrb_str_concat(mrb, regs[GETARG_A(i)], regs[GETARG_B(i)]); mrb_str_concat(mrb, regs[GETARG_A(i)], regs[GETARG_B(i)]);
regs = mrb->c->stack;
NEXT; NEXT;
} }
...@@ -2228,7 +2221,6 @@ RETRY_TRY_BLOCK: ...@@ -2228,7 +2221,6 @@ RETRY_TRY_BLOCK:
while (b < lim) { while (b < lim) {
mrb_hash_set(mrb, hash, regs[b], regs[b+1]); mrb_hash_set(mrb, hash, regs[b], regs[b+1]);
regs = mrb->c->stack;
b+=2; b+=2;
} }
regs[GETARG_A(i)] = hash; regs[GETARG_A(i)] = hash;
...@@ -2272,7 +2264,6 @@ RETRY_TRY_BLOCK: ...@@ -2272,7 +2264,6 @@ RETRY_TRY_BLOCK:
base = mrb_obj_value(mrb->c->ci->target_class); base = mrb_obj_value(mrb->c->ci->target_class);
} }
c = mrb_vm_define_class(mrb, base, super, id); c = mrb_vm_define_class(mrb, base, super, id);
regs = mrb->c->stack;
regs[a] = mrb_obj_value(c); regs[a] = mrb_obj_value(c);
ARENA_RESTORE(mrb, ai); ARENA_RESTORE(mrb, ai);
NEXT; NEXT;
...@@ -2324,7 +2315,7 @@ RETRY_TRY_BLOCK: ...@@ -2324,7 +2315,7 @@ RETRY_TRY_BLOCK:
mrb_gc_arena_restore(mrb, ai); mrb_gc_arena_restore(mrb, ai);
if (mrb->exc) goto L_RAISE; if (mrb->exc) goto L_RAISE;
/* pop stackpos */ /* pop stackpos */
regs = mrb->c->stack = mrb->c->ci->stackent; mrb->c->stack = mrb->c->ci->stackent;
cipop(mrb); cipop(mrb);
NEXT; NEXT;
} }
...@@ -2334,7 +2325,6 @@ RETRY_TRY_BLOCK: ...@@ -2334,7 +2325,6 @@ RETRY_TRY_BLOCK:
syms = irep->syms; syms = irep->syms;
stack_extend(mrb, irep->nregs, 1); stack_extend(mrb, irep->nregs, 1);
ci->nregs = irep->nregs; ci->nregs = irep->nregs;
regs = mrb->c->stack;
pc = irep->iseq; pc = irep->iseq;
JUMP; JUMP;
} }
...@@ -2425,6 +2415,7 @@ RETRY_TRY_BLOCK: ...@@ -2425,6 +2415,7 @@ RETRY_TRY_BLOCK:
} }
} }
END_DISPATCH; END_DISPATCH;
#undef regs
} }
MRB_CATCH(&c_jmp) { MRB_CATCH(&c_jmp) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment