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)
{
#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);
int32_t n, i = lj_lib_optint(L, 2, 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;
if (i > e) return 0;
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
#endif
#ifndef LJ_DS_UNPACK_PATCH
#define LJ_DS_UNPACK_PATCH LJ_DS
#ifndef LJ_DS_PARSER_TABLE_PATCH
#define LJ_DS_PARSER_TABLE_PATCH LJ_DS
#endif
#ifndef LJ_NO_SYSTEM

View File

@ -1807,8 +1807,14 @@ static void expr_table(LexState *ls, ExpDesc *e)
else if (narr > 0x7ff) narr = 0x7ff;
setbc_d(ip, narr|(hsize2hbits(nhash)<<11));
} 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)
lj_tab_reasize(fs->L, t, narr-1);
#endif
if (fixt) { /* Fix value for dummy keys in template table. */
Node *node = noderef(t->node);
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
#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

@ -43,7 +43,7 @@ static LJ_AINLINE Node *hashmask(const GCtab *t, uint32_t hash)
#define hashlohi(t, lo, hi) hashmask((t), hashrot((lo), (hi)))
#define hashnum(t, o) hashlohi((t), (o)->u32.lo, ((o)->u32.hi << 1))
#if LJ_GC64
#if LJ_GC64
#define hashgcref(t, r) \
hashlohi((t), (uint32_t)gcrefu(r), (uint32_t)(gcrefu(r) >> 32))
#else
@ -51,6 +51,7 @@ static LJ_AINLINE Node *hashmask(const GCtab *t, uint32_t hash)
#endif
#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_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);
#endif
#if LJ_DS_UNPACK_PATCH
LJ_FUNCA MSize LJ_FASTCALL lj_tab_arraylen(GCtab *t);
#endif
#endif

View File

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