delete unpack patch, add parser patch

This commit is contained in:
fesily 2023-08-17 16:45:31 +08:00
parent e73a2dc482
commit e8811a28d9
6 changed files with 13 additions and 27 deletions

View File

@ -222,16 +222,10 @@ LJLIB_CF(rawlen) LJLIB_REC(.)
LJLIB_CF(unpack) LJLIB_CF(unpack)
{ {
#if LJ_DS_UNPACK_PATCH
#define TAB_LEN lj_tab_arraylen
#else
#define TAB_LEN lj_tab_len
#endif
GCtab *t = lj_lib_checktab(L, 1); GCtab *t = lj_lib_checktab(L, 1);
int32_t n, i = lj_lib_optint(L, 2, 1); int32_t n, i = lj_lib_optint(L, 2, 1);
int32_t e = (L->base+3-1 < L->top && !tvisnil(L->base+3-1)) ? int32_t e = (L->base+3-1 < L->top && !tvisnil(L->base+3-1)) ?
lj_lib_checkint(L, 3) : (int32_t)TAB_LEN(t); lj_lib_checkint(L, 3) : (int32_t)lj_tab_len(t);
uint32_t nu; uint32_t nu;
if (i > e) return 0; if (i > e) return 0;
nu = (uint32_t)e - (uint32_t)i; nu = (uint32_t)e - (uint32_t)i;

View File

@ -751,8 +751,8 @@ extern void *LJ_WIN_LOADLIBA(const char *path);
#define LJ_DS_BIG_UPVAL_PATCH LJ_DS #define LJ_DS_BIG_UPVAL_PATCH LJ_DS
#endif #endif
#ifndef LJ_DS_UNPACK_PATCH #ifndef LJ_DS_PARSER_TABLE_PATCH
#define LJ_DS_UNPACK_PATCH LJ_DS #define LJ_DS_PARSER_TABLE_PATCH LJ_DS
#endif #endif
#ifndef LJ_NO_SYSTEM #ifndef LJ_NO_SYSTEM

View File

@ -1807,8 +1807,14 @@ static void expr_table(LexState *ls, ExpDesc *e)
else if (narr > 0x7ff) narr = 0x7ff; else if (narr > 0x7ff) narr = 0x7ff;
setbc_d(ip, narr|(hsize2hbits(nhash)<<11)); setbc_d(ip, narr|(hsize2hbits(nhash)<<11));
} else { } else {
#if LJ_DS_PARSER_TABLE_PATCH
if ((needarr && t->asize != narr) || hsize2hmask(nhash) != t->hmask) {
lj_tab_resize(fs->L, t, narr, hsize2hbits(nhash));
}
#else
if (needarr && t->asize < narr) if (needarr && t->asize < narr)
lj_tab_reasize(fs->L, t, narr-1); lj_tab_reasize(fs->L, t, narr-1);
#endif
if (fixt) { /* Fix value for dummy keys in template table. */ if (fixt) { /* Fix value for dummy keys in template table. */
Node *node = noderef(t->node); Node *node = noderef(t->node);
uint32_t i, hmask = t->hmask; uint32_t i, hmask = t->hmask;

View File

@ -691,14 +691,3 @@ MSize LJ_FASTCALL lj_tab_len_hint(GCtab *t, size_t hint)
} }
#endif #endif
#if LJ_DS_UNPACK_PATCH
MSize LJ_FASTCALL lj_tab_arraylen(GCtab *t)
{
MSize j = (MSize)t->asize;
while (j > 1 && tvisnil(arrayslot(t, j - 1))) {
j--;
}
if (j) --j;
return j;
}
#endif

View File

@ -51,6 +51,7 @@ static LJ_AINLINE Node *hashmask(const GCtab *t, uint32_t hash)
#endif #endif
#define hsize2hbits(s) ((s) ? ((s)==1 ? 1 : 1+lj_fls((uint32_t)((s)-1))) : 0) #define hsize2hbits(s) ((s) ? ((s)==1 ? 1 : 1+lj_fls((uint32_t)((s)-1))) : 0)
#define hsize2hmask(s) ((s) ? (1u <<hsize2hbits(nhash)) - 1 : 0)
LJ_FUNCA GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits); LJ_FUNCA GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits);
LJ_FUNC GCtab *lj_tab_new_ah(lua_State *L, int32_t a, int32_t h); LJ_FUNC GCtab *lj_tab_new_ah(lua_State *L, int32_t a, int32_t h);
@ -93,8 +94,4 @@ LJ_FUNCA MSize LJ_FASTCALL lj_tab_len(GCtab *t);
LJ_FUNC MSize LJ_FASTCALL lj_tab_len_hint(GCtab *t, size_t hint); LJ_FUNC MSize LJ_FASTCALL lj_tab_len_hint(GCtab *t, size_t hint);
#endif #endif
#if LJ_DS_UNPACK_PATCH
LJ_FUNCA MSize LJ_FASTCALL lj_tab_arraylen(GCtab *t);
#endif
#endif #endif

View File

@ -14,8 +14,8 @@
@setlocal @setlocal
@rem Add more debug flags here, e.g. DEBUGCFLAGS=/DLUA_USE_APICHECK @rem Add more debug flags here, e.g. DEBUGCFLAGS=/DLUA_USE_APICHECK
@set DEBUGCFLAGS= /DLUA_USE_APICHECK /DLUA_USE_ASSERT @set DEBUGCFLAGS= /DLUA_USE_APICHECK /DLUA_USE_ASSERT /DLUAJIT_USE_SYSMALLOC /fsanitize=address
@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline @set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline /DLUAJIT_NUMMODE
@set LJLINK=link /nologo @set LJLINK=link /nologo
@set LJMT=mt /nologo @set LJMT=mt /nologo
@set LJLIB=lib /nologo /nodefaultlib @set LJLIB=lib /nologo /nodefaultlib