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

@@ -18,7 +18,7 @@ static LJ_AINLINE void *cdata_getptr(void *p, CTSize sz)
if (LJ_64 && sz == 4) { /* Support 32 bit pointers on 64 bit targets. */
return ((void *)(uintptr_t)*(uint32_t *)p);
} else {
lua_assert(sz == CTSIZE_PTR);
lj_assertX(sz == CTSIZE_PTR, "bad pointer size %d", sz);
return *(void **)p;
}
}
@@ -29,7 +29,7 @@ static LJ_AINLINE void cdata_setptr(void *p, CTSize sz, const void *v)
if (LJ_64 && sz == 4) { /* Support 32 bit pointers on 64 bit targets. */
*(uint32_t *)p = (uint32_t)(uintptr_t)v;
} else {
lua_assert(sz == CTSIZE_PTR);
lj_assertX(sz == CTSIZE_PTR, "bad pointer size %d", sz);
*(void **)p = (void *)v;
}
}
@@ -40,7 +40,8 @@ static LJ_AINLINE GCcdata *lj_cdata_new(CTState *cts, CTypeID id, CTSize sz)
GCcdata *cd;
#ifdef LUA_USE_ASSERT
CType *ct = ctype_raw(cts, id);
lua_assert((ctype_hassize(ct->info) ? ct->size : CTSIZE_PTR) == sz);
lj_assertCTS((ctype_hassize(ct->info) ? ct->size : CTSIZE_PTR) == sz,
"inconsistent size of fixed-size cdata alloc");
#endif
cd = (GCcdata *)lj_mem_newgco(cts->L, sizeof(GCcdata) + sz);
cd->gct = ~LJ_TCDATA;