calls to 'luaC_checkGC' in luaD_precall moved near to 'luaD_checkstack'
(which is what can need memory)
This commit is contained in:
8
ldo.c
8
ldo.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldo.c,v 2.135 2014/11/11 17:13:39 roberto Exp roberto $
|
** $Id: ldo.c,v 2.136 2015/03/06 19:49:50 roberto Exp roberto $
|
||||||
** Stack and Call structure of Lua
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -323,6 +323,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
|
|||||||
case LUA_TCCL: { /* C closure */
|
case LUA_TCCL: { /* C closure */
|
||||||
f = clCvalue(func)->f;
|
f = clCvalue(func)->f;
|
||||||
Cfunc:
|
Cfunc:
|
||||||
|
luaC_checkGC(L); /* stack grow uses memory */
|
||||||
luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
|
luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
|
||||||
ci = next_ci(L); /* now 'enter' new function */
|
ci = next_ci(L); /* now 'enter' new function */
|
||||||
ci->nresults = nresults;
|
ci->nresults = nresults;
|
||||||
@@ -330,7 +331,6 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
|
|||||||
ci->top = L->top + LUA_MINSTACK;
|
ci->top = L->top + LUA_MINSTACK;
|
||||||
lua_assert(ci->top <= L->stack_last);
|
lua_assert(ci->top <= L->stack_last);
|
||||||
ci->callstatus = 0;
|
ci->callstatus = 0;
|
||||||
luaC_checkGC(L); /* stack grow uses memory */
|
|
||||||
if (L->hookmask & LUA_MASKCALL)
|
if (L->hookmask & LUA_MASKCALL)
|
||||||
luaD_hook(L, LUA_HOOKCALL, -1);
|
luaD_hook(L, LUA_HOOKCALL, -1);
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
@@ -344,6 +344,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
|
|||||||
StkId base;
|
StkId base;
|
||||||
Proto *p = clLvalue(func)->p;
|
Proto *p = clLvalue(func)->p;
|
||||||
n = cast_int(L->top - func) - 1; /* number of real arguments */
|
n = cast_int(L->top - func) - 1; /* number of real arguments */
|
||||||
|
luaC_checkGC(L); /* stack grow uses memory */
|
||||||
luaD_checkstack(L, p->maxstacksize);
|
luaD_checkstack(L, p->maxstacksize);
|
||||||
for (; n < p->numparams; n++)
|
for (; n < p->numparams; n++)
|
||||||
setnilvalue(L->top++); /* complete missing arguments */
|
setnilvalue(L->top++); /* complete missing arguments */
|
||||||
@@ -364,7 +365,6 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
|
|||||||
ci->u.l.savedpc = p->code; /* starting point */
|
ci->u.l.savedpc = p->code; /* starting point */
|
||||||
ci->callstatus = CIST_LUA;
|
ci->callstatus = CIST_LUA;
|
||||||
L->top = ci->top;
|
L->top = ci->top;
|
||||||
luaC_checkGC(L); /* stack grow uses memory */
|
|
||||||
if (L->hookmask & LUA_MASKCALL)
|
if (L->hookmask & LUA_MASKCALL)
|
||||||
callhook(L, ci);
|
callhook(L, ci);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -393,7 +393,7 @@ int luaD_poscall (lua_State *L, StkId firstResult) {
|
|||||||
}
|
}
|
||||||
res = ci->func; /* res == final position of 1st result */
|
res = ci->func; /* res == final position of 1st result */
|
||||||
wanted = ci->nresults;
|
wanted = ci->nresults;
|
||||||
L->ci = ci = ci->previous; /* back to caller */
|
L->ci = ci->previous; /* back to caller */
|
||||||
/* move results to correct place */
|
/* move results to correct place */
|
||||||
for (i = wanted; i != 0 && firstResult < L->top; i--)
|
for (i = wanted; i != 0 && firstResult < L->top; i--)
|
||||||
setobjs2s(L, res++, firstResult++);
|
setobjs2s(L, res++, firstResult++);
|
||||||
|
|||||||
Reference in New Issue
Block a user