diff options
Diffstat (limited to '')
-rw-r--r-- | lapi.c | 5 | ||||
-rw-r--r-- | ldo.c | 8 | ||||
-rw-r--r-- | ldo.h | 12 | ||||
-rw-r--r-- | lgc.c | 3 | ||||
-rw-r--r-- | ltm.c | 2 |
5 files changed, 10 insertions, 20 deletions
@@ -1286,13 +1286,14 @@ LUA_API void lua_toclose (lua_State *L, int idx) { | |||
1286 | LUA_API void lua_concat (lua_State *L, int n) { | 1286 | LUA_API void lua_concat (lua_State *L, int n) { |
1287 | lua_lock(L); | 1287 | lua_lock(L); |
1288 | api_checknelems(L, n); | 1288 | api_checknelems(L, n); |
1289 | if (n > 0) | 1289 | if (n > 0) { |
1290 | luaV_concat(L, n); | 1290 | luaV_concat(L, n); |
1291 | luaC_checkGC(L); | ||
1292 | } | ||
1291 | else { /* nothing to concatenate */ | 1293 | else { /* nothing to concatenate */ |
1292 | setsvalue2s(L, L->top.p, luaS_newlstr(L, "", 0)); /* push empty string */ | 1294 | setsvalue2s(L, L->top.p, luaS_newlstr(L, "", 0)); /* push empty string */ |
1293 | api_incr_top(L); | 1295 | api_incr_top(L); |
1294 | } | 1296 | } |
1295 | luaC_checkGC(L); | ||
1296 | lua_unlock(L); | 1297 | lua_unlock(L); |
1297 | } | 1298 | } |
1298 | 1299 | ||
@@ -416,7 +416,7 @@ static void rethook (lua_State *L, CallInfo *ci, int nres) { | |||
416 | StkId luaD_tryfuncTM (lua_State *L, StkId func) { | 416 | StkId luaD_tryfuncTM (lua_State *L, StkId func) { |
417 | const TValue *tm; | 417 | const TValue *tm; |
418 | StkId p; | 418 | StkId p; |
419 | checkstackGCp(L, 1, func); /* space for metamethod */ | 419 | checkstackp(L, 1, func); /* space for metamethod */ |
420 | tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); /* (after previous GC) */ | 420 | tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); /* (after previous GC) */ |
421 | if (l_unlikely(ttisnil(tm))) | 421 | if (l_unlikely(ttisnil(tm))) |
422 | luaG_callerror(L, s2v(func)); /* nothing to call */ | 422 | luaG_callerror(L, s2v(func)); /* nothing to call */ |
@@ -521,7 +521,7 @@ l_sinline int precallC (lua_State *L, StkId func, int nresults, | |||
521 | lua_CFunction f) { | 521 | lua_CFunction f) { |
522 | int n; /* number of returns */ | 522 | int n; /* number of returns */ |
523 | CallInfo *ci; | 523 | CallInfo *ci; |
524 | checkstackGCp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ | 524 | checkstackp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ |
525 | L->ci = ci = prepCallInfo(L, func, nresults, CIST_C, | 525 | L->ci = ci = prepCallInfo(L, func, nresults, CIST_C, |
526 | L->top.p + LUA_MINSTACK); | 526 | L->top.p + LUA_MINSTACK); |
527 | lua_assert(ci->top.p <= L->stack_last.p); | 527 | lua_assert(ci->top.p <= L->stack_last.p); |
@@ -557,7 +557,7 @@ int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, | |||
557 | int fsize = p->maxstacksize; /* frame size */ | 557 | int fsize = p->maxstacksize; /* frame size */ |
558 | int nfixparams = p->numparams; | 558 | int nfixparams = p->numparams; |
559 | int i; | 559 | int i; |
560 | checkstackGCp(L, fsize - delta, func); | 560 | checkstackp(L, fsize - delta, func); |
561 | ci->func.p -= delta; /* restore 'func' (if vararg) */ | 561 | ci->func.p -= delta; /* restore 'func' (if vararg) */ |
562 | for (i = 0; i < narg1; i++) /* move down function and arguments */ | 562 | for (i = 0; i < narg1; i++) /* move down function and arguments */ |
563 | setobjs2s(L, ci->func.p + i, func + i); | 563 | setobjs2s(L, ci->func.p + i, func + i); |
@@ -604,7 +604,7 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) { | |||
604 | int narg = cast_int(L->top.p - func) - 1; /* number of real arguments */ | 604 | int narg = cast_int(L->top.p - func) - 1; /* number of real arguments */ |
605 | int nfixparams = p->numparams; | 605 | int nfixparams = p->numparams; |
606 | int fsize = p->maxstacksize; /* frame size */ | 606 | int fsize = p->maxstacksize; /* frame size */ |
607 | checkstackGCp(L, fsize, func); | 607 | checkstackp(L, fsize, func); |
608 | L->ci = ci = prepCallInfo(L, func, nresults, 0, func + 1 + fsize); | 608 | L->ci = ci = prepCallInfo(L, func, nresults, 0, func + 1 + fsize); |
609 | ci->u.l.savedpc = p->code; /* starting point */ | 609 | ci->u.l.savedpc = p->code; /* starting point */ |
610 | for (; narg < nfixparams; narg++) | 610 | for (; narg < nfixparams; narg++) |
@@ -44,18 +44,6 @@ | |||
44 | p = restorestack(L, t__)) /* 'pos' part: restore 'p' */ | 44 | p = restorestack(L, t__)) /* 'pos' part: restore 'p' */ |
45 | 45 | ||
46 | 46 | ||
47 | /* macro to check stack size and GC, preserving 'p' */ | ||
48 | #define checkstackGCp(L,n,p) \ | ||
49 | luaD_checkstackaux(L, n, \ | ||
50 | ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \ | ||
51 | luaC_checkGC(L), /* stack grow uses memory */ \ | ||
52 | p = restorestack(L, t__)) /* 'pos' part: restore 'p' */ | ||
53 | |||
54 | |||
55 | /* macro to check stack size and GC */ | ||
56 | #define checkstackGC(L,fsize) \ | ||
57 | luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0) | ||
58 | |||
59 | 47 | ||
60 | /* type of protected functions, to be ran by 'runprotected' */ | 48 | /* type of protected functions, to be ran by 'runprotected' */ |
61 | typedef void (*Pfunc) (lua_State *L, void *ud); | 49 | typedef void (*Pfunc) (lua_State *L, void *ud); |
@@ -1700,8 +1700,9 @@ static void fullinc (lua_State *L, global_State *g) { | |||
1700 | /* finish any pending sweep phase to start a new cycle */ | 1700 | /* finish any pending sweep phase to start a new cycle */ |
1701 | luaC_runtilstate(L, bitmask(GCSpause)); | 1701 | luaC_runtilstate(L, bitmask(GCSpause)); |
1702 | luaC_runtilstate(L, bitmask(GCScallfin)); /* run up to finalizers */ | 1702 | luaC_runtilstate(L, bitmask(GCScallfin)); /* run up to finalizers */ |
1703 | luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */ | ||
1704 | /* estimate must be correct after a full GC cycle */ | 1703 | /* estimate must be correct after a full GC cycle */ |
1704 | lua_assert(g->marked == gettotalobjs(g)); | ||
1705 | luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */ | ||
1705 | setpause(g); | 1706 | setpause(g); |
1706 | } | 1707 | } |
1707 | 1708 | ||
@@ -260,7 +260,7 @@ void luaT_getvarargs (lua_State *L, CallInfo *ci, StkId where, int wanted) { | |||
260 | int nextra = ci->u.l.nextraargs; | 260 | int nextra = ci->u.l.nextraargs; |
261 | if (wanted < 0) { | 261 | if (wanted < 0) { |
262 | wanted = nextra; /* get all extra arguments available */ | 262 | wanted = nextra; /* get all extra arguments available */ |
263 | checkstackGCp(L, nextra, where); /* ensure stack space */ | 263 | checkstackp(L, nextra, where); /* ensure stack space */ |
264 | L->top.p = where + nextra; /* next instruction will need top */ | 264 | L->top.p = where + nextra; /* next instruction will need top */ |
265 | } | 265 | } |
266 | for (i = 0; i < wanted && i < nextra; i++) | 266 | for (i = 0; i < wanted && i < nextra; i++) |