Improve assertions.

This commit is contained in:
Mike Pall
2020-06-13 00:52:54 +02:00
parent 8b55054473
commit 8ae5170cdc
71 changed files with 1363 additions and 927 deletions

View File

@@ -260,6 +260,12 @@ typedef struct CTState {
#define CT_MEMALIGN 3 /* Alignment guaranteed by memory allocator. */
#ifdef LUA_USE_ASSERT
#define lj_assertCTS(c, ...) (lj_assertG_(cts->g, (c), __VA_ARGS__))
#else
#define lj_assertCTS(c, ...) ((void)cts)
#endif
/* -- Predefined types ---------------------------------------------------- */
/* Target-dependent types. */
@@ -392,7 +398,8 @@ static LJ_AINLINE CTState *ctype_cts(lua_State *L)
/* Check C type ID for validity when assertions are enabled. */
static LJ_AINLINE CTypeID ctype_check(CTState *cts, CTypeID id)
{
lua_assert(id > 0 && id < cts->top); UNUSED(cts);
UNUSED(cts);
lj_assertCTS(id > 0 && id < cts->top, "bad CTID %d", id);
return id;
}
@@ -408,8 +415,9 @@ static LJ_AINLINE CType *ctype_get(CTState *cts, CTypeID id)
/* Get child C type. */
static LJ_AINLINE CType *ctype_child(CTState *cts, CType *ct)
{
lua_assert(!(ctype_isvoid(ct->info) || ctype_isstruct(ct->info) ||
ctype_isbitfield(ct->info))); /* These don't have children. */
lj_assertCTS(!(ctype_isvoid(ct->info) || ctype_isstruct(ct->info) ||
ctype_isbitfield(ct->info)),
"ctype %08x has no children", ct->info);
return ctype_get(cts, ctype_cid(ct->info));
}