Compile table traversals: next(), pairs(), BC_ISNEXT/BC_ITERN.
Sponsored by OpenResty Inc.
This commit is contained in:
@@ -68,6 +68,8 @@ void lj_dispatch_init(GG_State *GG)
|
||||
/* The JIT engine is off by default. luaopen_jit() turns it on. */
|
||||
disp[BC_FORL] = disp[BC_IFORL];
|
||||
disp[BC_ITERL] = disp[BC_IITERL];
|
||||
/* Workaround for stable v2.1 bytecode. TODO: Replace with BC_IITERN. */
|
||||
disp[BC_ITERN] = &lj_vm_IITERN;
|
||||
disp[BC_LOOP] = disp[BC_ILOOP];
|
||||
disp[BC_FUNCF] = disp[BC_IFUNCF];
|
||||
disp[BC_FUNCV] = disp[BC_IFUNCV];
|
||||
@@ -118,19 +120,21 @@ void lj_dispatch_update(global_State *g)
|
||||
mode |= (g->hookmask & LUA_MASKRET) ? DISPMODE_RET : 0;
|
||||
if (oldmode != mode) { /* Mode changed? */
|
||||
ASMFunction *disp = G2GG(g)->dispatch;
|
||||
ASMFunction f_forl, f_iterl, f_loop, f_funcf, f_funcv;
|
||||
ASMFunction f_forl, f_iterl, f_itern, f_loop, f_funcf, f_funcv;
|
||||
g->dispatchmode = mode;
|
||||
|
||||
/* Hotcount if JIT is on, but not while recording. */
|
||||
if ((mode & (DISPMODE_JIT|DISPMODE_REC)) == DISPMODE_JIT) {
|
||||
f_forl = makeasmfunc(lj_bc_ofs[BC_FORL]);
|
||||
f_iterl = makeasmfunc(lj_bc_ofs[BC_ITERL]);
|
||||
f_itern = makeasmfunc(lj_bc_ofs[BC_ITERN]);
|
||||
f_loop = makeasmfunc(lj_bc_ofs[BC_LOOP]);
|
||||
f_funcf = makeasmfunc(lj_bc_ofs[BC_FUNCF]);
|
||||
f_funcv = makeasmfunc(lj_bc_ofs[BC_FUNCV]);
|
||||
} else { /* Otherwise use the non-hotcounting instructions. */
|
||||
f_forl = disp[GG_LEN_DDISP+BC_IFORL];
|
||||
f_iterl = disp[GG_LEN_DDISP+BC_IITERL];
|
||||
f_itern = &lj_vm_IITERN;
|
||||
f_loop = disp[GG_LEN_DDISP+BC_ILOOP];
|
||||
f_funcf = makeasmfunc(lj_bc_ofs[BC_IFUNCF]);
|
||||
f_funcv = makeasmfunc(lj_bc_ofs[BC_IFUNCV]);
|
||||
@@ -138,6 +142,7 @@ void lj_dispatch_update(global_State *g)
|
||||
/* Init static counting instruction dispatch first (may be copied below). */
|
||||
disp[GG_LEN_DDISP+BC_FORL] = f_forl;
|
||||
disp[GG_LEN_DDISP+BC_ITERL] = f_iterl;
|
||||
disp[GG_LEN_DDISP+BC_ITERN] = f_itern;
|
||||
disp[GG_LEN_DDISP+BC_LOOP] = f_loop;
|
||||
|
||||
/* Set dynamic instruction dispatch. */
|
||||
@@ -165,6 +170,7 @@ void lj_dispatch_update(global_State *g)
|
||||
/* Otherwise set dynamic counting ins. */
|
||||
disp[BC_FORL] = f_forl;
|
||||
disp[BC_ITERL] = f_iterl;
|
||||
disp[BC_ITERN] = f_itern;
|
||||
disp[BC_LOOP] = f_loop;
|
||||
/* Set dynamic return dispatch. */
|
||||
if ((mode & DISPMODE_RET)) {
|
||||
|
||||
Reference in New Issue
Block a user