diff options
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.200 2018/03/16 15:33:34 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.201 2018/05/22 12:02:36 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 | */ |
@@ -182,7 +182,7 @@ int luaD_reallocstack (lua_State *L, int newsize, int raiseerror) { | |||
182 | StkId newstack = luaM_reallocvector(L, L->stack, lim, newsize, StackValue); | 182 | StkId newstack = luaM_reallocvector(L, L->stack, lim, newsize, StackValue); |
183 | lua_assert(newsize <= LUAI_MAXSTACK || newsize == ERRORSTACKSIZE); | 183 | lua_assert(newsize <= LUAI_MAXSTACK || newsize == ERRORSTACKSIZE); |
184 | lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK); | 184 | lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK); |
185 | if (newstack == NULL) { /* reallocation failed? */ | 185 | if (unlikely(newstack == NULL)) { /* reallocation failed? */ |
186 | if (raiseerror) | 186 | if (raiseerror) |
187 | luaM_error(L); | 187 | luaM_error(L); |
188 | else return 0; /* do not raise an error */ | 188 | else return 0; /* do not raise an error */ |
@@ -204,7 +204,7 @@ int luaD_reallocstack (lua_State *L, int newsize, int raiseerror) { | |||
204 | int luaD_growstack (lua_State *L, int n, int raiseerror) { | 204 | int luaD_growstack (lua_State *L, int n, int raiseerror) { |
205 | int size = L->stacksize; | 205 | int size = L->stacksize; |
206 | int newsize = 2 * size; /* tentative new size */ | 206 | int newsize = 2 * size; /* tentative new size */ |
207 | if (size > LUAI_MAXSTACK) { /* need more space after extra size? */ | 207 | if (unlikely(size > LUAI_MAXSTACK)) { /* need more space after extra size? */ |
208 | if (raiseerror) | 208 | if (raiseerror) |
209 | luaD_throw(L, LUA_ERRERR); /* error inside message handler */ | 209 | luaD_throw(L, LUA_ERRERR); /* error inside message handler */ |
210 | else return 0; | 210 | else return 0; |
@@ -215,7 +215,7 @@ int luaD_growstack (lua_State *L, int n, int raiseerror) { | |||
215 | newsize = LUAI_MAXSTACK; | 215 | newsize = LUAI_MAXSTACK; |
216 | if (newsize < needed) /* but must respect what was asked for */ | 216 | if (newsize < needed) /* but must respect what was asked for */ |
217 | newsize = needed; | 217 | newsize = needed; |
218 | if (newsize > LUAI_MAXSTACK) { /* stack overflow? */ | 218 | if (unlikely(newsize > LUAI_MAXSTACK)) { /* stack overflow? */ |
219 | /* add extra size to be able to handle the error message */ | 219 | /* add extra size to be able to handle the error message */ |
220 | luaD_reallocstack(L, ERRORSTACKSIZE, raiseerror); | 220 | luaD_reallocstack(L, ERRORSTACKSIZE, raiseerror); |
221 | if (raiseerror) | 221 | if (raiseerror) |
@@ -350,7 +350,7 @@ static StkId rethook (lua_State *L, CallInfo *ci, StkId firstres, int nres) { | |||
350 | void luaD_tryfuncTM (lua_State *L, StkId func) { | 350 | void luaD_tryfuncTM (lua_State *L, StkId func) { |
351 | const TValue *tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); | 351 | const TValue *tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); |
352 | StkId p; | 352 | StkId p; |
353 | if (!ttisfunction(tm)) | 353 | if (unlikely(!ttisfunction(tm))) |
354 | luaG_typeerror(L, s2v(func), "call"); | 354 | luaG_typeerror(L, s2v(func), "call"); |
355 | for (p = L->top; p > func; p--) | 355 | for (p = L->top; p > func; p--) |
356 | setobjs2s(L, p, p-1); | 356 | setobjs2s(L, p, p-1); |
@@ -660,14 +660,14 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs, | |||
660 | L->nny = 0; /* allow yields */ | 660 | L->nny = 0; /* allow yields */ |
661 | api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); | 661 | api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); |
662 | status = luaD_rawrunprotected(L, resume, &nargs); | 662 | status = luaD_rawrunprotected(L, resume, &nargs); |
663 | if (status == -1) /* error calling 'lua_resume'? */ | 663 | if (unlikely(status == -1)) /* error calling 'lua_resume'? */ |
664 | status = LUA_ERRRUN; | 664 | status = LUA_ERRRUN; |
665 | else { /* continue running after recoverable errors */ | 665 | else { /* continue running after recoverable errors */ |
666 | while (errorstatus(status) && recover(L, status)) { | 666 | while (errorstatus(status) && recover(L, status)) { |
667 | /* unroll continuation */ | 667 | /* unroll continuation */ |
668 | status = luaD_rawrunprotected(L, unroll, &status); | 668 | status = luaD_rawrunprotected(L, unroll, &status); |
669 | } | 669 | } |
670 | if (errorstatus(status)) { /* unrecoverable error? */ | 670 | if (unlikely(errorstatus(status))) { /* unrecoverable error? */ |
671 | L->status = cast_byte(status); /* mark thread as 'dead' */ | 671 | L->status = cast_byte(status); /* mark thread as 'dead' */ |
672 | seterrorobj(L, status, L->top); /* push error message */ | 672 | seterrorobj(L, status, L->top); /* push error message */ |
673 | L->ci->top = L->top; | 673 | L->ci->top = L->top; |
@@ -694,7 +694,7 @@ LUA_API int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx, | |||
694 | luai_userstateyield(L, nresults); | 694 | luai_userstateyield(L, nresults); |
695 | lua_lock(L); | 695 | lua_lock(L); |
696 | api_checknelems(L, nresults); | 696 | api_checknelems(L, nresults); |
697 | if (L->nny > 0) { | 697 | if (unlikely(L->nny > 0)) { |
698 | if (L != G(L)->mainthread) | 698 | if (L != G(L)->mainthread) |
699 | luaG_runerror(L, "attempt to yield across a C-call boundary"); | 699 | luaG_runerror(L, "attempt to yield across a C-call boundary"); |
700 | else | 700 | else |
@@ -727,7 +727,7 @@ int luaD_pcall (lua_State *L, Pfunc func, void *u, | |||
727 | ptrdiff_t old_errfunc = L->errfunc; | 727 | ptrdiff_t old_errfunc = L->errfunc; |
728 | L->errfunc = ef; | 728 | L->errfunc = ef; |
729 | status = luaD_rawrunprotected(L, func, u); | 729 | status = luaD_rawrunprotected(L, func, u); |
730 | if (status != LUA_OK) { /* an error occurred? */ | 730 | if (unlikely(status != LUA_OK)) { /* an error occurred? */ |
731 | StkId oldtop = restorestack(L, old_top); | 731 | StkId oldtop = restorestack(L, old_top); |
732 | luaF_close(L, oldtop); /* close possible pending closures */ | 732 | luaF_close(L, oldtop); /* close possible pending closures */ |
733 | seterrorobj(L, status, oldtop); | 733 | seterrorobj(L, status, oldtop); |