diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-03-30 13:05:23 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-03-30 13:05:23 -0300 |
commit | 484bf14a6bac3174900f0b7783f41c5b3bab0217 (patch) | |
tree | f84b259fa5afdbc154efdb025559c10d0e0db564 | |
parent | abb2f5511d0cc2cabf9a1bf82f47a72e62f59e4f (diff) | |
download | lua-484bf14a6bac3174900f0b7783f41c5b3bab0217.tar.gz lua-484bf14a6bac3174900f0b7783f41c5b3bab0217.tar.bz2 lua-484bf14a6bac3174900f0b7783f41c5b3bab0217.zip |
calls to 'luaC_checkGC' in luaD_precall moved near to 'luaD_checkstack'
(which is what can need memory)
-rw-r--r-- | ldo.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.135 2014/11/11 17:13:39 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.136 2015/03/06 19:49:50 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -323,6 +323,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { | |||
323 | case LUA_TCCL: { /* C closure */ | 323 | case LUA_TCCL: { /* C closure */ |
324 | f = clCvalue(func)->f; | 324 | f = clCvalue(func)->f; |
325 | Cfunc: | 325 | Cfunc: |
326 | luaC_checkGC(L); /* stack grow uses memory */ | ||
326 | luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ | 327 | luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ |
327 | ci = next_ci(L); /* now 'enter' new function */ | 328 | ci = next_ci(L); /* now 'enter' new function */ |
328 | ci->nresults = nresults; | 329 | ci->nresults = nresults; |
@@ -330,7 +331,6 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { | |||
330 | ci->top = L->top + LUA_MINSTACK; | 331 | ci->top = L->top + LUA_MINSTACK; |
331 | lua_assert(ci->top <= L->stack_last); | 332 | lua_assert(ci->top <= L->stack_last); |
332 | ci->callstatus = 0; | 333 | ci->callstatus = 0; |
333 | luaC_checkGC(L); /* stack grow uses memory */ | ||
334 | if (L->hookmask & LUA_MASKCALL) | 334 | if (L->hookmask & LUA_MASKCALL) |
335 | luaD_hook(L, LUA_HOOKCALL, -1); | 335 | luaD_hook(L, LUA_HOOKCALL, -1); |
336 | lua_unlock(L); | 336 | lua_unlock(L); |
@@ -344,6 +344,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { | |||
344 | StkId base; | 344 | StkId base; |
345 | Proto *p = clLvalue(func)->p; | 345 | Proto *p = clLvalue(func)->p; |
346 | n = cast_int(L->top - func) - 1; /* number of real arguments */ | 346 | n = cast_int(L->top - func) - 1; /* number of real arguments */ |
347 | luaC_checkGC(L); /* stack grow uses memory */ | ||
347 | luaD_checkstack(L, p->maxstacksize); | 348 | luaD_checkstack(L, p->maxstacksize); |
348 | for (; n < p->numparams; n++) | 349 | for (; n < p->numparams; n++) |
349 | setnilvalue(L->top++); /* complete missing arguments */ | 350 | setnilvalue(L->top++); /* complete missing arguments */ |
@@ -364,7 +365,6 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { | |||
364 | ci->u.l.savedpc = p->code; /* starting point */ | 365 | ci->u.l.savedpc = p->code; /* starting point */ |
365 | ci->callstatus = CIST_LUA; | 366 | ci->callstatus = CIST_LUA; |
366 | L->top = ci->top; | 367 | L->top = ci->top; |
367 | luaC_checkGC(L); /* stack grow uses memory */ | ||
368 | if (L->hookmask & LUA_MASKCALL) | 368 | if (L->hookmask & LUA_MASKCALL) |
369 | callhook(L, ci); | 369 | callhook(L, ci); |
370 | return 0; | 370 | return 0; |
@@ -393,7 +393,7 @@ int luaD_poscall (lua_State *L, StkId firstResult) { | |||
393 | } | 393 | } |
394 | res = ci->func; /* res == final position of 1st result */ | 394 | res = ci->func; /* res == final position of 1st result */ |
395 | wanted = ci->nresults; | 395 | wanted = ci->nresults; |
396 | L->ci = ci = ci->previous; /* back to caller */ | 396 | L->ci = ci->previous; /* back to caller */ |
397 | /* move results to correct place */ | 397 | /* move results to correct place */ |
398 | for (i = wanted; i != 0 && firstResult < L->top; i--) | 398 | for (i = wanted; i != 0 && firstResult < L->top; i--) |
399 | setobjs2s(L, res++, firstResult++); | 399 | setobjs2s(L, res++, firstResult++); |