diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-09-11 09:26:14 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-09-11 09:26:14 -0300 |
| commit | 115087344797d0aafb23f4fe5b902fdebd2c3310 (patch) | |
| tree | 732c83cee53b9d67b83cebfc2e5debd30d48eeed /lstate.c | |
| parent | 79ab21be90792c00da98e5ec3d55c8a082c6e6de (diff) | |
| download | lua-115087344797d0aafb23f4fe5b902fdebd2c3310.tar.gz lua-115087344797d0aafb23f4fe5b902fdebd2c3310.tar.bz2 lua-115087344797d0aafb23f4fe5b902fdebd2c3310.zip | |
'luaC_newobj' does not handle special cases; only special case
now is threads, which do not use 'luaC_newobj' anymore.
Diffstat (limited to 'lstate.c')
| -rw-r--r-- | lstate.c | 18 |
1 files changed, 11 insertions, 7 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.c,v 2.110 2013/09/03 15:37:10 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.111 2013/09/05 19:31:49 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 | */ |
| @@ -237,16 +237,20 @@ static void close_state (lua_State *L) { | |||
| 237 | 237 | ||
| 238 | 238 | ||
| 239 | LUA_API lua_State *lua_newthread (lua_State *L) { | 239 | LUA_API lua_State *lua_newthread (lua_State *L) { |
| 240 | global_State *g = G(L); | ||
| 240 | lua_State *L1; | 241 | lua_State *L1; |
| 241 | lua_lock(L); | 242 | lua_lock(L); |
| 242 | luaC_checkGC(L); | 243 | luaC_checkGC(L); |
| 243 | /* create new thread, linked after 'l_registry' */ | 244 | /* create new thread */ |
| 244 | L1 = &luaC_newobj(L, LUA_TTHREAD, sizeof(LX), | 245 | L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; |
| 245 | &hvalue(&G(L)->l_registry)->next, offsetof(LX, l))->th; | 246 | L1->marked = luaC_white(g) | bitmask(LOCALMARK) | bitmask(NOLOCALBIT); |
| 247 | L1->tt = LUA_TTHREAD; | ||
| 248 | /* link it after 'l_registry' */ | ||
| 249 | L1->next = hvalue(&g->l_registry)->next; | ||
| 250 | hvalue(&g->l_registry)->next = obj2gco(L1); | ||
| 246 | setthvalue(L, L->top, L1); | 251 | setthvalue(L, L->top, L1); |
| 247 | api_incr_top(L); | 252 | api_incr_top(L); |
| 248 | preinit_state(L1, G(L)); | 253 | preinit_state(L1, g); |
| 249 | nolocal(obj2gco(L1)); /* threads are never local */ | ||
| 250 | L1->hookmask = L->hookmask; | 254 | L1->hookmask = L->hookmask; |
| 251 | L1->basehookcount = L->basehookcount; | 255 | L1->basehookcount = L->basehookcount; |
| 252 | L1->hook = L->hook; | 256 | L1->hook = L->hook; |
| @@ -279,7 +283,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { | |||
| 279 | L->next = NULL; | 283 | L->next = NULL; |
| 280 | L->tt = LUA_TTHREAD; | 284 | L->tt = LUA_TTHREAD; |
| 281 | g->currentwhite = bitmask(WHITE0BIT); | 285 | g->currentwhite = bitmask(WHITE0BIT); |
| 282 | L->marked = luaC_white(g) | bitmask(LOCALBIT); | 286 | L->marked = luaC_white(g) | bitmask(NOLOCALBIT); |
| 283 | g->gckind = KGC_NORMAL; | 287 | g->gckind = KGC_NORMAL; |
| 284 | preinit_state(L, g); | 288 | preinit_state(L, g); |
| 285 | g->frealloc = f; | 289 | g->frealloc = f; |
