Update LuaJIT to the latest 2.1.0 source (1d8b747)

This commit is contained in:
Alex Szpakowski
2020-10-12 18:09:06 -03:00
parent ec1ceaf373
commit 72540d2d5a
214 changed files with 4738 additions and 3800 deletions
+19 -11
View File
@@ -1,6 +1,6 @@
/*
** C declaration parser.
** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2020 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"
@@ -28,6 +28,12 @@
** If in doubt, please check the input against your favorite C compiler.
*/
#ifdef LUA_USE_ASSERT
#define lj_assertCP(c, ...) (lj_assertG_(G(cp->L), (c), __VA_ARGS__))
#else
#define lj_assertCP(c, ...) ((void)cp)
#endif
/* -- Miscellaneous ------------------------------------------------------- */
/* Match string against a C literal. */
@@ -61,7 +67,7 @@ LJ_NORET static void cp_err(CPState *cp, ErrMsg em);
static const char *cp_tok2str(CPState *cp, CPToken tok)
{
lua_assert(tok < CTOK_FIRSTDECL);
lj_assertCP(tok < CTOK_FIRSTDECL, "bad CPToken %d", tok);
if (tok > CTOK_OFS)
return ctoknames[tok-CTOK_OFS-1];
else if (!lj_char_iscntrl(tok))
@@ -169,7 +175,8 @@ static CPToken cp_number(CPState *cp)
TValue o;
do { cp_save(cp, cp->c); } while (lj_char_isident(cp_get(cp)));
cp_save(cp, '\0');
fmt = lj_strscan_scan((const uint8_t *)sbufB(&cp->sb), &o, STRSCAN_OPT_C);
fmt = lj_strscan_scan((const uint8_t *)sbufB(&cp->sb), sbuflen(&cp->sb)-1,
&o, STRSCAN_OPT_C);
if (fmt == STRSCAN_INT) cp->val.id = CTID_INT32;
else if (fmt == STRSCAN_U32) cp->val.id = CTID_UINT32;
else if (!(cp->mode & CPARSE_MODE_SKIP))
@@ -391,7 +398,7 @@ static void cp_init(CPState *cp)
cp->curpack = 0;
cp->packstack[0] = 255;
lj_buf_init(cp->L, &cp->sb);
lua_assert(cp->p != NULL);
lj_assertCP(cp->p != NULL, "uninitialized cp->p");
cp_get(cp); /* Read-ahead first char. */
cp->tok = 0;
cp->tmask = CPNS_DEFAULT;
@@ -852,12 +859,13 @@ static CTypeID cp_decl_intern(CPState *cp, CPDecl *decl)
/* The cid is already part of info for copies of pointers/functions. */
idx = ct->next;
if (ctype_istypedef(info)) {
lua_assert(id == 0);
lj_assertCP(id == 0, "typedef not at toplevel");
id = ctype_cid(info);
/* Always refetch info/size, since struct/enum may have been completed. */
cinfo = ctype_get(cp->cts, id)->info;
csize = ctype_get(cp->cts, id)->size;
lua_assert(ctype_isstruct(cinfo) || ctype_isenum(cinfo));
lj_assertCP(ctype_isstruct(cinfo) || ctype_isenum(cinfo),
"typedef of bad type");
} else if (ctype_isfunc(info)) { /* Intern function. */
CType *fct;
CTypeID fid;
@@ -890,7 +898,7 @@ static CTypeID cp_decl_intern(CPState *cp, CPDecl *decl)
/* Inherit csize/cinfo from original type. */
} else {
if (ctype_isnum(info)) { /* Handle mode/vector-size attributes. */
lua_assert(id == 0);
lj_assertCP(id == 0, "number not at toplevel");
if (!(info & CTF_BOOL)) {
CTSize msize = ctype_msizeP(decl->attr);
CTSize vsize = ctype_vsizeP(decl->attr);
@@ -945,7 +953,7 @@ static CTypeID cp_decl_intern(CPState *cp, CPDecl *decl)
info = (info & ~CTF_ALIGN) | (cinfo & CTF_ALIGN);
info |= (cinfo & CTF_QUAL); /* Inherit qual. */
} else {
lua_assert(ctype_isvoid(info));
lj_assertCP(ctype_isvoid(info), "bad ctype %08x", info);
}
csize = size;
cinfo = info+id;
@@ -1584,7 +1592,7 @@ end_decl:
cp_errmsg(cp, cp->tok, LJ_ERR_FFI_DECLSPEC);
sz = sizeof(int);
}
lua_assert(sz != 0);
lj_assertCP(sz != 0, "basic ctype with zero size");
info += CTALIGN(lj_fls(sz)); /* Use natural alignment. */
info += (decl->attr & CTF_QUAL); /* Merge qualifiers. */
cp_push(decl, info, sz);
@@ -1844,7 +1852,7 @@ static void cp_decl_multi(CPState *cp)
/* Treat both static and extern function declarations as extern. */
ct = ctype_get(cp->cts, ctypeid);
/* We always get new anonymous functions (typedefs are copied). */
lua_assert(gcref(ct->name) == NULL);
lj_assertCP(gcref(ct->name) == NULL, "unexpected named function");
id = ctypeid; /* Just name it. */
} else if ((scl & CDF_STATIC)) { /* Accept static constants. */
id = cp_decl_constinit(cp, &ct, ctypeid);
@@ -1901,7 +1909,7 @@ static TValue *cpcparser(lua_State *L, lua_CFunction dummy, void *ud)
cp_decl_single(cp);
if (cp->param && cp->param != cp->L->top)
cp_err(cp, LJ_ERR_FFI_NUMPARAM);
lua_assert(cp->depth == 0);
lj_assertCP(cp->depth == 0, "unbalanced cparser declaration depth");
return NULL;
}