aboutsummaryrefslogtreecommitdiff
path: root/ldo.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Error object cannot be nilRoberto Ierusalimschy2025-02-281-3/+7
| | | | | Lua will change a nil as error object to a string message, so that it never reports an error with nil as the error object.
* '__close' gets no error object if there is no errorRoberto Ierusalimschy2025-02-281-4/+0
| | | | | Instead of receiving nil as a second argument, __close metamethods are called with just one argument when there are no errors.
* Added macro LUAI_STRICT_ADDRESSRoberto Ierusalimschy2025-02-181-10/+18
| | | | | By default, the code assumes it is safe to use a dealocated pointer as long as the code does not access it.
* Main thread is a regular field of global_StateRoberto Ierusalimschy2025-01-311-4/+5
| | | | | They were already allocated as a single block, so there is no need for the global_State to point to its main thread.
* New type 'TStatus' for thread status/error codesRoberto Ierusalimschy2025-01-301-22/+23
|
* CallInfo bit CIST_CLSRET broken in twoRoberto Ierusalimschy2025-01-281-5/+7
| | | | | | | | | Since commit f407b3c4a, it was being used for two distinct (and incompatible) meanings: A: Function has TBC variables (now bit CIST_TBC) B: Interpreter is closing TBC variables (original bit CIST_CLSRET) B implies A, but A does not imply B.
* fixing 'lua_status' in panic.Roberto Ierusalimschy2025-01-161-0/+1
| | | | | 'luaD_throw' may call 'luaE_resetthread', which returns an error code but clears 'L->status'; so, 'luaD_throw' should set that status again.
* DetailsRoberto Ierusalimschy2025-01-161-2/+2
| | | | New year (2024->2025), typos in comments
* Improvements in the manualRoberto Ierusalimschy2025-01-101-1/+1
| | | | Plus details
* Detail in 'luaD_inctop'Roberto Ierusalimschy2024-12-171-1/+1
| | | | | | Protect stack top before possible stack reallocation. (In the current implementation, a stack reallocation cannot call an emergency collection, so there is no bug, but it is safer not to depend on that.)
* Change to macro 'LUAI_TRY'Roberto Ierusalimschy2024-11-251-8/+6
| | | | The call to 'f' is done by the macro, to give it more flexibility.
* Counter for length of chains of __call metamethodsRoberto Ierusalimschy2024-11-161-14/+27
| | | | | This counter will allow (in a later commit) error messages to correct argument numbers in functions called through __call metamethods.
* More integration of 'nresults' into 'callstatus'Roberto Ierusalimschy2024-11-151-12/+13
|
* Added option for direct correction of stack pointersRoberto Ierusalimschy2024-08-221-10/+44
| | | | | | | | | | The use of a pointer (not access, only for computations) after its deallocation is forbiden in ISO C, but seems to work fine in all platforms we are aware of. So, using that to correct stack pointers after a stack reallocation seems safe and is much simpler than the current implementation (first change all pointers to offsets and then changing the offsets back to pointers). Anyway, for now that option is disabled.
* Struct 'transferinfo' moved to "lua_State"Roberto Ierusalimschy2024-07-301-9/+5
| | | | | | That reduces the size of "CallInfo". Moreover, bit CIST_HOOKED from call status is not needed. When in a hook, 'transferinfo' is always valid, being zero when the hook is not call/return.
* Added gcc option '-Wconversion'Roberto Ierusalimschy2024-07-271-5/+5
| | | | | No warnings for standard numerical types. Still pending alternative numerical types.
* 'nresults' moved into 'callstatus'Roberto Ierusalimschy2024-07-211-34/+38
| | | | That gives us more free bits in 'callstatus', for future use.
* Using CIST_CLSRET instead of trick with 'nresults'Roberto Ierusalimschy2024-07-191-9/+11
| | | | | The callstatus flag CIST_CLSRET is used in all tests for the presence of variables to be closed in C functions.
* Maximum stack size may not fit in unsigned shortRoberto Ierusalimschy2024-07-161-14/+29
| | | | | | Therefore, fields ftransfer/ntransfer in lua_Debug must have type 'int'. (Maximum stack size must fit in an 'int'.) Also, this commit adds check that maximum stack size respects size_t for size in bytes.
* Cleaning of llimits.hRoberto Ierusalimschy2024-06-201-0/+13
| | | | | | Several definitions that don't need to be "global" (that is, that concerns only specific parts of the code) moved out of llimits.h, to more appropriate places.
* API asserts for illegal pops of to-be-closed variablesRoberto Ierusalimschy2024-03-111-2/+3
|
* Merge branch 'master' into nextversionRoberto Ierusalimschy2024-01-251-0/+4
|\
| * Bug: Yielding in a hook stops in the wrong instructionRoberto Ierusalimschy2024-01-111-0/+4
| | | | | | | | | | | | | | | | Yielding in a hook must decrease the program counter, because it already counted an instruction that, in the end, was not executed. However, that decrement should be done only when about to restart the thread. Otherwise, inspecting the thread with the debug library shows it one instruction behind of where it really is.
* | Added suport for Fixed BuffersRoberto Ierusalimschy2023-09-051-4/+9
| | | | | | | | | | A fixed buffer keeps a binary chunk "forever", so that the program does not need to copy some of its parts when loading it.
* | Field 'Proto.is_vararg' uses only one bitRoberto Ierusalimschy2023-08-301-1/+1
| | | | | | | | So that the other bits can be used for other purposes.
* | Merge branch 'master' into nextversionRoberto Ierusalimschy2023-06-221-12/+8
|\|
| * Several functions turned 'static'Roberto Ierusalimschy2023-05-221-3/+3
| | | | | | | | | | Several functions that were already being used only inside their own file have been declared as 'static'.
| * Corrected support for 16-bit systemsRoberto Ierusalimschy2023-03-091-9/+5
| | | | | | | | | | We still need access to a 16-bit system to correctly test these changes.
* | Removed GC checks from function callsRoberto Ierusalimschy2022-11-241-4/+4
|/ | | | | Function calls do not create new objects. (It may use memory with stack reallocation, but now that is irrelevant to the GC.)
* Stack reallocation done with a single reallocRoberto Ierusalimschy2022-10-311-22/+46
| | | | | | | To avoid the need of both the old and the new stack addresses valid at the same time, to correct the pointers to the stack, these pointers are changed to offsets before the reallocation and then changed back to pointers after the reallocation.
* Stack indices changed to union'sRoberto Ierusalimschy2022-10-291-63/+62
| | | | | That will allow to change pointers to offsets while reallocating the stack.
* More checks and documentation for uses of EXTRA_STACKRoberto Ierusalimschy2022-05-261-1/+6
|
* Bug: 'lua_settop' may use an invalid pointer to stackRoberto Ierusalimschy2022-05-251-6/+6
|
* 'lua_checkstack' doesn't need to check stack overflowRoberto Ierusalimschy2022-05-231-8/+7
| | | | | | 'luaD_growstack' already checks that. This commit also fixes an internal bug in 'luaD_growstack': a large 'n' could cause an arithmetic overflow when computing 'needed'.
* DetailsRoberto Ierusalimschy2022-04-011-2/+6
| | | | | Comments + manual + identation + asserts about stack limits that were not allowing the use of the full stack
* Bug: finalizers can be called with an invalid stackRoberto Ierusalimschy2021-12-151-1/+1
| | | | | The call to 'checkstackGC' can run finalizers, which will find an inconsistent CallInfo, as 'ci' is half updated at the point of call.
* Corrected bug in 'luaD_tryfuncTM'Roberto Ierusalimschy2021-11-161-1/+2
| | | | | | The pointer to the metamethod can be invalidated by a finalizer that can run during a GC in 'checkstackGCp'. (This commit also fixes a detail in the manual.) Bug introduced in commit 91673a8ec.
* Bug: C stack overflow with coroutinesRoberto Ierusalimschy2021-11-031-2/+4
| | | | | | 'coroutine.resume' did not increment counter of C calls when continuing execution after a protected error (that is, while running 'precover').
* More uniform implementation for tail callsRoberto Ierusalimschy2021-10-291-29/+52
| | | | | | | | | | | '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).
* Removed goto's in 'luaD_precall'Roberto Ierusalimschy2021-10-181-24/+27
| | | | (plus a detail in lauxlib.h.)
* Using 'inline' in some functionsRoberto Ierusalimschy2021-09-151-4/+4
| | | | | 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-3/+4
|
* Undo simplification of tail calls (commit 901d760)Roberto Ierusalimschy2021-08-181-34/+32
| | | | Not that simpler and slower.
* Simplification in the parameters of 'luaD_precall'Roberto Ierusalimschy2021-06-301-10/+9
| | | | | | 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-18/+25
| | | | | 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-24/+24
| | | | | Tail calls handled by 'luaD_precall', like regular calls, to avoid code duplication.
* Stack reallocation done in two phasesRoberto Ierusalimschy2021-02-271-7/+21
| | | | | | | | | $he stack reallocation is done in two steps (allocation + free) because the correction of the pointers pointing into the stack must be done while both addresses (the old stack and the new one) are valid. In ISO C, any pointer use after the pointer has been deallocated is undefined behavior. The compiler option '-fsanitize=pointer-subtract' (plus what it needs to work) complained about the old implementation.
* Broadening the use of branch hintsRoberto Ierusalimschy2021-02-241-12/+12
| | | | | | 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).
* '__close' methods can yield in the return of a C functionRoberto Ierusalimschy2021-02-121-29/+43
| | | | | | | When, inside a coroutine, a C function with to-be-closed slots return, the corresponding metamethods can yield. ('__close' metamethods called through 'lua_closeslot' still cannot yield, as there is no continuation to go when resuming.)
* New implementation for to-be-closed variablesRoberto Ierusalimschy2021-02-091-1/+1
| | | | | | | | 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.