Improve assertions.
This commit is contained in:
@@ -61,7 +61,8 @@ static GCcdata *argv2cdata(jit_State *J, TRef tr, cTValue *o)
|
||||
static CTypeID crec_constructor(jit_State *J, GCcdata *cd, TRef tr)
|
||||
{
|
||||
CTypeID id;
|
||||
lua_assert(tref_iscdata(tr) && cd->ctypeid == CTID_CTYPEID);
|
||||
lj_assertJ(tref_iscdata(tr) && cd->ctypeid == CTID_CTYPEID,
|
||||
"expected CTypeID cdata");
|
||||
id = *(CTypeID *)cdataptr(cd);
|
||||
tr = emitir(IRT(IR_FLOAD, IRT_INT), tr, IRFL_CDATA_INT);
|
||||
emitir(IRTG(IR_EQ, IRT_INT), tr, lj_ir_kint(J, (int32_t)id));
|
||||
@@ -237,13 +238,14 @@ static void crec_copy(jit_State *J, TRef trdst, TRef trsrc, TRef trlen,
|
||||
if (len > CREC_COPY_MAXLEN) goto fallback;
|
||||
if (ct) {
|
||||
CTState *cts = ctype_ctsG(J2G(J));
|
||||
lua_assert(ctype_isarray(ct->info) || ctype_isstruct(ct->info));
|
||||
lj_assertJ(ctype_isarray(ct->info) || ctype_isstruct(ct->info),
|
||||
"copy of non-aggregate");
|
||||
if (ctype_isarray(ct->info)) {
|
||||
CType *cct = ctype_rawchild(cts, ct);
|
||||
tp = crec_ct2irt(cts, cct);
|
||||
if (tp == IRT_CDATA) goto rawcopy;
|
||||
step = lj_ir_type_size[tp];
|
||||
lua_assert((len & (step-1)) == 0);
|
||||
lj_assertJ((len & (step-1)) == 0, "copy of fractional size");
|
||||
} else if ((ct->info & CTF_UNION)) {
|
||||
step = (1u << ctype_align(ct->info));
|
||||
goto rawcopy;
|
||||
@@ -629,7 +631,8 @@ static TRef crec_ct_tv(jit_State *J, CType *d, TRef dp, TRef sp, cTValue *sval)
|
||||
/* Specialize to the name of the enum constant. */
|
||||
emitir(IRTG(IR_EQ, IRT_STR), sp, lj_ir_kstr(J, str));
|
||||
if (cct && ctype_isconstval(cct->info)) {
|
||||
lua_assert(ctype_child(cts, cct)->size == 4);
|
||||
lj_assertJ(ctype_child(cts, cct)->size == 4,
|
||||
"only 32 bit const supported"); /* NYI */
|
||||
svisnz = (void *)(intptr_t)(ofs != 0);
|
||||
sp = lj_ir_kint(J, (int32_t)ofs);
|
||||
sid = ctype_cid(cct->info);
|
||||
@@ -757,7 +760,7 @@ static void crec_index_bf(jit_State *J, RecordFFData *rd, TRef ptr, CTInfo info)
|
||||
IRType t = IRT_I8 + 2*lj_fls(ctype_bitcsz(info)) + ((info&CTF_UNSIGNED)?1:0);
|
||||
TRef tr = emitir(IRT(IR_XLOAD, t), ptr, 0);
|
||||
CTSize pos = ctype_bitpos(info), bsz = ctype_bitbsz(info), shift = 32 - bsz;
|
||||
lua_assert(t <= IRT_U32); /* NYI: 64 bit bitfields. */
|
||||
lj_assertJ(t <= IRT_U32, "only 32 bit bitfields supported"); /* NYI */
|
||||
if (rd->data == 0) { /* __index metamethod. */
|
||||
if ((info & CTF_BOOL)) {
|
||||
tr = emitir(IRTI(IR_BAND), tr, lj_ir_kint(J, (int32_t)((1u << pos))));
|
||||
@@ -769,7 +772,7 @@ static void crec_index_bf(jit_State *J, RecordFFData *rd, TRef ptr, CTInfo info)
|
||||
tr = emitir(IRTI(IR_BSHL), tr, lj_ir_kint(J, shift - pos));
|
||||
tr = emitir(IRTI(IR_BSAR), tr, lj_ir_kint(J, shift));
|
||||
} else {
|
||||
lua_assert(bsz < 32); /* Full-size fields cannot end up here. */
|
||||
lj_assertJ(bsz < 32, "unexpected full bitfield index");
|
||||
tr = emitir(IRTI(IR_BSHR), tr, lj_ir_kint(J, pos));
|
||||
tr = emitir(IRTI(IR_BAND), tr, lj_ir_kint(J, (int32_t)((1u << bsz)-1)));
|
||||
/* We can omit the U32 to NUM conversion, since bsz < 32. */
|
||||
@@ -884,7 +887,7 @@ again:
|
||||
crec_index_bf(J, rd, ptr, fct->info);
|
||||
return;
|
||||
} else {
|
||||
lua_assert(ctype_isfield(fct->info));
|
||||
lj_assertJ(ctype_isfield(fct->info), "field expected");
|
||||
sid = ctype_cid(fct->info);
|
||||
}
|
||||
}
|
||||
@@ -1111,7 +1114,7 @@ static TRef crec_call_args(jit_State *J, RecordFFData *rd,
|
||||
if (fid) { /* Get argument type from field. */
|
||||
CType *ctf = ctype_get(cts, fid);
|
||||
fid = ctf->sib;
|
||||
lua_assert(ctype_isfield(ctf->info));
|
||||
lj_assertJ(ctype_isfield(ctf->info), "field expected");
|
||||
did = ctype_cid(ctf->info);
|
||||
} else {
|
||||
if (!(ct->info & CTF_VARARG))
|
||||
|
||||
Reference in New Issue
Block a user