diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-08-19 11:16:33 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-08-19 11:16:33 -0300 |
| commit | 8e6b7ef9ab226b9184d300ad1b14c3812a6e86d8 (patch) | |
| tree | 3267567b2110b418d4fa8fccd1054c710e123924 | |
| parent | caceeab750ed80e94f8ec763248ae04cd90fefb5 (diff) | |
| download | lua-8e6b7ef9ab226b9184d300ad1b14c3812a6e86d8.tar.gz lua-8e6b7ef9ab226b9184d300ad1b14c3812a6e86d8.tar.bz2 lua-8e6b7ef9ab226b9184d300ad1b14c3812a6e86d8.zip | |
new function 'isgclocal' + test for GC consistency of prototype's caches
| -rw-r--r-- | ltests.c | 19 |
1 files changed, 16 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltests.c,v 2.143 2013/08/16 19:02:31 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.144 2013/08/18 16:12:18 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 | */ |
| @@ -203,6 +203,8 @@ static int testobjref2 (GCObject *f, GCObject *t) { | |||
| 203 | UpVal *uv = gco2uv(f); | 203 | UpVal *uv = gco2uv(f); |
| 204 | return (uv->v != &uv->value); /* open upvalue can point to local stuff */ | 204 | return (uv->v != &uv->value); /* open upvalue can point to local stuff */ |
| 205 | } | 205 | } |
| 206 | if (gch(f)->tt == LUA_TPROTO && gch(t)->tt == LUA_TLCL) | ||
| 207 | return 1; /* cache from a prototype */ | ||
| 206 | return 0; | 208 | return 0; |
| 207 | } | 209 | } |
| 208 | 210 | ||
| @@ -274,6 +276,7 @@ static void checktable (global_State *g, Table *h) { | |||
| 274 | static void checkproto (global_State *g, Proto *f) { | 276 | static void checkproto (global_State *g, Proto *f) { |
| 275 | int i; | 277 | int i; |
| 276 | GCObject *fgc = obj2gco(f); | 278 | GCObject *fgc = obj2gco(f); |
| 279 | if (f->cache) checkobjref(g, fgc, f->cache); | ||
| 277 | if (f->source) checkobjref(g, fgc, f->source); | 280 | if (f->source) checkobjref(g, fgc, f->source); |
| 278 | for (i=0; i<f->sizek; i++) { | 281 | for (i=0; i<f->sizek; i++) { |
| 279 | if (ttisstring(f->k+i)) | 282 | if (ttisstring(f->k+i)) |
| @@ -634,7 +637,7 @@ static int settrick (lua_State *L) { | |||
| 634 | } | 637 | } |
| 635 | 638 | ||
| 636 | 639 | ||
| 637 | static int get_gccolor (lua_State *L) { | 640 | static int gc_color (lua_State *L) { |
| 638 | TValue *o; | 641 | TValue *o; |
| 639 | luaL_checkany(L, 1); | 642 | luaL_checkany(L, 1); |
| 640 | o = obj_at(L, 1); | 643 | o = obj_at(L, 1); |
| @@ -647,6 +650,15 @@ static int get_gccolor (lua_State *L) { | |||
| 647 | } | 650 | } |
| 648 | 651 | ||
| 649 | 652 | ||
| 653 | static int gc_local (lua_State *L) { | ||
| 654 | TValue *o; | ||
| 655 | luaL_checkany(L, 1); | ||
| 656 | o = obj_at(L, 1); | ||
| 657 | lua_pushboolean(L, !iscollectable(o) || islocal(gcvalue(o))); | ||
| 658 | return 1; | ||
| 659 | } | ||
| 660 | |||
| 661 | |||
| 650 | static int gc_state (lua_State *L) { | 662 | static int gc_state (lua_State *L) { |
| 651 | static const char *statenames[] = {"propagate", "atomic", | 663 | static const char *statenames[] = {"propagate", "atomic", |
| 652 | "sweepstring", "sweepudata", "sweep", "pause", ""}; | 664 | "sweepstring", "sweepudata", "sweep", "pause", ""}; |
| @@ -1447,7 +1459,8 @@ static const struct luaL_Reg tests_funcs[] = { | |||
| 1447 | {"d2s", d2s}, | 1459 | {"d2s", d2s}, |
| 1448 | {"doonnewstack", doonnewstack}, | 1460 | {"doonnewstack", doonnewstack}, |
| 1449 | {"doremote", doremote}, | 1461 | {"doremote", doremote}, |
| 1450 | {"gccolor", get_gccolor}, | 1462 | {"gccolor", gc_color}, |
| 1463 | {"isgclocal", gc_local}, | ||
| 1451 | {"gcstate", gc_state}, | 1464 | {"gcstate", gc_state}, |
| 1452 | {"getref", getref}, | 1465 | {"getref", getref}, |
| 1453 | {"hash", hash_query}, | 1466 | {"hash", hash_query}, |
