diff options
Diffstat (limited to 'ltests.c')
-rw-r--r-- | ltests.c | 32 |
1 files changed, 17 insertions, 15 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.45 2008/02/11 18:04:26 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.46 2008/02/11 19:04:16 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -176,10 +176,10 @@ static int testobjref1 (global_State *g, GCObject *f, GCObject *t) { | |||
176 | static void printobj (global_State *g, GCObject *o) { | 176 | static void printobj (global_State *g, GCObject *o) { |
177 | int i = 0; | 177 | int i = 0; |
178 | GCObject *p; | 178 | GCObject *p; |
179 | for (p = g->rootgc; p != o && p != NULL; p = p->gch.next) i++; | 179 | for (p = g->rootgc; p != o && p != NULL; p = gch(p)->next) i++; |
180 | if (p == NULL) i = -1; | 180 | if (p == NULL) i = -1; |
181 | printf("%d:%s(%p)-%c(%02X)", i, luaT_typenames[o->gch.tt], (void *)o, | 181 | printf("%d:%s(%p)-%c(%02X)", i, luaT_typenames[gch(o)->tt], (void *)o, |
182 | isdead(g,o)?'d':isblack(o)?'b':iswhite(o)?'w':'g', o->gch.marked); | 182 | isdead(g,o)?'d':isblack(o)?'b':iswhite(o)?'w':'g', gch(o)->marked); |
183 | } | 183 | } |
184 | 184 | ||
185 | 185 | ||
@@ -198,7 +198,7 @@ static int testobjref (global_State *g, GCObject *f, GCObject *t) { | |||
198 | #define checkobjref(g,f,t) lua_assert(testobjref(g,f,obj2gco(t))) | 198 | #define checkobjref(g,f,t) lua_assert(testobjref(g,f,obj2gco(t))) |
199 | 199 | ||
200 | #define checkvalref(g,f,t) lua_assert(!iscollectable(t) || \ | 200 | #define checkvalref(g,f,t) lua_assert(!iscollectable(t) || \ |
201 | ((ttype(t) == (t)->value.gc->gch.tt) && testobjref(g,f,gcvalue(t)))) | 201 | ((ttype(t) == gch((t)->value.gc)->tt) && testobjref(g,f,gcvalue(t)))) |
202 | 202 | ||
203 | 203 | ||
204 | 204 | ||
@@ -285,7 +285,7 @@ static void checkstack (global_State *g, lua_State *L1) { | |||
285 | CallInfo *ci; | 285 | CallInfo *ci; |
286 | GCObject *uvo; | 286 | GCObject *uvo; |
287 | lua_assert(!isdead(g, obj2gco(L1))); | 287 | lua_assert(!isdead(g, obj2gco(L1))); |
288 | for (uvo = L1->openupval; uvo != NULL; uvo = uvo->gch.next) { | 288 | for (uvo = L1->openupval; uvo != NULL; uvo = gch(uvo)->next) { |
289 | UpVal *uv = gco2uv(uvo); | 289 | UpVal *uv = gco2uv(uvo); |
290 | lua_assert(uv->v != &uv->u.value); /* must be open */ | 290 | lua_assert(uv->v != &uv->u.value); /* must be open */ |
291 | lua_assert(!isblack(uvo)); /* open upvalues cannot be black */ | 291 | lua_assert(!isblack(uvo)); /* open upvalues cannot be black */ |
@@ -308,14 +308,14 @@ static void checkstack (global_State *g, lua_State *L1) { | |||
308 | 308 | ||
309 | static void checkobject (global_State *g, GCObject *o) { | 309 | static void checkobject (global_State *g, GCObject *o) { |
310 | if (isdead(g, o)) | 310 | if (isdead(g, o)) |
311 | /* lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep);*/ | 311 | /* lua_assert(issweep(g));*/ |
312 | { if (!(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep)) | 312 | { if (!issweep(g)) |
313 | printf(">>> %d %s %02x\n", g->gcstate, luaT_typenames[o->gch.tt], o->gch.marked); | 313 | printf(">>> %d %s %02x\n", g->gcstate, luaT_typenames[gch(o)->tt], gch(o)->marked); |
314 | } | 314 | } |
315 | else { | 315 | else { |
316 | if (g->gcstate == GCSfinalize) | 316 | if (g->gcstate == GCSfinalize) |
317 | lua_assert(iswhite(o)); | 317 | lua_assert(iswhite(o)); |
318 | switch (o->gch.tt) { | 318 | switch (gch(o)->tt) { |
319 | case LUA_TUPVAL: { | 319 | case LUA_TUPVAL: { |
320 | UpVal *uv = gco2uv(o); | 320 | UpVal *uv = gco2uv(o); |
321 | lua_assert(uv->v == &uv->u.value); /* must be closed */ | 321 | lua_assert(uv->v == &uv->u.value); /* must be closed */ |
@@ -329,7 +329,7 @@ printf(">>> %d %s %02x\n", g->gcstate, luaT_typenames[o->gch.tt], o->gch.marke | |||
329 | break; | 329 | break; |
330 | } | 330 | } |
331 | case LUA_TTABLE: { | 331 | case LUA_TTABLE: { |
332 | checktable(g, gco2h(o)); | 332 | checktable(g, gco2t(o)); |
333 | break; | 333 | break; |
334 | } | 334 | } |
335 | case LUA_TTHREAD: { | 335 | case LUA_TTHREAD: { |
@@ -367,10 +367,10 @@ int lua_checkmemory (lua_State *L) { | |||
367 | GCObject *o; | 367 | GCObject *o; |
368 | UpVal *uv; | 368 | UpVal *uv; |
369 | checkstack(g, g->mainthread); | 369 | checkstack(g, g->mainthread); |
370 | for (o = g->rootgc; o != obj2gco(g->mainthread); o = o->gch.next) | 370 | for (o = g->rootgc; o != NULL; o = gch(o)->next) |
371 | checkobject(g, o); | 371 | checkobject(g, o); |
372 | for (o = o->gch.next; o != NULL; o = o->gch.next) { | 372 | for (o = g->tmudata; o != NULL; o = gch(o)->next) { |
373 | lua_assert(o->gch.tt == LUA_TUSERDATA); | 373 | lua_assert(!isdead(g, o)); |
374 | checkobject(g, o); | 374 | checkobject(g, o); |
375 | } | 375 | } |
376 | for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { | 376 | for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { |
@@ -534,8 +534,10 @@ static int gcstate (lua_State *L) { | |||
534 | switch(G(L)->gcstate) { | 534 | switch(G(L)->gcstate) { |
535 | case GCSpropagate: lua_pushstring(L, "propagate"); break; | 535 | case GCSpropagate: lua_pushstring(L, "propagate"); break; |
536 | case GCSsweepstring: lua_pushstring(L, "sweep strings"); break; | 536 | case GCSsweepstring: lua_pushstring(L, "sweep strings"); break; |
537 | case GCSsweeptmu: lua_pushstring(L, "sweep udata with __gc"); break; | ||
537 | case GCSsweep: lua_pushstring(L, "sweep"); break; | 538 | case GCSsweep: lua_pushstring(L, "sweep"); break; |
538 | case GCSfinalize: lua_pushstring(L, "finalize"); break; | 539 | case GCSfinalize: lua_pushstring(L, "finalize"); break; |
540 | default: lua_assert(0); | ||
539 | } | 541 | } |
540 | return 1; | 542 | return 1; |
541 | } | 543 | } |
@@ -612,7 +614,7 @@ static int string_query (lua_State *L) { | |||
612 | else if (s < tb->size) { | 614 | else if (s < tb->size) { |
613 | GCObject *ts; | 615 | GCObject *ts; |
614 | int n = 0; | 616 | int n = 0; |
615 | for (ts = tb->hash[s]; ts; ts = ts->gch.next) { | 617 | for (ts = tb->hash[s]; ts; ts = gch(ts)->next) { |
616 | setsvalue2s(L, L->top, gco2ts(ts)); | 618 | setsvalue2s(L, L->top, gco2ts(ts)); |
617 | incr_top(L); | 619 | incr_top(L); |
618 | n++; | 620 | n++; |