aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Simpler handling of errors when creating tbc variablesRoberto Ierusalimschy2021-01-196-35/+25
| | | | | | New field 'lua_State.ptbc' keeps to-be-closed variable until its upvalue is created, so that it can be closed in case of a memory-allocation error.
* Allow yields in '__close' metamethods ater errorsRoberto Ierusalimschy2021-01-183-71/+126
| | | | | | Completes commit b07fc10e91a. '__close' metamethods can yield even when they are being called due to an error. '__close' metamethods from C functions are still not allowed to yield.
* Corrected documentation for 'table.sort'Roberto Ierusalimschy2021-01-141-8/+8
| | | | | The sort function must define a (strict) weak order for a correct sorting. A partial order is not enough.
* Allow yields inside '__close' metamethodsRoberto Ierusalimschy2021-01-137-18/+114
| | | | | | | Initial implementation to allow yields inside '__close' metamethods. This current version still does not allow a '__close' metamethod to yield when called due to an error. '__close' metamethods from C functions also are not allowed to yield.
* New API function 'lua_closeslot'Roberto Ierusalimschy2021-01-116-29/+66
| | | | | | Closing a to-be-closed variable with 'lua_settop' is too restrictive, as it erases all slots above the variable. Moreover, it adds side effects to 'lua_settop', which should be a fairly basic function.
* Handles '__close' errors in coroutines in "coroutine style"Roberto Ierusalimschy2020-12-302-22/+85
| | | | | Errors in '__close' metamethods in coroutines are handled by the same logic that handles other errors, through 'recover'.
* Do not insert nil values into tablesRoberto Ierusalimschy2020-12-291-0/+2
|
* Better error messages for calling non-callable objectsRoberto Ierusalimschy2020-12-296-11/+52
| | | | | | | When available, use the calling code to find a suitable name for what was being called; this is particularly useful for errors of non-callable metamethods. This commit also improved the debug information for order metamethods.
* No need to recheck close method before calling itRoberto Ierusalimschy2020-12-292-27/+63
| | | | | | | | A to-be-closed variable is constant and it must have a close metamethod when it is created. A program has to go out of its way (e.g., by changing the variable's metamethod) to invalidate that check. So, it is not worth to test that again. If the program tampers with the metamethod, Lua will raise a regular error when attempting to call it.
* Reset thread before panickingRoberto Ierusalimschy2020-12-283-14/+15
| | | | | Before panicking, it is simpler to reset the thread instead of closing its variables and adjust the top manually.
* Cleaner handling of errors in '__close' metamethodsRoberto Ierusalimschy2020-12-287-75/+80
| | | | | Instead of protecting each individual metamethod call, protect the entire call to 'luaF_close'.
* Report last error in closing methodsRoberto Ierusalimschy2020-12-225-101/+35
| | | | | When there are multiple errors around closing methods, report the last error instead of the original.
* Upvalues removed from 'openupval' before being closedRoberto Ierusalimschy2020-12-213-26/+31
| | | | | | | Undo commit c220b0a5d0: '__close' is not called again in case of errors. (Upvalue is removed from the list before the call.) The common error that justified that change was C stack overflows, which are much rarer with the stackless implementation.
* 'coroutine.close'/'lua_resetthread' report original errorsRoberto Ierusalimschy2020-12-185-15/+40
| | | | | | Besides errors in closing methods, 'coroutine.close' and 'lua_resetthread' also consider the original error that stopped the thread, if any.
* Cleaner handling of floats in pack/unpackRoberto Ierusalimschy2020-12-161-29/+41
|
* Cleaner definition for macro 'ttisclosure'Roberto Ierusalimschy2020-12-161-1/+2
|
* Review of asserts in 'ltests.c'Roberto Ierusalimschy2020-12-081-56/+70
| | | | The module 'ltests.c' must work correctly with asserts off, too.
* Details (do not affect regular code)Roberto Ierusalimschy2020-12-074-3/+31
| | | | | | | * Avoids multiple definitions of 'lua_assert' in test file. * Smaller C-stack limit in test mode. * Note in the manual about the use of false * Extra test for constant reuse.
* Changes in the API of 'luaH_set' and related functionsRoberto Ierusalimschy2020-12-046-40/+58
| | | | | Functions to set values in a table (luaH_set, luaH_newkey, etc.) receive the new value, instead of returning a slot where to put the value.
* Added test cases for error messages about goto/labelRoberto Ierusalimschy2020-12-031-0/+21
|
* n Windows, 'popen' accepts "[rw][bt]?" as valid modesRoberto Ierusalimschy2020-12-031-6/+12
| | | | Added the modifiers 'b' and 't' to valid modes for 'popen' in Windows.
* Avoid "bad programming habits" in the reference systemRoberto Ierusalimschy2020-12-031-6/+18
| | | | | | References were using both 0 indices and nils as values in arrays. Both do not fit in the concept of a sequence, which is the kind of use that guides all Lua optimizations.
* 'lua_assert' moved from 'lualib.h' to 'lauxlib.h'Roberto Ierusalimschy2020-12-032-6/+12
| | | | | | The macro is useful also in 'lauxlib.c', which does not include 'lualib.h'. Also, the definition was corrected to be "on" when LUAI_ASSERT is defined.
* DetailsRoberto Ierusalimschy2020-12-025-32/+32
| | | | Names in the parser and other details that do not change actual code.
* Changed access to global table in the registryRoberto Ierusalimschy2020-11-262-14/+20
| | | | | The global table is always in the array part of the registry; we can use this fact to make its access slightly more efficient.
* Avoid using 'signal' when 'sigaction' is availableRoberto Ierusalimschy2020-11-241-3/+23
| | | | | The semantics of 'signal' varies a lot among different implementations; 'sigaction' ensures a more consistent behavior.
* Optimization for 'n^2'v5.4.2Roberto Ierusalimschy2020-11-131-1/+2
| | | | | Squares are much more common than other exponentiations, and 'n*n' is much more efficient than 'pow'.
* Compiler optimization back to '-O2'Roberto Ierusalimschy2020-11-111-10/+0
| | | | Undo commit 6a10f03ff. Compiler performance is important, too.
* Removed optimization for «if ... then goto»Roberto Ierusalimschy2020-11-112-66/+6
| | | | | That optimization was too complex and caused some weird traces when debugging. The more common case «if ... then break» was kept.
* Bug when growing a stackRoberto Ierusalimschy2020-11-083-4/+4
| | | | | | When a stack grows, its extra area can be in use, and it becomes part of the common area. So, the extra area must be kept correct all the times. (Bug introduced by commit 5aa36e894f5.)
* 'luaL_newstate' should not allocate extra memoryRoberto Ierusalimschy2020-11-033-26/+50
| | | | | | | | The allocation of a userdata for the state of the warn system can cause a panic if it fails; 'luaL_ref' also can fail. This commit re-implements the warn system so that it does not need an explicit state. Instead, the system uses different functions to represent the different states.
* DetailsRoberto Ierusalimschy2020-10-304-18/+30
| | | | | | - small corrections in the manual - ldo.c: 'docall' -> 'ccall' ('docall' already used in 'lua.c') - comments
* _PROMPT can have non-string valuesRoberto Ierusalimschy2020-10-262-6/+37
| | | | | | 'get_prompt' uses 'luaL_tolstring' to convert _PROMPT or _PROMPT2 value to a string. That conversion may invoke a '__tostring' metamethod.
* CommentsRoberto Ierusalimschy2020-10-223-26/+34
|
* Fixed wrong trace of vararg functionsRoberto Ierusalimschy2020-10-192-20/+35
| | | | | Trace of vararg functions was skipping an instruction when returning from a call. (Bug introduced by commit 5d8ce05b3.)
* Fixed compiler option -DHARDSTACKTESTS to commit 5aa36e8Roberto Ierusalimschy2020-10-191-1/+1
|
* Fixed bug of keys removed from tables vs 'next'Roberto Ierusalimschy2020-10-144-27/+67
| | | | | | Fixed the bug that a key removed from a table might not be found again by 'next'. (This is needed to allow keys to be removed during a traversal.) This bug was introduced in commit 73ec04fc.
* New release number (5.4.2)Roberto Ierusalimschy2020-10-121-1/+1
|
* 'lua_upvalueid' returns NULL on invalid upvalue indexRoberto Ierusalimschy2020-10-124-15/+33
|
* Hash always use all characters in a long stringRoberto Ierusalimschy2020-10-124-20/+6
| | | | | | | Hashes for long strings are computed only when they are used as keys in a table, not a too common case. And, in that case, it is to easy to force collisions changing only the characters which are not part of the hash.
* DetailsRoberto Ierusalimschy2020-10-124-14/+45
| | | | | | | - After converting a generic GCObject to a specific type ('gco2*'), avoid using the original GCObject (to reduce aliasing). - Small corrections in comments in 'lopcodes.h' - Added tests about who calls __close metamethods
* 'recover' finish of 'luaD_pcall' should follow the originalRoberto Ierusalimschy2020-10-122-7/+25
|
* No more field 'lua_State.stacksize'Roberto Ierusalimschy2020-10-126-26/+29
| | | | | | The stack size is derived from 'stack_last', when needed. Moreover, the handling of stack sizes is more consistent, always excluding the extra space except when allocating/deallocating the array.
* Avoid shrinking stacks to oftenRoberto Ierusalimschy2020-10-122-17/+87
| | | | | | Shrink a stack only when the final stack size can be at most 2/3 the previous size with half of its entries empty. This commit also improves the clarity of 'luaD_growstack'.
* No need for 'volatile' in string.pack/unpackRoberto Ierusalimschy2020-10-121-10/+7
| | | | Type punning an address to 'char *' should be always safe.
* Avoid GCs when testing stack overflowRoberto Ierusalimschy2020-10-121-6/+14
| | | | | A GC step may invoke some finalizer, which may error and emit a warning due to stack overflfow.
* Correct handling of 'luaV_execute' invocationsRoberto Ierusalimschy2020-10-125-32/+37
| | | | | | | | | The previous stackless implementations marked all 'luaV_execute' invocations as fresh. However, re-entering 'luaV_execute' when resuming a coroutine should not be a fresh invocation. (It works because 'unroll' called 'luaV_execute' for each call entry, but it was slower than letting 'luaV_execute' finish all non-fresh invocations.)
* Revision of stackless implementationRoberto Ierusalimschy2020-10-1212-283/+127
| | | | | | - more organized handling of 'nCcalls' - comments - deprecation of 'setcstacklimit'
* Back to a stackless implementationRoberto Ierusalimschy2020-10-1211-95/+72
| | | | | | | | | | | | | A "with stack" implementation gains too little in performance to be worth all the noise from C-stack overflows. This commit is almost a sketch, to test performance. There are several pending stuff: - review control of C-stack overflow and error messages; - what to do with setcstacklimit; - review comments; - review unroll of Lua calls.
* Wrong cast in 'str_unpack'Roberto Ierusalimschy2020-09-301-1/+1
|