diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-08-16 15:55:49 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-08-16 15:55:49 -0300 |
commit | 439d74e29f3234a034777f88b260523afe8c0446 (patch) | |
tree | a3ee160dccfd3cf0f065edbba07290c4ba9af93d /lstate.c | |
parent | 3679d33b02782ff7d7d0fa163b815902b189c89e (diff) | |
download | lua-439d74e29f3234a034777f88b260523afe8c0446.tar.gz lua-439d74e29f3234a034777f88b260523afe8c0446.tar.bz2 lua-439d74e29f3234a034777f88b260523afe8c0446.zip |
added 'local' bit (true => object is only refered by local variables)
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 2.100 2013/08/05 16:58:28 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.101 2013/08/07 12:18:11 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -159,17 +159,19 @@ static void freestack (lua_State *L) { | |||
159 | ** Create registry table and its predefined values | 159 | ** Create registry table and its predefined values |
160 | */ | 160 | */ |
161 | static void init_registry (lua_State *L, global_State *g) { | 161 | static void init_registry (lua_State *L, global_State *g) { |
162 | TValue mt; | 162 | TValue temp; |
163 | /* create registry */ | 163 | /* create registry */ |
164 | Table *registry = luaH_new(L); | 164 | Table *registry = luaH_new(L); |
165 | sethvalue(L, &g->l_registry, registry); | 165 | sethvalue(L, &g->l_registry, registry); |
166 | luaH_resize(L, registry, LUA_RIDX_LAST, 0); | 166 | luaH_resize(L, registry, LUA_RIDX_LAST, 0); |
167 | nolocal(obj2gco(registry)); | ||
167 | /* registry[LUA_RIDX_MAINTHREAD] = L */ | 168 | /* registry[LUA_RIDX_MAINTHREAD] = L */ |
168 | setthvalue(L, &mt, L); | 169 | setthvalue(L, &temp, L); /* temp = L */ |
169 | luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &mt); | 170 | luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &temp); |
170 | /* registry[LUA_RIDX_GLOBALS] = table of globals */ | 171 | /* registry[LUA_RIDX_GLOBALS] = table of globals */ |
171 | sethvalue(L, &mt, luaH_new(L)); | 172 | sethvalue(L, &temp, luaH_new(L)); /* temp = new table (global table) */ |
172 | luaH_setint(L, registry, LUA_RIDX_GLOBALS, &mt); | 173 | luaH_setint(L, registry, LUA_RIDX_GLOBALS, &temp); |
174 | valnolocal(&temp); /* keep local invariant */ | ||
173 | } | 175 | } |
174 | 176 | ||
175 | 177 | ||
@@ -236,6 +238,7 @@ LUA_API lua_State *lua_newthread (lua_State *L) { | |||
236 | setthvalue(L, L->top, L1); | 238 | setthvalue(L, L->top, L1); |
237 | api_incr_top(L); | 239 | api_incr_top(L); |
238 | preinit_state(L1, G(L)); | 240 | preinit_state(L1, G(L)); |
241 | nolocal(obj2gco(L1)); /* threads are never local */ | ||
239 | L1->hookmask = L->hookmask; | 242 | L1->hookmask = L->hookmask; |
240 | L1->basehookcount = L->basehookcount; | 243 | L1->basehookcount = L->basehookcount; |
241 | L1->hook = L->hook; | 244 | L1->hook = L->hook; |
@@ -268,7 +271,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { | |||
268 | L->next = NULL; | 271 | L->next = NULL; |
269 | L->tt = LUA_TTHREAD; | 272 | L->tt = LUA_TTHREAD; |
270 | g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT); | 273 | g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT); |
271 | L->marked = luaC_white(g); | 274 | L->marked = luaC_white(g) | bitmask(LOCALBIT); |
272 | g->gckind = KGC_NORMAL; | 275 | g->gckind = KGC_NORMAL; |
273 | preinit_state(L, g); | 276 | preinit_state(L, g); |
274 | g->frealloc = f; | 277 | g->frealloc = f; |