aboutsummaryrefslogtreecommitdiff
path: root/ldo.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Fixed some bugs around stack reallocationRoberto Ierusalimschy2021-02-051-1/+1
| | | | Long time without using HARDSTACKTESTS...
* Optimizations for line hookRoberto Ierusalimschy2021-01-281-4/+5
| | | | | The function 'changedline' tries harder to avoid calling 'luaG_getfuncline' plus small changes in the use of 'L->oldpc'.
* Small improvements in hooksRoberto Ierusalimschy2021-01-261-9/+8
| | | | | | | | | | - 'L->top' is set once in 'luaD_hook', instead of being set in 'luaD_hookcall' and 'rethook'; - resume discard arguments when returning after an yield inside a hook (arguments may interfere with the coroutine stack); - yield inside a hook asserts it has no arguments.
* Janitorial workRoberto Ierusalimschy2021-01-251-24/+31
| | | | Comments, code details, identation.
* Correct order of return hooks vs. close metamethodsRoberto Ierusalimschy2021-01-211-9/+15
| | | | | | The return hook should be called only after closing variables (which are still part of the function). C functions were calling the hook before the metamethods.
* Simpler handling of errors when creating tbc variablesRoberto Ierusalimschy2021-01-191-0/+1
| | | | | | 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-181-60/+67
| | | | | | 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.
* Allow yields inside '__close' metamethodsRoberto Ierusalimschy2021-01-131-3/+3
| | | | | | | 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.
* Handles '__close' errors in coroutines in "coroutine style"Roberto Ierusalimschy2020-12-301-20/+46
| | | | | Errors in '__close' metamethods in coroutines are handled by the same logic that handles other errors, through 'recover'.
* Better error messages for calling non-callable objectsRoberto Ierusalimschy2020-12-291-1/+1
| | | | | | | 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.
* Reset thread before panickingRoberto Ierusalimschy2020-12-281-5/+1
| | | | | 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-281-12/+47
| | | | | Instead of protecting each individual metamethod call, protect the entire call to 'luaF_close'.
* Bug when growing a stackRoberto Ierusalimschy2020-11-081-1/+1
| | | | | | 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.)
* DetailsRoberto Ierusalimschy2020-10-301-8/+8
| | | | | | - small corrections in the manual - ldo.c: 'docall' -> 'ccall' ('docall' already used in 'lua.c') - comments
* 'recover' finish of 'luaD_pcall' should follow the originalRoberto Ierusalimschy2020-10-121-3/+3
|
* No more field 'lua_State.stacksize'Roberto Ierusalimschy2020-10-121-10/+9
| | | | | | 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-121-16/+38
| | | | | | 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'.
* Correct handling of 'luaV_execute' invocationsRoberto Ierusalimschy2020-10-121-11/+14
| | | | | | | | | 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-26/+26
| | | | | | - more organized handling of 'nCcalls' - comments - deprecation of 'setcstacklimit'
* Back to a stackless implementationRoberto Ierusalimschy2020-10-121-20/+31
| | | | | | | | | | | | | 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: 'luaD_callnoyield' called twice in a rowRoberto Ierusalimschy2020-07-171-5/+4
| | | | | | | | | | | In luaD_callnoyield, when there is a possible stack overflow, it zeros the number of CallInfos to force a check when calling the function. However, if the "function" is not a function, the code will raise an error before checking the stack. Then, the error handling calls luaD_callnoyield again and nCcalls is decremented again, crossing the stack redzone without raising an error. (This loop can only happens once, because the error handler must be a function. But once is enough to cross the redzone.)
* Fixed bug: invalid 'oldpc' when returning to a functionRoberto Ierusalimschy2020-07-171-3/+3
| | | | | | | | | | 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: wrong stack limit when entering a coroutineRoberto Ierusalimschy2020-07-131-1/+1
| | | | | | When entering a coroutine, the computation of nCcalls added 'from->nci' to correct for preallocated CallInfos, but 'nci' includes also the Callinfos already used.
* Fixed bugs of stack reallocation x GCRoberto Ierusalimschy2020-07-071-6/+7
| | | | | | | | 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.)
* Avoid any code before locks in the APIRoberto Ierusalimschy2020-07-061-1/+2
| | | | | For consistency in the C API, avoid any initializations before callling lua_lock.
* Keep minimum size when shrinking a stackRoberto Ierusalimschy2020-07-061-3/+2
| | | | | When shrinking a stack (during GC), do not make it smaller than the initial stack size.
* Improvements in the handling of signalsRoberto Ierusalimschy2020-05-221-5/+5
| | | | Added 'volatile' to 'l_signalT' variables plus some minor changes.
* Clearer distinction between types and tagsRoberto Ierusalimschy2020-01-311-3/+3
| | | | | LUA_T* represents only types; tags (types + Variants) are represented by LUA_V* constants.
* '__call' metamethod can be any callable objectRoberto Ierusalimschy2019-06-251-14/+14
| | | | | Removed the restriction that a '__call' metamethod must be an actual function.
* New function 'setCstacklimit'Roberto Ierusalimschy2019-06-181-3/+4
| | | | | Added new functions to dynamically set the C-stack limit ('lua_setCstacklimit' in the C-API, 'debug.setCstacklimit' in Lua).
* Revamp around 'L->nCcalls' countRoberto Ierusalimschy2019-06-121-7/+6
| | | | | The field 'L->nCcalls' now counts downwards, so that the C-stack limits do not depend on the stack size.
* DetailsRoberto Ierusalimschy2019-05-131-1/+1
| | | | | | - 'luaL_setfuncs' avoids creating closures for placeholders. - Fixed some warnings about unused values in comma expressions. - Comments.
* Test for dead coroutine moved to 'lua_resume'Roberto Ierusalimschy2019-05-091-0/+2
| | | | | | The test for dead coroutines done in the 'coro' library was moved to 'lua_resume', in the kernel, which already does other similar tests.
* Coroutines do not unwind the stack in case of errorsRoberto Ierusalimschy2019-05-091-3/+1
| | | | | | | | | | | Back to how it was, a coroutine does not unwind its stack in case of errors (and therefore do not close its to-be-closed variables). This allows the stack to be examined after the error. The program can use 'coroutine.kill' to close the variables. The function created by 'coroutine.wrap', however, closes the coroutine's variables in case of errors, as it is impossible to examine the stack any way.
* LUAI_MAXCCALLS renamed LUAI_MAXCSTACKRoberto Ierusalimschy2019-03-251-2/+2
| | | | | | | The limit LUAI_MAXCCALLS was renamed LUAI_MAXCSTACK, which better represents its meaning. Moreover, its definition was moved to 'luaconf.h', given its importance now that Lua does not use a "stackless" implementation.
* No more to-be-closed functionsRoberto Ierusalimschy2019-01-041-0/+1
| | | | | | | | | | | | | | | | | | | To-be-closed variables must contain objects with '__toclose' metamethods (or nil). Functions were removed for several reasons: * Functions interact badly with sandboxes. If a sandbox raises an error to interrupt a script, a to-be-closed function still can hijack control and continue running arbitrary sandboxed code. * Functions interact badly with coroutines. If a coroutine yields and is never resumed again, its to-be-closed functions will never run. To-be-closed objects, on the other hand, will still be closed, provided they have appropriate finalizers. * If you really need a function, it is easy to create a dummy object to run that function in its '__toclose' metamethod. This comit also adds closing of variables in case of panic.
* Changes in the control of C-stack overflowRoberto Ierusalimschy2018-12-271-24/+16
| | | | | | | | | | * unification of the 'nny' and 'nCcalls' counters; * external C functions ('lua_CFunction') count more "slots" in the C stack (to allow for their possible use of buffers) * added a new test script specific for C-stack overflows. (Most of those tests were already present, but concentrating them in a single script easies the task of checking whether 'LUAI_MAXCCALLS' is adequate in a system.)
* New functions 'lua_resetthread' and 'coroutine.kill'Roberto Ierusalimschy2018-12-131-0/+4
| | | | | | New functions to reset/kill a thread/coroutine, mainly (only?) to close any pending to-be-closed variable. ('lua_resetthread' also allows a thread to be reused...)
* DetailsRoberto Ierusalimschy2018-12-111-16/+13
| | | | | | | | - in 'luaB_tonumber', do not need to "checkany" when argument is a number. - in 'lua_resume', the call to 'luaD_rawrunprotected' cannot return a status equal to -1.
* Some bugs with stack reallocation by 'luaF_close'Roberto Ierusalimschy2018-11-241-3/+6
| | | | | | | (Long time without testing with '-DHARDSTACKTESTS'...) With the introduction of to-be-closed variables, calls to 'luaF_close' can move the stack, but some call sites where keeping pointers to the stack without correcting them.
* To-be-closed variables in the C APIRoberto Ierusalimschy2018-10-251-13/+19
|
* Complete implementation of to-be-closed variablesRoberto Ierusalimschy2018-10-221-3/+6
|
* First "complete" implementation of to-be-closed variablesRoberto Ierusalimschy2018-10-171-7/+13
| | | | | | | Still missing: - handling of memory errors when creating upvalue (must run closing method all the same) - interaction with coroutines
* Towards "to closed" local variablesRoberto Ierusalimschy2018-10-081-2/+1
| | | | | | | | | | | | Start of the implementation of "scoped variables" or "to be closed" variables, local variables whose '__close' (or themselves) are called when they go out of scope. This commit implements the syntax, the opcode, and the creation of the corresponding upvalue, but it still does not call the finalizations when the variable goes out of scope (the most important part). Currently, the syntax is 'local scoped name = exp', but that will probably change.
* Added "cost" for the use of C stack by a coroutine invocation.Roberto Ierusalimschy2018-09-111-2/+8
| | | | | | | | | Resuming a coroutine uses more C stack than other operations (such as function calls or recursive syntax). So, to avoid stack overflow in recursive coroutine invocations, either LUAI_MAXCCALLS must be too small or a coroutine invocation must "pay" a higher price. New constant LUAL_COROCSTK ("COROutine C STaK") defines how much is this price.
* Bug: wrong 'nCcalls' when resuming a coroutineRoberto Ierusalimschy2018-07-111-3/+6
| | | | | | | | The counter 'nCcalls' now includes the number of CallInfo structures pre-allocated (so that these "potential" C calls can be made without checking 'nCcalls'). So, when copying this value from a thread to another, in 'lua_resume', it must be corrected to the number of CallInfo structures in the thread being resumed.
* new macros 'likely'/'unlikely' with hints for jump predictionsRoberto Ierusalimschy2018-05-301-9/+9
| | | | (used only in errors for now)
* in 'luaD_poscall', there is no need to compute 'firstResult' when 'nres==0'Roberto Ierusalimschy2018-05-221-39/+30
|
* 'fTransfer' -> 'ftransfer' / 'nTransfer' -> 'ntransfer'Roberto Ierusalimschy2018-03-161-8/+8
| | | | (keep the standard of names in lower case)
* details (avoid using non-C89 '//' comment)Roberto Ierusalimschy2018-03-071-2/+1
|