📄 ljit_x86.h
字号:
dasm_put(Dst, 791, Dt2([1+nargs])); } dasm_put(Dst, 2171, (ptrdiff_t)(J->nextins)); } if (nargs >= 0) { /* Previous op was not open and did not set TOP. */ int i; /* Relocate [BASE+func, BASE+func+nargs] -> [ci->func, ci->func+nargs]. */ /* TODO: loop for large nargs? */ if (!J->pt->is_vararg) { /* Fixarg function. */ dasm_put(Dst, 2241, Dt2([func].value)); for (i = 0; i < nargs; i++) { if (J->flags & JIT_F_CPU_SSE2) { dasm_put(Dst, 821, Dt2([func+1+i].tt), Dt2([func+1+i].value), Dt2([i].tt), Dt2([i].value)); } else { dasm_put(Dst, 2245, Dt2([func+1+i].value), Dt2([func+1+i].value.na[1]), Dt2([i].value), Dt2([func+1+i].tt), Dt2([i].value.na[1]), Dt2([i].tt)); } } dasm_put(Dst, 2264, Dt2([nargs]), sizeof(TValue), Dt1(->ci), Dt2(->value)); } else { /* Vararg function. */ dasm_put(Dst, 2278, Dt1(->ci), Dt2([func]), Dt4(->func), Dt3(->value), Dt2(->value)); for (i = 0; i < nargs; i++) { if (J->flags & JIT_F_CPU_SSE2) { dasm_put(Dst, 2294, Dt3([i+1].tt), Dt3([i+1].value), Dt2([i+1].tt), Dt2([i+1].value)); } else { dasm_put(Dst, 2312, Dt3([i+1].value), Dt3([i+1].value.na[1]), Dt2([i+1].value), Dt3([i+1].tt), Dt2([i+1].value.na[1]), Dt2([i+1].tt)); } } dasm_put(Dst, 2331, Dt2([1+nargs]), Dt2(->value)); } } else { /* Previous op was open and set TOP. */ dasm_put(Dst, 332, Dt1(->ci)); if (func) { dasm_put(Dst, 787, func*sizeof(TValue)); } dasm_put(Dst, 2338, Dt4(->func), Dt4(->func), Dt2(->value)); } dasm_put(Dst, 2230, sizeof(CallInfo), Dt5(->jit_gate));finish: J->combine++; /* Combine with following return instruction. */}/* ------------------------------------------------------------------------ */static void jit_op_move(jit_State *J, int dest, int src){ if (J->flags & JIT_F_CPU_SSE2) { dasm_put(Dst, 821, Dt2([src].tt), Dt2([src].value), Dt2([dest].tt), Dt2([dest].value)); } else { dasm_put(Dst, 839, Dt2([src].value), Dt2([src].value.na[1]), Dt2([src].tt), Dt2([dest].value), Dt2([dest].value.na[1]), Dt2([dest].tt)); }}static void jit_op_loadk(jit_State *J, int dest, int kidx){ const TValue *kk = &J->pt->k[kidx]; int rk = jit_return_k(J); if (rk) dest = 0; switch (ttype(kk)) { case 0: dasm_put(Dst, 2369, Dt2([dest].tt)); break; case 1: if (bvalue(kk)) { /* true */ dasm_put(Dst, 2377, Dt2([dest].value), Dt2([dest].tt)); } else { /* false */ dasm_put(Dst, 2389, Dt2([dest].value), Dt2([dest].tt)); } break; case 3: { if ((&(kk)->value)->n == (lua_Number)0) { dasm_put(Dst, 2404); } else if ((&(kk)->value)->n == (lua_Number)1) { dasm_put(Dst, 2408); } else { dasm_put(Dst, 2411, &(kk)->value); } dasm_put(Dst, 1306, Dt2([dest].value), Dt2([dest].tt)); break; } case 4: dasm_put(Dst, 2415, Dt2([dest].value), (ptrdiff_t)(gcvalue(kk)), Dt2([dest].tt)); break; default: lua_assert(0); break; } if (rk) { dasm_put(Dst, 32); }}static void jit_op_loadnil(jit_State *J, int first, int last){ int idx, num = last - first + 1; int rk = jit_return_k(J); dasm_put(Dst, 2125); if (rk) { dasm_put(Dst, 2427, Dt2([0].tt)); } else if (num <= 8) { for (idx = first; idx <= last; idx++) { dasm_put(Dst, 854, Dt2([idx].tt)); } } else { dasm_put(Dst, 2432, Dt2([first].tt), Dt2([last].tt), sizeof(TValue)); }}static void jit_op_loadbool(jit_State *J, int dest, int b, int dojump){ int rk = jit_return_k(J); if (rk) dest = 0; if (b) { /* true */ dasm_put(Dst, 2377, Dt2([dest].value), Dt2([dest].tt)); } else { /* false */ dasm_put(Dst, 2389, Dt2([dest].value), Dt2([dest].tt)); } if (rk) { dasm_put(Dst, 32); } else if (dojump) { const TValue *h = hint_getpc(J, COMBINE, J->nextpc); if (!(ttisboolean(h) && bvalue(h) == 0)) { /* Avoid jmp around dead ins. */ dasm_put(Dst, 665, J->nextpc+1); } }}/* ------------------------------------------------------------------------ */static void jit_op_getupval(jit_State *J, int dest, int uvidx){ if (!J->pt->is_vararg) { dasm_put(Dst, 2241, Dt2([-1].value)); } else { dasm_put(Dst, 2452, Dt1(->ci), Dt4(->func), Dt3(->value)); } dasm_put(Dst, 2462, Dt5(->upvals[uvidx]), DtF(->v)); if (J->flags & JIT_F_CPU_SSE2) { dasm_put(Dst, 2469, Dt3([0].tt), Dt3([0].value), Dt2([dest].tt), Dt2([dest].value)); } else { dasm_put(Dst, 2487, Dt3([0].value), Dt3([0].value.na[1]), Dt3([0].tt), Dt2([dest].value), Dt2([dest].value.na[1]), Dt2([dest].tt)); }}static void jit_op_setupval(jit_State *J, int src, int uvidx){ if (!J->pt->is_vararg) { dasm_put(Dst, 2241, Dt2([-1].value)); } else { dasm_put(Dst, 2452, Dt1(->ci), Dt4(->func), Dt3(->value)); } dasm_put(Dst, 2506, Dt5(->upvals[uvidx]), DtF(->v), Dt2([src].tt), Dt2([src].value), Dt3(->tt), Dt2([src].value.na[1]), Dt3(->value), Dt3(->value.na[1])); dasm_put(Dst, 2542, DtA(->gch.marked), WHITEBITS, DtF(->marked), bitmask(BLACKBIT));}/* ------------------------------------------------------------------------ *//* Optimized table lookup routines. Enter via jsub, fallback to C. *//* Fallback for GETTABLE_*. Temporary key is in L->env. */static void jit_gettable_fb(lua_State *L, Table *t, StkId dest){ Table *mt = t->metatable; const TValue *tm = luaH_getstr(mt, G(L)->tmname[TM_INDEX]); if (ttisnil(tm)) { /* No __index method? */ mt->flags |= 1<<TM_INDEX; /* Cache this fact. */ setnilvalue(dest); } else if (ttisfunction(tm)) { /* __index function? */ ptrdiff_t destr = savestack(L, dest); setobj2s(L, L->top, tm); sethvalue(L, L->top+1, t); setobj2s(L, L->top+2, &L->env); luaD_checkstack(L, 3); L->top += 3; luaD_call(L, L->top - 3, 1); dest = restorestack(L, destr); L->top--; setobjs2s(L, dest, L->top); } else { /* Let luaV_gettable() continue with the __index object. */ luaV_gettable(L, tm, &L->env, dest); }}/* Fallback for SETTABLE_*STR. Temporary (string) key is in L->env. */static void jit_settable_fb(lua_State *L, Table *t, StkId val){ Table *mt = t->metatable; const TValue *tm = luaH_getstr(mt, G(L)->tmname[TM_NEWINDEX]); if (ttisnil(tm)) { /* No __newindex method? */ mt->flags |= 1<<TM_NEWINDEX; /* Cache this fact. */ t->flags = 0; /* But need to clear the cache for the table itself. */ setobj2t(L, luaH_setstr(L, t, rawtsvalue(&L->env)), val); luaC_barriert(L, t, val); } else if (ttisfunction(tm)) { /* __newindex function? */ setobj2s(L, L->top, tm); sethvalue(L, L->top+1, t); setobj2s(L, L->top+2, &L->env); setobj2s(L, L->top+3, val); luaD_checkstack(L, 4); L->top += 4; luaD_call(L, L->top - 4, 0); } else { /* Let luaV_settable() continue with the __newindex object. */ luaV_settable(L, tm, &L->env, val); }}/* ------------------------------------------------------------------------ */static void jit_op_newtable(jit_State *J, int dest, int lnarray, int lnhash){ dasm_put(Dst, 3158, luaO_fb2int(lnarray), luaO_fb2int(lnhash), (ptrdiff_t)(luaH_new), Dt2([dest].value), Dt2([dest].tt)); jit_checkGC(J);}static void jit_op_getglobal(jit_State *J, int dest, int kidx){ const TValue *kk = &J->pt->k[kidx]; jit_assert(ttisstring(kk)); dasm_put(Dst, 3184, (ptrdiff_t)(&kk->value.gc->ts)); if (dest) { dasm_put(Dst, 787, dest*sizeof(TValue)); } dasm_put(Dst, 3187);}static void jit_op_setglobal(jit_State *J, int rval, int kidx){ const TValue *kk = &J->pt->k[kidx]; jit_assert(ttisstring(kk)); dasm_put(Dst, 3184, (ptrdiff_t)(&kk->value.gc->ts)); if (rval) { dasm_put(Dst, 787, rval*sizeof(TValue)); } dasm_put(Dst, 3191);}enum { TKEY_KSTR = -2, TKEY_STR = -1, TKEY_ANY = 0 };/* Optimize key lookup depending on consts or hints type. */static int jit_keylookup(jit_State *J, int tab, int rkey){ const TValue *tabt = hint_get(J, TYPE); const TValue *key; if (!ttistable(tabt)) return TKEY_ANY; /* Not a table? Use fallback. */ key = ISK(rkey) ? &J->pt->k[INDEXK(rkey)] : hint_get(J, TYPEKEY); if (ttisstring(key)) { /* String key? */ if (ISK(rkey)) { dasm_put(Dst, 3195, Dt2([tab]), (ptrdiff_t)(&key->value.gc->ts)); return TKEY_KSTR; /* Const string key. */ } else { dasm_put(Dst, 3201, Dt2([tab]), Dt2([rkey])); return TKEY_STR; /* Var string key. */ } } else if (ttisnumber(key)) { /* Number key? */ lua_Number n = nvalue(key); int k; lua_number2int(k, n); if (!(k >= 1 && k < (1 << 26) && (lua_Number)k == n)) return TKEY_ANY; /* Not a proper array key? Use fallback. */ if (ISK(rkey)) { dasm_put(Dst, 3208, Dt2([tab].tt), Dt2([tab].value), k, DtC(->array), DtC(->sizearray)); return k; /* Const array key (>= 1). */ } else { dasm_put(Dst, 3232, Dt2([tab].tt), Dt2([rkey].tt)); if (J->flags & JIT_F_CPU_SSE2) { dasm_put(Dst, 3250, Dt2([rkey]), Dt2([tab].value)); } else { dasm_put(Dst, 3283, Dt2([rkey].value)); if (J->flags & JIT_F_CPU_CMOV) { dasm_put(Dst, 3293); } else { dasm_put(Dst, 3298); } dasm_put(Dst, 3304, Dt2([tab].value)); } dasm_put(Dst, 3320, DtC(->sizearray), DtC(->array)); return 1; /* Variable array key. */ } } return TKEY_ANY; /* Use fallback. */}static void jit_op_gettable(jit_State *J, int dest, int tab, int rkey){ int k = jit_keylookup(J, tab, rkey); switch (k) { case TKEY_KSTR: /* Const string key. */ if (dest) { dasm_put(Dst, 787, dest*sizeof(TValue)); } dasm_put(Dst, 3334); break; case TKEY_STR: /* Variable string key. */ if (dest) { dasm_put(Dst, 787, dest*sizeof(TValue)); } dasm_put(Dst, 3338); break; case TKEY_ANY: /* Generic gettable fallback. */ if (ISK(rkey)) { dasm_put(Dst, 3342, (ptrdiff_t)(&J->pt->k[INDEXK(rkey)])); } else { dasm_put(Dst, 3204, Dt2([rkey])); } dasm_put(Dst, 3345, Dt2([tab])); if (dest) { dasm_put(Dst, 787, dest*sizeof(TValue)); } dasm_put(Dst, 3349, Dt1(->savedp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -