diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-09-11 11:09:55 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-09-11 11:09:55 -0300 |
| commit | dd373a8f665e5e22ad3ad75401aa9fe3bbb2afc8 (patch) | |
| tree | d475246f43edc6de6e1ebf491b274e9d9a5c1c24 /lstate.c | |
| parent | 7061fe1d56f40e9d22a226423079da808fb41f66 (diff) | |
| download | lua-dd373a8f665e5e22ad3ad75401aa9fe3bbb2afc8.tar.gz lua-dd373a8f665e5e22ad3ad75401aa9fe3bbb2afc8.tar.bz2 lua-dd373a8f665e5e22ad3ad75401aa9fe3bbb2afc8.zip | |
threads are kept in a separated GC list, linked after the main thread
Diffstat (limited to 'lstate.c')
| -rw-r--r-- | lstate.c | 20 |
1 files changed, 6 insertions, 14 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.c,v 2.111 2013/09/05 19:31:49 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.112 2013/09/11 12:26:14 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 | */ |
| @@ -165,14 +165,6 @@ static void init_registry (lua_State *L, global_State *g) { | |||
| 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 | nolocal(obj2gco(registry)); |
| 168 | /* registry is the first "regular" object created by a state; move it | ||
| 169 | from 'localgc' to 'allgc' so that it act as a "sentinel" there */ | ||
| 170 | lua_assert(g->allgc == NULL && | ||
| 171 | registry->next == NULL && | ||
| 172 | g->localgc == obj2gco(registry)); | ||
| 173 | g->allgc = g->localgc; | ||
| 174 | g->localgc = NULL; | ||
| 175 | l_setbit(registry->marked, LOCALMARK); /* mark that it is not in 'localgc' */ | ||
| 176 | /* registry[LUA_RIDX_MAINTHREAD] = L */ | 168 | /* registry[LUA_RIDX_MAINTHREAD] = L */ |
| 177 | setthvalue(L, &temp, L); /* temp = L */ | 169 | setthvalue(L, &temp, L); /* temp = L */ |
| 178 | luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &temp); | 170 | luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &temp); |
| @@ -243,11 +235,11 @@ LUA_API lua_State *lua_newthread (lua_State *L) { | |||
| 243 | luaC_checkGC(L); | 235 | luaC_checkGC(L); |
| 244 | /* create new thread */ | 236 | /* create new thread */ |
| 245 | L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; | 237 | L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; |
| 246 | L1->marked = luaC_white(g) | bitmask(LOCALMARK) | bitmask(NOLOCALBIT); | 238 | L1->marked = luaC_white(g) | bit2mask(NOLOCALBIT, LOCALMARK); |
| 247 | L1->tt = LUA_TTHREAD; | 239 | L1->tt = LUA_TTHREAD; |
| 248 | /* link it after 'l_registry' */ | 240 | /* link it on list of threads */ |
| 249 | L1->next = hvalue(&g->l_registry)->next; | 241 | L1->next = g->mainthread->next; |
| 250 | hvalue(&g->l_registry)->next = obj2gco(L1); | 242 | g->mainthread->next = obj2gco(L1); |
| 251 | setthvalue(L, L->top, L1); | 243 | setthvalue(L, L->top, L1); |
| 252 | api_incr_top(L); | 244 | api_incr_top(L); |
| 253 | preinit_state(L1, g); | 245 | preinit_state(L1, g); |
| @@ -283,7 +275,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { | |||
| 283 | L->next = NULL; | 275 | L->next = NULL; |
| 284 | L->tt = LUA_TTHREAD; | 276 | L->tt = LUA_TTHREAD; |
| 285 | g->currentwhite = bitmask(WHITE0BIT); | 277 | g->currentwhite = bitmask(WHITE0BIT); |
| 286 | L->marked = luaC_white(g) | bitmask(NOLOCALBIT); | 278 | L->marked = luaC_white(g) | bit2mask(NOLOCALBIT, LOCALMARK); |
| 287 | g->gckind = KGC_NORMAL; | 279 | g->gckind = KGC_NORMAL; |
| 288 | preinit_state(L, g); | 280 | preinit_state(L, g); |
| 289 | g->frealloc = f; | 281 | g->frealloc = f; |
