summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lapi.c14
-rw-r--r--ldebug.c4
-rw-r--r--ldo.h6
-rw-r--r--lgc.c4
-rw-r--r--ltm.c15
-rw-r--r--lvm.c4
6 files changed, 26 insertions, 21 deletions
diff --git a/lapi.c b/lapi.c
index 072190bc..9daf0545 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.255 2015/09/09 13:45:50 roberto Exp roberto $ 2** $Id: lapi.c,v 2.256 2015/10/06 16:10:22 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -121,11 +121,11 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
121 lua_lock(to); 121 lua_lock(to);
122 api_checknelems(from, n); 122 api_checknelems(from, n);
123 api_check(from, G(from) == G(to), "moving among independent states"); 123 api_check(from, G(from) == G(to), "moving among independent states");
124 api_check(from, to->ci->top - to->top >= n, "not enough elements to move"); 124 api_check(from, to->ci->top - to->top >= n, "stack overflow");
125 from->top -= n; 125 from->top -= n;
126 for (i = 0; i < n; i++) { 126 for (i = 0; i < n; i++) {
127 setobj2s(to, to->top, from->top + i); 127 setobj2s(to, to->top, from->top + i);
128 api_incr_top(to); 128 to->top++; /* stack already checked by previous 'api_check' */
129 } 129 }
130 lua_unlock(to); 130 lua_unlock(to);
131} 131}
@@ -918,10 +918,10 @@ LUA_API void lua_callk (lua_State *L, int nargs, int nresults,
918 if (k != NULL && L->nny == 0) { /* need to prepare continuation? */ 918 if (k != NULL && L->nny == 0) { /* need to prepare continuation? */
919 L->ci->u.c.k = k; /* save continuation */ 919 L->ci->u.c.k = k; /* save continuation */
920 L->ci->u.c.ctx = ctx; /* save context */ 920 L->ci->u.c.ctx = ctx; /* save context */
921 luaD_call(L, func, nresults, 1); /* do the call */ 921 luaD_call(L, func, nresults); /* do the call */
922 } 922 }
923 else /* no continuation or no yieldable */ 923 else /* no continuation or no yieldable */
924 luaD_call(L, func, nresults, 0); /* just do the call */ 924 luaD_callnoyield(L, func, nresults); /* just do the call */
925 adjustresults(L, nresults); 925 adjustresults(L, nresults);
926 lua_unlock(L); 926 lua_unlock(L);
927} 927}
@@ -939,7 +939,7 @@ struct CallS { /* data to 'f_call' */
939 939
940static void f_call (lua_State *L, void *ud) { 940static void f_call (lua_State *L, void *ud) {
941 struct CallS *c = cast(struct CallS *, ud); 941 struct CallS *c = cast(struct CallS *, ud);
942 luaD_call(L, c->func, c->nresults, 0); 942 luaD_callnoyield(L, c->func, c->nresults);
943} 943}
944 944
945 945
@@ -977,7 +977,7 @@ LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc,
977 L->errfunc = func; 977 L->errfunc = func;
978 setoah(ci->callstatus, L->allowhook); /* save value of 'allowhook' */ 978 setoah(ci->callstatus, L->allowhook); /* save value of 'allowhook' */
979 ci->callstatus |= CIST_YPCALL; /* function can do error recovery */ 979 ci->callstatus |= CIST_YPCALL; /* function can do error recovery */
980 luaD_call(L, c.func, nresults, 1); /* do the call */ 980 luaD_call(L, c.func, nresults); /* do the call */
981 ci->callstatus &= ~CIST_YPCALL; 981 ci->callstatus &= ~CIST_YPCALL;
982 L->errfunc = ci->u.c.old_errfunc; 982 L->errfunc = ci->u.c.old_errfunc;
983 status = LUA_OK; /* if it is here, there were no errors */ 983 status = LUA_OK; /* if it is here, there were no errors */
diff --git a/ldebug.c b/ldebug.c
index 211806bb..da0fd7a4 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 2.115 2015/05/22 17:45:56 roberto Exp roberto $ 2** $Id: ldebug.c,v 2.116 2015/10/22 14:40:47 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -618,7 +618,7 @@ l_noret luaG_errormsg (lua_State *L) {
618 setobjs2s(L, L->top, L->top - 1); /* move argument */ 618 setobjs2s(L, L->top, L->top - 1); /* move argument */
619 setobjs2s(L, L->top - 1, errfunc); /* push function */ 619 setobjs2s(L, L->top - 1, errfunc); /* push function */
620 L->top++; /* assume EXTRA_STACK */ 620 L->top++; /* assume EXTRA_STACK */
621 luaD_call(L, L->top - 2, 1, 0); /* call it */ 621 luaD_callnoyield(L, L->top - 2, 1); /* call it */
622 } 622 }
623 luaD_throw(L, LUA_ERRRUN); 623 luaD_throw(L, LUA_ERRRUN);
624} 624}
diff --git a/ldo.h b/ldo.h
index 31986dc0..de6988fd 100644
--- a/ldo.h
+++ b/ldo.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.h,v 2.23 2015/10/21 18:40:47 roberto Exp roberto $ 2** $Id: ldo.h,v 2.24 2015/11/02 16:09:30 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*/
@@ -40,8 +40,8 @@ LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
40 const char *mode); 40 const char *mode);
41LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); 41LUAI_FUNC void luaD_hook (lua_State *L, int event, int line);
42LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 42LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
43LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults, 43LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
44 int allowyield); 44LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults);
45LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 45LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
46 ptrdiff_t oldtop, ptrdiff_t ef); 46 ptrdiff_t oldtop, ptrdiff_t ef);
47LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult, int nres); 47LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult, int nres);
diff --git a/lgc.c b/lgc.c
index 837b1cc3..47aa05e2 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.207 2015/09/08 15:41:05 roberto Exp roberto $ 2** $Id: lgc.c,v 2.208 2015/11/02 16:19:29 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -797,7 +797,7 @@ static GCObject *udata2finalize (global_State *g) {
797 797
798static void dothecall (lua_State *L, void *ud) { 798static void dothecall (lua_State *L, void *ud) {
799 UNUSED(ud); 799 UNUSED(ud);
800 luaD_call(L, L->top - 2, 0, 0); 800 luaD_callnoyield(L, L->top - 2, 0);
801} 801}
802 802
803 803
diff --git a/ltm.c b/ltm.c
index 3a763204..06408307 100644
--- a/ltm.c
+++ b/ltm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.c,v 2.33 2014/11/21 12:15:57 roberto Exp roberto $ 2** $Id: ltm.c,v 2.34 2015/03/30 15:42:27 roberto Exp roberto $
3** Tag methods 3** Tag methods
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -86,13 +86,18 @@ const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
86void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, 86void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1,
87 const TValue *p2, TValue *p3, int hasres) { 87 const TValue *p2, TValue *p3, int hasres) {
88 ptrdiff_t result = savestack(L, p3); 88 ptrdiff_t result = savestack(L, p3);
89 setobj2s(L, L->top++, f); /* push function (assume EXTRA_STACK) */ 89 StkId func = L->top;
90 setobj2s(L, L->top++, p1); /* 1st argument */ 90 setobj2s(L, func, f); /* push function (assume EXTRA_STACK) */
91 setobj2s(L, L->top++, p2); /* 2nd argument */ 91 setobj2s(L, func + 1, p1); /* 1st argument */
92 setobj2s(L, func + 2, p2); /* 2nd argument */
93 L->top += 3;
92 if (!hasres) /* no result? 'p3' is third argument */ 94 if (!hasres) /* no result? 'p3' is third argument */
93 setobj2s(L, L->top++, p3); /* 3rd argument */ 95 setobj2s(L, L->top++, p3); /* 3rd argument */
94 /* metamethod may yield only when called from Lua code */ 96 /* metamethod may yield only when called from Lua code */
95 luaD_call(L, L->top - (4 - hasres), hasres, isLua(L->ci)); 97 if (isLua(L->ci))
98 luaD_call(L, func, hasres);
99 else
100 luaD_callnoyield(L, func, hasres);
96 if (hasres) { /* if has result, move it to its place */ 101 if (hasres) { /* if has result, move it to its place */
97 p3 = restorestack(L, result); 102 p3 = restorestack(L, result);
98 setobjs2s(L, p3, --L->top); 103 setobjs2s(L, p3, --L->top);
diff --git a/lvm.c b/lvm.c
index 27ade135..8894df99 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.258 2015/11/02 11:43:17 roberto Exp roberto $ 2** $Id: lvm.c,v 2.259 2015/11/02 14:06:01 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -1226,7 +1226,7 @@ void luaV_execute (lua_State *L) {
1226 setobjs2s(L, cb+1, ra+1); 1226 setobjs2s(L, cb+1, ra+1);
1227 setobjs2s(L, cb, ra); 1227 setobjs2s(L, cb, ra);
1228 L->top = cb + 3; /* func. + 2 args (state and index) */ 1228 L->top = cb + 3; /* func. + 2 args (state and index) */
1229 Protect(luaD_call(L, cb, GETARG_C(i), 1)); 1229 Protect(luaD_call(L, cb, GETARG_C(i)));
1230 L->top = ci->top; 1230 L->top = ci->top;
1231 i = *(ci->u.l.savedpc++); /* go to next instruction */ 1231 i = *(ci->u.l.savedpc++); /* go to next instruction */
1232 ra = RA(i); 1232 ra = RA(i);