aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lapi.c5
-rw-r--r--ldo.c8
-rw-r--r--ldo.h12
-rw-r--r--lgc.c3
-rw-r--r--ltm.c2
5 files changed, 10 insertions, 20 deletions
diff --git a/lapi.c b/lapi.c
index 3876956d..00bdd37a 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1286,13 +1286,14 @@ LUA_API void lua_toclose (lua_State *L, int idx) {
1286LUA_API void lua_concat (lua_State *L, int n) { 1286LUA_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
diff --git a/ldo.c b/ldo.c
index c30cde76..54518aff 100644
--- a/ldo.c
+++ b/ldo.c
@@ -416,7 +416,7 @@ static void rethook (lua_State *L, CallInfo *ci, int nres) {
416StkId luaD_tryfuncTM (lua_State *L, StkId func) { 416StkId 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++)
diff --git a/ldo.h b/ldo.h
index 1aa446ad..b050fc08 100644
--- a/ldo.h
+++ b/ldo.h
@@ -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' */
61typedef void (*Pfunc) (lua_State *L, void *ud); 49typedef void (*Pfunc) (lua_State *L, void *ud);
diff --git a/lgc.c b/lgc.c
index 0e4e5552..aa95c028 100644
--- a/lgc.c
+++ b/lgc.c
@@ -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
diff --git a/ltm.c b/ltm.c
index 07a06081..8e0d2222 100644
--- a/ltm.c
+++ b/ltm.c
@@ -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++)