summaryrefslogtreecommitdiff
path: root/lfunc.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Clearer distinction between types and tagsRoberto Ierusalimschy2020-01-311-5/+5
| | | | | LUA_T* represents only types; tags (types + Variants) are represented by LUA_V* constants.
* Comments (mosty typos)Roberto Ierusalimschy2019-12-301-1/+1
|
* DetailsRoberto Ierusalimschy2019-11-181-7/+7
|
* Supressed errors in '__close' generate warningsRoberto Ierusalimschy2019-08-161-1/+5
|
* To-be-closed variables must be closed on initializationRoberto Ierusalimschy2019-07-311-17/+32
| | | | | | | | | When initializing a to-be-closed variable, check whether it has a '__close' metamethod (or is a false value) and raise an error if if it hasn't. This produces more accurate error messages. (The check before closing still need to be done: in the C API, the value is not constant; and the object may lose its '__close' metamethod during the block.)
* Do not collect open upvaluesRoberto Ierusalimschy2019-07-221-8/+7
| | | | | | | | Open upvalues are kept alive together with their corresponding stack. This change makes a simpler and safer fix to the issue in commit 440a5ee78c8, about upvalues in the list of open upvalues being collected while others are being created. (That previous fix may not be correct.)
* Fixed bug for emergency collection in upvalue creationRoberto Ierusalimschy2019-07-191-6/+8
| | | | | | | | | | | When creating an upvalue, an emergency collection can collect the previous upvalue where the new one would be linked. The following code can trigger the bug, using valgrind on Lua compiled with the -DHARDMEMTESTS option: local x; local y (function () return y end)(); (function () return x end)()
* Tag LUA_TUPVALTBC replaced by a flagRoberto Ierusalimschy2019-07-191-7/+8
| | | | | It is simpler to signal a to-be-closed upvalue with a boolean flag, instead of using a different tag.
* Small bug with stack reallocationRoberto Ierusalimschy2019-07-181-4/+3
| | | | | | | | OP_RETURN must update trap before updating stack. (Bug detected with -DHARDSTACKTESTS). Also, in 'luaF_close', do not create a variable with 'uplevel(uv)', as the stack may change and invalidate this value. (This is not a bug, but could become one if 'upl' was used again.)
* '__close' method may be called again in case of errorRoberto Ierusalimschy2019-07-161-10/+12
| | | | | | | | | An error in a closing method may be caused by a lack of resources, such as memory or stack space, and the error may free enough resources (by unwinding the stack) to allow the method to work if called again. If the closing method is already running after some error (including its own), it is not called again.
* Avoid setting the stack top below upvalues to be closedRoberto Ierusalimschy2019-07-161-0/+1
| | | | | | When leaving a scope, the new stack top should be set only after closing any upvalue, to avoid manipulating values in an "invalid" part of the stack.
* Multiple errors in '__toclose' report the first oneRoberto Ierusalimschy2019-06-051-3/+6
| | | | | | | | When there are multiple errors when closing objects, the error reported by the protected call is the first one, for two reasons: First, other errors may be caused by this one; second, the first error is handled in the original execution context, and therefore has the full traceback.
* DetailsRoberto Ierusalimschy2019-03-131-1/+2
| | | | | | | | | | Several small improvements (code style, warnings, comments, more tests), in particular: - 'lua_topointer' extended to handle strings - raises an error in 'string.format("%10q")' ('%q' with modifiers) - in the manual for 'string.format', the term "option" replaced by "conversion specifier" (the term used by the C standard)
* No more to-be-closed functionsRoberto Ierusalimschy2019-01-041-14/+10
| | | | | | | | | | | | | | | | | | | 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.
* New functions 'lua_resetthread' and 'coroutine.kill'Roberto Ierusalimschy2018-12-131-8/+10
| | | | | | 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...)
* A to-be-closed variable must have a closable value (or be nil)Roberto Ierusalimschy2018-11-291-0/+6
| | | | | | | It is an error for a to-be-closed variable to have a non-closable non-nil value when it is being closed. This situation does not seem to be useful and often hints to an error. (Particularly in the C API, it is easy to change a to-be-closed index by mistake.)
* Removed internal cache for closuresRoberto Ierusalimschy2018-11-011-2/+0
| | | | | | | | | | | | | | | | | | | The mechanism of "caching the last closure created for a prototype to try to reuse it the next time a closure for that prototype is created" was removed. There are several reasons: - It is hard to find a natural example where this cache has a measurable impact on performance. - Programmers already perceive closure creation as something slow, so they tend to avoid it inside hot paths. (Any case where the cache could reuse a closure can be rewritten predefining the closure in some variable and using that variable.) - The implementation was somewhat complex, due to a bad interaction with the generational collector. (Typically, new closures are new, while prototypes are old. So, the cache breaks the invariant that old objects should not point to new ones.)
* Closing methods should not interfere with returning valuesRoberto Ierusalimschy2018-10-251-31/+33
| | | | | | | | | | | | A closing method cannot be called in its own stack slot, as there may be returning values in the stack after that slot, and the call would corrupt those values. Instead, the closing method must be copied to the top of the stack to be called. Moreover, even when a function returns no value, its return istruction still has to have its position (which will set the stack top) after the local variables, otherwise a closing method might corrupt another not-yet-called closing method.
* Handling of memory errors when creating to-be-closed upvaluesRoberto Ierusalimschy2018-10-181-32/+94
|
* First "complete" implementation of to-be-closed variablesRoberto Ierusalimschy2018-10-171-3/+44
| | | | | | | Still missing: - handling of memory errors when creating upvalue (must run closing method all the same) - interaction with coroutines
* Removed extra information from RCS keyword stringsRoberto Ierusalimschy2018-08-231-1/+1
| | | | | Version numbers and dates (mostly wrong) from RCS keyword strings removed from all source files; only the file name are kept.
* new type 'StackValue' for stack elementsRoberto Ierusalimschy2017-06-291-6/+6
| | | | (we may want to put extra info there in the future)
* 'lineinfo' in prototypes saved as differences instead of absoluteRoberto Ierusalimschy2017-06-271-1/+4
| | | | | | values, so that the array can use bytes instead of ints, reducing its size. (A new array 'abslineinfo' is used when line differences do not fit in a byte.)
* bug: cannot reuse a dying upvalueRoberto Ierusalimschy2017-05-241-2/+2
|
* added 'cachemiss' field to prototype to avoid wasting time checkingRoberto Ierusalimschy2017-04-301-1/+2
| | | | hits that fail too often
* Upvalues collected like everything else (with mark-sweep) insteadRoberto Ierusalimschy2017-04-111-19/+28
| | | | of reference count (simpler and better for generational mode)
* small changes in 'luaC_upvalbarrier'Roberto Ierusalimschy2017-04-061-4/+5
|
* added include for 'lprefix.h', for stuff that must be added beforeRoberto Ierusalimschy2014-11-021-4/+6
| | | | any other header file
* `name' in comments changed to 'name'Roberto Ierusalimschy2014-10-251-3/+3
|
* more precision between closure types ('LClosure' x 'CClosure')Roberto Ierusalimschy2014-06-191-9/+9
|
* use appropriate macros to convert GCObject to specific typesRoberto Ierusalimschy2014-06-181-4/+7
|
* new list 'twups' to allow traversal of upvalues from dead threadsRoberto Ierusalimschy2014-02-181-4/+12
| | | | (+ fixed some problems with cycles involving those upvalues)
* field 'op' renamed to 'open'Roberto Ierusalimschy2014-02-151-4/+4
|
* no more local collectionRoberto Ierusalimschy2014-02-131-2/+1
|
* 'luaC_newobj' does not handle special cases; only special caseRoberto Ierusalimschy2013-09-111-4/+4
| | | | now is threads, which do not use 'luaC_newobj' anymore.
* LOCALBLACK changed to LOCALMARK and used also to control whether objectRoberto Ierusalimschy2013-08-271-6/+4
| | | | | is in 'localgc' list + luaC_newobj by default puts object in 'localgc' list
* upvalues collected by reference countRoberto Ierusalimschy2013-08-271-38/+27
|
* Lua closures go to local, tooRoberto Ierusalimschy2013-08-261-5/+14
|
* C functions and strings now go to the local list; first versionRoberto Ierusalimschy2013-08-231-2/+3
| | | | of the local collector
* added 'local' bit (true => object is only refered by local variables)Roberto Ierusalimschy2013-08-161-1/+3
|
* double-linked list of all upvalues elliminated and changed to aRoberto Ierusalimschy2013-08-071-27/+7
| | | | traversal of all non-marked threads
* no more generational collection !!!Roberto Ierusalimschy2013-08-051-2/+1
|
* open upvalues cannot be old if thread is not old; when thread is old,Roberto Ierusalimschy2012-10-031-2/+2
| | | | | their list is not traversed anymore, and therefore can contain dead elements.
* no more 'Proto' objects on the stack. Protos are anchored on outerRoberto Ierusalimschy2012-05-081-4/+3
| | | | Protos or on a Closure, which must be created before the Proto.
* object tag keeps variant bits too -> no need for 'isC' field inRoberto Ierusalimschy2012-01-201-12/+3
| | | | Closures + more strick typing for closure variants
* typo in commentsRoberto Ierusalimschy2010-06-301-2/+2
|
* unused '#include' removedRoberto Ierusalimschy2010-06-101-2/+1
|
* Lua closures are cached for reuseRoberto Ierusalimschy2010-06-041-2/+5
|
* corrected some places where an old object could end up in frontRoberto Ierusalimschy2010-05-101-3/+5
| | | | of a new one + minimal documentation about this problem
* nasty GC bug: upvalue must be turned white when not keeping invariant,Roberto Ierusalimschy2010-04-291-6/+2
| | | | but barrier was not being called when uv->v were already white.