diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-08-28 15:30:45 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-08-28 15:30:45 -0300 |
commit | 2dc91ca5eef37890e03ed4c14054d4eb38c0b250 (patch) | |
tree | 5685e873b530c90e730416313bbccf24bc9a2f35 /ldo.c | |
parent | a3e1c40d6d6fb81db9d8b58aee69466f715aab5c (diff) | |
download | lua-2dc91ca5eef37890e03ed4c14054d4eb38c0b250.tar.gz lua-2dc91ca5eef37890e03ed4c14054d4eb38c0b250.tar.bz2 lua-2dc91ca5eef37890e03ed4c14054d4eb38c0b250.zip |
checks garbage collector every time it calls a function (as the
stack can grow and so allocates more memory)
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.105 2012/06/08 15:14:04 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.106 2012/06/29 19:23:33 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 | */ |
@@ -311,6 +311,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { | |||
311 | ci->top = L->top + LUA_MINSTACK; | 311 | ci->top = L->top + LUA_MINSTACK; |
312 | lua_assert(ci->top <= L->stack_last); | 312 | lua_assert(ci->top <= L->stack_last); |
313 | ci->callstatus = 0; | 313 | ci->callstatus = 0; |
314 | luaC_checkGC(L); /* stack grow uses memory */ | ||
314 | if (L->hookmask & LUA_MASKCALL) | 315 | if (L->hookmask & LUA_MASKCALL) |
315 | luaD_hook(L, LUA_HOOKCALL, -1); | 316 | luaD_hook(L, LUA_HOOKCALL, -1); |
316 | lua_unlock(L); | 317 | lua_unlock(L); |
@@ -338,6 +339,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { | |||
338 | ci->u.l.savedpc = p->code; /* starting point */ | 339 | ci->u.l.savedpc = p->code; /* starting point */ |
339 | ci->callstatus = CIST_LUA; | 340 | ci->callstatus = CIST_LUA; |
340 | L->top = ci->top; | 341 | L->top = ci->top; |
342 | luaC_checkGC(L); /* stack grow uses memory */ | ||
341 | if (L->hookmask & LUA_MASKCALL) | 343 | if (L->hookmask & LUA_MASKCALL) |
342 | callhook(L, ci); | 344 | callhook(L, ci); |
343 | return 0; | 345 | return 0; |
@@ -393,7 +395,6 @@ void luaD_call (lua_State *L, StkId func, int nResults, int allowyield) { | |||
393 | luaV_execute(L); /* call it */ | 395 | luaV_execute(L); /* call it */ |
394 | if (!allowyield) L->nny--; | 396 | if (!allowyield) L->nny--; |
395 | L->nCcalls--; | 397 | L->nCcalls--; |
396 | luaC_checkGC(L); | ||
397 | } | 398 | } |
398 | 399 | ||
399 | 400 | ||
@@ -473,7 +474,7 @@ static int recover (lua_State *L, int status) { | |||
473 | static l_noret resume_error (lua_State *L, const char *msg, StkId firstArg) { | 474 | static l_noret resume_error (lua_State *L, const char *msg, StkId firstArg) { |
474 | L->top = firstArg; /* remove args from the stack */ | 475 | L->top = firstArg; /* remove args from the stack */ |
475 | setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */ | 476 | setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */ |
476 | incr_top(L); | 477 | api_incr_top(L); |
477 | luaD_throw(L, -1); /* jump back to 'lua_resume' */ | 478 | luaD_throw(L, -1); /* jump back to 'lua_resume' */ |
478 | } | 479 | } |
479 | 480 | ||