From 2dc91ca5eef37890e03ed4c14054d4eb38c0b250 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 28 Aug 2012 15:30:45 -0300 Subject: [PATCH] checks garbage collector every time it calls a function (as the stack can grow and so allocates more memory) --- ldo.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ldo.c b/ldo.c index f1095822..dd0bf405 100644 --- a/ldo.c +++ b/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 2.105 2012/06/08 15:14:04 roberto Exp roberto $ +** $Id: ldo.c,v 2.106 2012/06/29 19:23:33 roberto Exp roberto $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -311,6 +311,7 @@ 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); @@ -338,6 +339,7 @@ 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 +395,6 @@ void luaD_call (lua_State *L, StkId func, int nResults, int allowyield) { luaV_execute(L); /* call it */ if (!allowyield) L->nny--; L->nCcalls--; - luaC_checkGC(L); } @@ -473,7 +474,7 @@ static int recover (lua_State *L, int status) { static l_noret resume_error (lua_State *L, const char *msg, StkId firstArg) { L->top = firstArg; /* remove args from the stack */ setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */ - incr_top(L); + api_incr_top(L); luaD_throw(L, -1); /* jump back to 'lua_resume' */ }