aboutsummaryrefslogtreecommitdiff
path: root/lvm.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Towards release 5.4.7Roberto Ierusalimschy2024-04-261-1/+1
|
* Bug: Buffer overflow in string concatenationRoberto Ierusalimschy2023-12-211-1/+1
| | | | | Even if the string fits in size_t, the whole size of the TString object can overflow when we add the header.
* More disciplined use of 'getstr' and 'tsslen'Roberto Ierusalimschy2023-08-171-7/+10
| | | | | We may want to add other string variants in the future; this change documents better where the code may need to handle those variants.
* Bug: Call hook may be called twice when count hook yieldsRoberto Ierusalimschy2023-07-251-10/+3
| | | | | Took the opportunity and moved the code that controls call hooks in 'luaV_execute' into a function.
* Bug: read overflow in 'l_strcmp'Roberto Ierusalimschy2023-06-141-18/+20
| | | | | Equality according to 'strcoll' does not imply that strings have the same length.
* DetailsRoberto Ierusalimschy2023-05-151-4/+4
| | | | | - Better comments about short strings in opcodes. - luaH_newkey made static.
* Bug: Wrong line in error message for arith. errorsRoberto Ierusalimschy2023-02-081-0/+4
| | | | | It also causes 'L->top' to be wrong when the error happens, triggering an 'assert'.
* Stack indices changed to union'sRoberto Ierusalimschy2022-10-291-50/+50
| | | | | That will allow to change pointers to offsets while reallocating the stack.
* Negation in constant folding of '>>' may overflowRoberto Ierusalimschy2022-09-231-3/+1
|
* 'luaV_concat' can use invalidated pointer to stackRoberto Ierusalimschy2022-05-231-3/+3
| | | | Bug introduced in commit 42d40581.
* Save stack space while handling errorsRoberto Ierusalimschy2022-05-201-2/+4
| | | | | | | | | | Because error handling (luaG_errormsg) uses slots from EXTRA_STACK, and some errors can recur (e.g., string overflow while creating an error message in 'luaG_runerror', or a C-stack overflow before calling the message handler), the code should use stack slots with parsimony. This commit fixes the bug "Lua-stack overflow when C stack overflows while handling an error".
* DetailsRoberto Ierusalimschy2022-04-011-1/+1
| | | | | Comments + manual + identation + asserts about stack limits that were not allowing the use of the full stack
* Avoid computing invalid addressesRoberto Ierusalimschy2022-02-181-32/+89
| | | | | | luaV_execute should compute 'ra' only when the instruction uses it. Computing an illegal address is undefined behavior even if the address is never dereferenced.
* More uniform implementation for tail callsRoberto Ierusalimschy2021-10-291-14/+5
| | | | | | | | | | | 'luaD_pretailcall' mimics 'luaD_precall', handling call metamethods and calling C functions directly. That makes the code in the interpreter loop simpler. This commit also goes back to emulating the tail call in 'luaD_precall' with a goto, as C compilers may not do proper tail calls and the C stack can overflow much sooner than the Lua stack (which grows as the metamethod is added to it).
* DocumentationRoberto Ierusalimschy2021-10-111-1/+1
| | | | | Better explanation about the guaranties of multiple assignment in the manual.
* Using 'inline' in some functionsRoberto Ierusalimschy2021-09-151-6/+6
| | | | | According to ISO C, "making a function an inline function suggests that calls to the function be as fast as possible." (Not available in C89.)
* 'luaD_tryfuncTM' checks stack space by itselfRoberto Ierusalimschy2021-08-181-5/+6
|
* Undo simplification of tail calls (commit 901d760)Roberto Ierusalimschy2021-08-181-4/+17
| | | | Not that simpler and slower.
* Bug: Negation in 'luaV_shiftr' may overflowRoberto Ierusalimschy2021-07-221-1/+1
| | | | Negation of an unchecked lua_Integer overflows with mininteger.
* Simplification in the parameters of 'luaD_precall'Roberto Ierusalimschy2021-06-301-2/+2
| | | | | | The parameters 'nresults' and 'delta1', in 'luaD_precall', were never meaningful simultaneously. So, they were combined in a single parameter 'retdel'.
* C functions can be tail called, tooRoberto Ierusalimschy2021-06-141-8/+1
| | | | | A tail call to a C function can have the behavior of a "real" tail call, reusing the stack frame of the caller.
* Simpler implementation for tail callsRoberto Ierusalimschy2021-06-111-13/+7
| | | | | Tail calls handled by 'luaD_precall', like regular calls, to avoid code duplication.
* Bug: yielding in '__close' mess up number of returnsRoberto Ierusalimschy2021-04-161-1/+11
| | | | | Yielding in a __close metamethod called when returning vararg results changes the top and so messes up the number of returned values.
* Bug: Lua source should not use C99 comments ("//")Roberto Ierusalimschy2021-04-101-2/+4
|
* Don't use tointegerns when luaV_tointegerns will doRoberto Ierusalimschy2021-02-241-2/+7
| | | | | | | | Some places don't need the "fast path" macro tointegerns, either because speed is not essential (lcode.c) or because the value is not supposed to be an integer already (luaV_equalobj and luaG_tointerror). Moreover, luaV_equalobj should always use F2Ieq, even if Lua is compiled to "round to floor".
* DetailsRoberto Ierusalimschy2021-02-241-2/+2
| | | | | Added documentation and asserts that constants for arithmetic opcodes must be numbers.
* Broadening the use of branch hintsRoberto Ierusalimschy2021-02-241-19/+20
| | | | | | More uses of macros 'likely'/'unlikely' (renamed to 'l_likely'/'l_unlikely'), both in range (extended to the libraries) and in scope (extended to hooks, stack growth).
* New implementation for to-be-closed variablesRoberto Ierusalimschy2021-02-091-4/+2
| | | | | | | | To-be-closed variables are linked in their own list, embedded into the stack elements. (Due to alignment, this information does not change the size of the stack elements in most architectures.) This new list does not produce garbage and avoids memory errors when creating tbc variables.
* Fixed some bugs around stack reallocationRoberto Ierusalimschy2021-02-051-0/+2
| | | | Long time without using HARDSTACKTESTS...
* Allow yields inside '__close' metamethodsRoberto Ierusalimschy2021-01-131-3/+7
| | | | | | | 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.
* Cleaner handling of errors in '__close' metamethodsRoberto Ierusalimschy2020-12-281-1/+1
| | | | | Instead of protecting each individual metamethod call, protect the entire call to 'luaF_close'.
* Changes in the API of 'luaH_set' and related functionsRoberto Ierusalimschy2020-12-041-4/+1
| | | | | 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.
* Fixed wrong trace of vararg functionsRoberto Ierusalimschy2020-10-191-20/+25
| | | | | Trace of vararg functions was skipping an instruction when returning from a call. (Bug introduced by commit 5d8ce05b3.)
* No more field 'lua_State.stacksize'Roberto Ierusalimschy2020-10-121-1/+1
| | | | | | 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.
* Correct handling of 'luaV_execute' invocationsRoberto Ierusalimschy2020-10-121-12/+13
| | | | | | | | | 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-121-3/+3
| | | | | | - more organized handling of 'nCcalls' - comments - deprecation of 'setcstacklimit'
* Back to a stackless implementationRoberto Ierusalimschy2020-10-121-7/+20
| | | | | | | | | | | | | 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.
* Fixed bug: invalid 'oldpc' when returning to a functionRoberto Ierusalimschy2020-07-171-1/+1
| | | | | | | | | | The field 'L->oldpc' is not always updated when control returns to a function; an invalid value can seg. fault when computing 'changedline'. (One example is an error in a finalizer; control can return to 'luaV_execute' without executing 'luaD_poscall'.) Instead of trying to fix all possible corner cases, it seems safer to be resilient to invalid values for 'oldpc'. Valid but wrong values at most cause an extra call to a line hook.
* Fixed bug of access violation in finalizersRoberto Ierusalimschy2020-07-081-4/+3
| | | | | | Errors in finalizers need a valid 'pc' to produce an error message, even if the error is not propagated. Therefore, calls to the GC (which may call finalizers) inside luaV_execute must save the 'pc'.
* Fixed bugs of stack reallocation x GCRoberto Ierusalimschy2020-07-071-1/+1
| | | | | | | | Macro 'checkstackGC' was doing a GC step after resizing the stack; the GC could shrink the stack and undo the resize. Moreover, macro 'checkstackp' also does a GC step, which could remove the preallocated CallInfo when calling a function. (Its name has been changed to 'checkstackGCp' to emphasize that it calls the GC.)
* 'luaV_concat' can "concat" one single valueRoberto Ierusalimschy2020-07-031-5/+4
| | | | | Several of its callers needed that case and had to do the check themselves.
* DetailsRoberto Ierusalimschy2020-02-271-6/+7
| | | | | Several details in code (e.g., moving a variable to the most inner scope that encloses its uses), comments, parameter names, extra tests.
* OP_LOADFALSE broken in two instructionsRoberto Ierusalimschy2020-02-111-1/+5
|
* Clearer distinction between types and tagsRoberto Ierusalimschy2020-01-311-12/+12
| | | | | LUA_T* represents only types; tags (types + Variants) are represented by LUA_V* constants.
* Changed internal representation of booleansRoberto Ierusalimschy2020-01-061-7/+12
| | | | | | | Instead of an explicit value (field 'b'), true and false use different tag variants. This avoids reading an extra field and results in more direct code. (Most code that uses booleans needs to distinguish between true and false anyway.)
* Comment about LUA_COMPAT_LT_LE moved to proper placeRoberto Ierusalimschy2019-12-101-6/+3
|
* Simplifications in 'op_arith*' family of macrosRoberto Ierusalimschy2019-12-051-47/+27
|
* Using an enumeration for float->integer coercion modesRoberto Ierusalimschy2019-12-051-14/+11
|
* 'l_mathlim' renamed to 'l_floatatt'Roberto Ierusalimschy2019-12-051-1/+1
| | | | That macro is applied to float attributes, not to limits.
* Better comments about the use of 'k' in opcodesRoberto Ierusalimschy2019-12-051-11/+11
|