summaryrefslogtreecommitdiff
path: root/ltests.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltests.c')
-rw-r--r--ltests.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/ltests.c b/ltests.c
index e99b432f..8686fa73 100644
--- a/ltests.c
+++ b/ltests.c
@@ -272,7 +272,13 @@ static void checkclosure (global_State *g, Closure *cl) {
272static void checkstack (global_State *g, lua_State *L1) { 272static void checkstack (global_State *g, lua_State *L1) {
273 StkId o; 273 StkId o;
274 CallInfo *ci; 274 CallInfo *ci;
275 GCObject *uvo;
275 lua_assert(!isdead(g, obj2gco(L1))); 276 lua_assert(!isdead(g, obj2gco(L1)));
277 for (uvo = L1->openupval; uvo != NULL; uvo = uvo->gch.next) {
278 UpVal *uv = gco2uv(uvo);
279 lua_assert(uv->v != &uv->u.value); /* must be open */
280 lua_assert(!isblack(uvo)); /* open upvalues cannot be black */
281 }
276 checkliveness(g, gt(L1)); 282 checkliveness(g, gt(L1));
277 if (L1->base_ci) { 283 if (L1->base_ci) {
278 for (ci = L1->base_ci; ci <= L1->ci; ci++) 284 for (ci = L1->base_ci; ci <= L1->ci; ci++)
@@ -300,6 +306,7 @@ printf(">>> %d %s %02x\n", g->gcstate, luaT_typenames[o->gch.tt], o->gch.marke
300 case LUA_TUPVAL: { 306 case LUA_TUPVAL: {
301 UpVal *uv = gco2uv(o); 307 UpVal *uv = gco2uv(o);
302 lua_assert(uv->v == &uv->u.value); /* must be closed */ 308 lua_assert(uv->v == &uv->u.value); /* must be closed */
309 lua_assert(!isgray(o)); /* closed upvalues are never gray */
303 checkvalref(g, o, uv->v); 310 checkvalref(g, o, uv->v);
304 break; 311 break;
305 } 312 }
@@ -333,14 +340,20 @@ printf(">>> %d %s %02x\n", g->gcstate, luaT_typenames[o->gch.tt], o->gch.marke
333int lua_checkmemory (lua_State *L) { 340int lua_checkmemory (lua_State *L) {
334 global_State *g = G(L); 341 global_State *g = G(L);
335 GCObject *o; 342 GCObject *o;
343 UpVal *uv;
336 checkstack(g, g->mainthread); 344 checkstack(g, g->mainthread);
337 for (o = g->rootgc; o != obj2gco(g->mainthread); o = o->gch.next) 345 for (o = g->rootgc; o != obj2gco(g->mainthread); o = o->gch.next)
338 checkobject(g, o); 346 checkobject(g, o);
339 checkobject(g, obj2gco(g->mainthread)); 347 for (o = o->gch.next; o != NULL; o = o->gch.next) {
340 for (o = g->mainthread->next; o != NULL; o = o->gch.next) {
341 lua_assert(o->gch.tt == LUA_TUSERDATA); 348 lua_assert(o->gch.tt == LUA_TUSERDATA);
342 checkobject(g, o); 349 checkobject(g, o);
343 } 350 }
351 for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) {
352 lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
353 lua_assert(uv->v != &uv->u.value); /* must be open */
354 lua_assert(!isblack(obj2gco(uv))); /* open upvalues are never black */
355 checkvalref(g, obj2gco(uv), uv->v);
356 }
344 return 0; 357 return 0;
345} 358}
346 359