diff options
Diffstat (limited to '')
-rw-r--r-- | ldo.c | 30 |
1 files changed, 27 insertions, 3 deletions
@@ -139,6 +139,16 @@ l_noret luaD_throw (lua_State *L, TStatus errcode) { | |||
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||
142 | l_noret luaD_throwbaselevel (lua_State *L, TStatus errcode) { | ||
143 | if (L->errorJmp) { | ||
144 | /* unroll error entries up to the first level */ | ||
145 | while (L->errorJmp->previous != NULL) | ||
146 | L->errorJmp = L->errorJmp->previous; | ||
147 | } | ||
148 | luaD_throw(L, errcode); | ||
149 | } | ||
150 | |||
151 | |||
142 | TStatus luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { | 152 | TStatus luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { |
143 | l_uint32 oldnCcalls = L->nCcalls; | 153 | l_uint32 oldnCcalls = L->nCcalls; |
144 | struct lua_longjmp lj; | 154 | struct lua_longjmp lj; |
@@ -164,6 +174,20 @@ TStatus luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { | |||
164 | #define STACKERRSPACE 200 | 174 | #define STACKERRSPACE 200 |
165 | 175 | ||
166 | 176 | ||
177 | /* | ||
178 | ** LUAI_MAXSTACK limits the size of the Lua stack. | ||
179 | ** It must fit into INT_MAX/2. | ||
180 | */ | ||
181 | |||
182 | #if !defined(LUAI_MAXSTACK) | ||
183 | #if 1000000 < (INT_MAX / 2) | ||
184 | #define LUAI_MAXSTACK 1000000 | ||
185 | #else | ||
186 | #define LUAI_MAXSTACK (INT_MAX / 2u) | ||
187 | #endif | ||
188 | #endif | ||
189 | |||
190 | |||
167 | /* maximum stack size that respects size_t */ | 191 | /* maximum stack size that respects size_t */ |
168 | #define MAXSTACK_BYSIZET ((MAX_SIZET / sizeof(StackValue)) - STACKERRSPACE) | 192 | #define MAXSTACK_BYSIZET ((MAX_SIZET / sizeof(StackValue)) - STACKERRSPACE) |
169 | 193 | ||
@@ -199,7 +223,7 @@ l_noret luaD_errerr (lua_State *L) { | |||
199 | ** The following macro chooses how strict is the code. | 223 | ** The following macro chooses how strict is the code. |
200 | */ | 224 | */ |
201 | #if !defined(LUAI_STRICT_ADDRESS) | 225 | #if !defined(LUAI_STRICT_ADDRESS) |
202 | #define LUAI_STRICT_ADDRESS 0 | 226 | #define LUAI_STRICT_ADDRESS 1 |
203 | #endif | 227 | #endif |
204 | 228 | ||
205 | #if LUAI_STRICT_ADDRESS | 229 | #if LUAI_STRICT_ADDRESS |
@@ -319,7 +343,7 @@ int luaD_growstack (lua_State *L, int n, int raiseerror) { | |||
319 | return 0; /* if not 'raiseerror', just signal it */ | 343 | return 0; /* if not 'raiseerror', just signal it */ |
320 | } | 344 | } |
321 | else if (n < MAXSTACK) { /* avoids arithmetic overflows */ | 345 | else if (n < MAXSTACK) { /* avoids arithmetic overflows */ |
322 | int newsize = 2 * size; /* tentative new size */ | 346 | int newsize = size + (size >> 1); /* tentative new size (size * 1.5) */ |
323 | int needed = cast_int(L->top.p - L->stack.p) + n; | 347 | int needed = cast_int(L->top.p - L->stack.p) + n; |
324 | if (newsize > MAXSTACK) /* cannot cross the limit */ | 348 | if (newsize > MAXSTACK) /* cannot cross the limit */ |
325 | newsize = MAXSTACK; | 349 | newsize = MAXSTACK; |
@@ -513,7 +537,7 @@ l_sinline void genmoveresults (lua_State *L, StkId res, int nres, | |||
513 | ** to 'res'. Handle most typical cases (zero results for commands, | 537 | ** to 'res'. Handle most typical cases (zero results for commands, |
514 | ** one result for expressions, multiple results for tail calls/single | 538 | ** one result for expressions, multiple results for tail calls/single |
515 | ** parameters) separated. The flag CIST_TBC in 'fwanted', if set, | 539 | ** parameters) separated. The flag CIST_TBC in 'fwanted', if set, |
516 | ** forces the swicth to go to the default case. | 540 | ** forces the switch to go to the default case. |
517 | */ | 541 | */ |
518 | l_sinline void moveresults (lua_State *L, StkId res, int nres, | 542 | l_sinline void moveresults (lua_State *L, StkId res, int nres, |
519 | l_uint32 fwanted) { | 543 | l_uint32 fwanted) { |