From 484bf14a6bac3174900f0b7783f41c5b3bab0217 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 30 Mar 2015 13:05:23 -0300 Subject: calls to 'luaC_checkGC' in luaD_precall moved near to 'luaD_checkstack' (which is what can need memory) --- ldo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ldo.c b/ldo.c index ffe9a8da..c47d9a49 100644 --- a/ldo.c +++ b/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 ** 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 */ f = clCvalue(func)->f; Cfunc: + luaC_checkGC(L); /* stack grow uses memory */ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ ci = next_ci(L); /* now 'enter' new function */ ci->nresults = nresults; @@ -330,7 +331,6 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { ci->top = L->top + LUA_MINSTACK; lua_assert(ci->top <= L->stack_last); ci->callstatus = 0; - luaC_checkGC(L); /* stack grow uses memory */ if (L->hookmask & LUA_MASKCALL) luaD_hook(L, LUA_HOOKCALL, -1); lua_unlock(L); @@ -344,6 +344,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { StkId base; Proto *p = clLvalue(func)->p; n = cast_int(L->top - func) - 1; /* number of real arguments */ + luaC_checkGC(L); /* stack grow uses memory */ luaD_checkstack(L, p->maxstacksize); for (; n < p->numparams; n++) 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->callstatus = CIST_LUA; L->top = ci->top; - luaC_checkGC(L); /* stack grow uses memory */ if (L->hookmask & LUA_MASKCALL) callhook(L, ci); return 0; @@ -393,7 +393,7 @@ int luaD_poscall (lua_State *L, StkId firstResult) { } res = ci->func; /* res == final position of 1st result */ wanted = ci->nresults; - L->ci = ci = ci->previous; /* back to caller */ + L->ci = ci->previous; /* back to caller */ /* move results to correct place */ for (i = wanted; i != 0 && firstResult < L->top; i--) setobjs2s(L, res++, firstResult++); -- cgit v1.2.3-55-g6feb