aboutsummaryrefslogtreecommitdiff
path: root/ltests.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* New implementation for to-be-closed variablesRoberto Ierusalimschy2021-02-091-0/+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.
* New API function 'lua_closeslot'Roberto Ierusalimschy2021-01-111-0/+3
| | | | | | 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.
* Review of asserts in 'ltests.c'Roberto Ierusalimschy2020-12-081-56/+70
| | | | The module 'ltests.c' must work correctly with asserts off, too.
* 'luaL_newstate' should not allocate extra memoryRoberto Ierusalimschy2020-11-031-1/+1
| | | | | | | | 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.
* Hash always use all characters in a long stringRoberto Ierusalimschy2020-10-121-1/+0
| | | | | | | 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.
* No more field 'lua_State.stacksize'Roberto Ierusalimschy2020-10-121-4/+4
| | | | | | 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.
* Better tests for gray listsRoberto Ierusalimschy2020-08-071-9/+31
| | | | | Test uses an extra bit in 'marked' to mark all elements in gray lists and then check against elements colored gray.
* Clearer handling of gray lists when entering generational modeRoberto Ierusalimschy2020-08-031-12/+48
| | | | | | | | When entering generational mode, all objects are old. So, the only objects that need to be in a gray list are threads, which can be assigned without barriers. Changes in anything else (e.g., weak tables) will trigger barriers that, if needed, will add the object to a gray list.
* DetailsRoberto Ierusalimschy2020-07-291-2/+2
| | | | | The fields 'old' and 'finobjold' were renamed 'old1' and 'finobjold1', respectively, to make clearer the main ages of their elements.
* Function 'printobj' in 'ltests.c' made publicRoberto Ierusalimschy2020-07-271-0/+4
| | | | It helps to have this function available for debugging.
* Make sure that main thread is non yieldableRoberto Ierusalimschy2020-07-061-2/+5
| | | | | Main thread must be non yieldable even at "level 0" (bare API), outside the 'pcall' from 'lua.c'.
* Avoid memory allocation in some functions from 'ltests.c'Roberto Ierusalimschy2020-07-041-7/+20
| | | | | | | To allow their use in memory tests, some functions in 'ltests.c' should never allocate memory. To avoid this allocation, the library registers the strings used for status codes, and keeps the variable '_WARN' always defined (with false instead of nil).
* In 'lua_checkmemory', userdata can be gray, tooRoberto Ierusalimschy2020-06-151-0/+4
| | | | | Since commit ca6fe7449a74, userdata with uservalues can be gray and can belong to gray lists ('gclist').
* Avoid calling 'fprintf' with NULLRoberto Ierusalimschy2020-06-091-1/+3
| | | | | | Avoid undefined behavior in calls like «fprintf("%s", NULL)». ('lua_writestringerror' is implemented as 'fprintf', and 'lua_tostring' can return NULL if object is not a string.)
* Fixed bug in 'string.format("%p")'Roberto Ierusalimschy2020-03-161-2/+1
| | | | | The string "(null)" used for non-collectable values must be printed as a string, not as a pointer. (Bug introduced in commit e0cbaa50fa7).
* DetailsRoberto Ierusalimschy2020-02-271-5/+7
| | | | | Several details in code (e.g., moving a variable to the most inner scope that encloses its uses), comments, parameter names, extra tests.
* Clearer distinction between types and tagsRoberto Ierusalimschy2020-01-311-19/+19
| | | | | LUA_T* represents only types; tags (types + Variants) are represented by LUA_V* constants.
* Comments (mosty typos)Roberto Ierusalimschy2019-12-301-2/+2
|
* Details (mostly comments)Roberto Ierusalimschy2019-10-221-1/+1
|
* Default for warnings changed to "off"Roberto Ierusalimschy2019-08-201-1/+1
| | | | | Warnings are mostly a tool to help developers (e.g., by showing hidden error messages); regular users usually don't need to see them.
* Improvement in warn-mode '@store' (for testing)Roberto Ierusalimschy2019-08-181-8/+20
| | | | | | When using warn-mode '@store', from the test library, the tests ensure not only that the expected warnings were issued, but also that there was no extra warnings.
* Supressed errors in '__close' generate warningsRoberto Ierusalimschy2019-08-161-5/+5
|
* Added control messages to warningsRoberto Ierusalimschy2019-08-151-17/+47
| | | | | | | Added the concept of control messages to the warning system, plus the implementation of the controls "@on"/"@off" to turn warnings on/off. Moreover, the warning system in the test library adds some other controls to ease the test of warnings.
* To-be-closed variables must be closed on initializationRoberto Ierusalimschy2019-07-311-0/+3
| | | | | | | | | 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.)
* Tag LUA_TUPVALTBC replaced by a flagRoberto Ierusalimschy2019-07-191-2/+1
| | | | | It is simpler to signal a to-be-closed upvalue with a boolean flag, instead of using a different tag.
* OP_NEWTABLE keeps exact size of arraysRoberto Ierusalimschy2019-07-121-9/+0
| | | | | | OP_NEWTABLE is followed by an OP_EXTRAARG, so that it can keep the exact size of the array part of the table to be created. (Functions 'luaO_int2fb'/'luaO_fb2int' were removed.)
* A few more tests for table access in the APIRoberto Ierusalimschy2019-06-251-0/+16
| | | | | Added tests where the table being accessed is also the index or value in the operation.
* DetailsRoberto Ierusalimschy2019-05-131-5/+3
| | | | | | - 'luaL_setfuncs' avoids creating closures for placeholders. - Fixed some warnings about unused values in comma expressions. - Comments.
* Revamp of 'lua_pushfstring' / 'luaO_pushvfstring'Roberto Ierusalimschy2019-04-241-0/+9
| | | | | | | | | The function 'luaO_pushvfstring' now uses an internal buffer to concatenate small strings, instead of pushing all pieces on the stack. This avoids the creation of several small Lua strings for each piece of the result. (For instance, a format like "n: '%d'" used to create three intermediate strings: "n: '", the numeral, and "'". Now it creates none.)
* Changes in the warning systemRoberto Ierusalimschy2019-03-141-38/+22
| | | | | | | | - The warning functions get an extra parameter that tells whether message is to be continued (instead of using end-of-lines as a signal). - The user data for the warning function is a regular value, instead of a writable slot inside the Lua state.
* DetailsRoberto Ierusalimschy2019-03-131-2/+5
| | | | | | | | | | 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-7/+11
| | | | | | | | | | | | | | | | | | | 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.
* No more LUA_ERRGCMM errorsRoberto Ierusalimschy2019-01-011-13/+48
| | | | | Errors in finalizers (__gc metamethods) are never propagated. Instead, they generate a warning.
* Added a warning system to LuaRoberto Ierusalimschy2018-12-281-1/+32
| | | | | The warning system is just a way for Lua to emit warnings, messages to the programmer that do not interfere with the running program.
* DetailsRoberto Ierusalimschy2018-12-171-1/+2
| | | | | A few details in the makefile and in the manual. (In particular, it updates the dependency lists in the makefile.)
* New functions 'lua_resetthread' and 'coroutine.kill'Roberto Ierusalimschy2018-12-131-0/+3
| | | | | | 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...)
* Some bugs with stack reallocation by 'luaF_close'Roberto Ierusalimschy2018-11-241-1/+1
| | | | | | | (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.
* 'lua_toclose' gets the index to be closed as an argumentRoberto Ierusalimschy2018-11-121-1/+1
| | | | | | Sometimes it is useful to mark to-be-closed an index that is not at the top of the stack (e.g., if the value to be closed came from a function call returning multiple values).
* New syntax for to-be-closed variablesRoberto Ierusalimschy2018-11-071-2/+2
| | | | | | | The new syntax is <local *toclose x = f()>. The mark '*' allows other attributes to be added later without the need of new keywords; it also allows better error messages. The API function was also renamed ('lua_tobeclosed' -> 'lua_toclose').
* Removed internal cache for closuresRoberto Ierusalimschy2018-11-011-4/+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.)
* Big revamp in the implmentation of labels/gotosRoberto Ierusalimschy2018-10-291-1/+1
| | | | | | | | Added restriction that, when a label is created, there cannot be another label with the same name visible. That allows backward goto's to be resolved when they are read. Backward goto's get a close if they jump out of the scope of some variable; labels get a close only if previous goto to it jumps out of the scope of some upvalue.
* To-be-closed variables in the C APIRoberto Ierusalimschy2018-10-251-0/+3
|
* First "complete" implementation of to-be-closed variablesRoberto Ierusalimschy2018-10-171-1/+1
| | | | | | | 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-11/+14
| | | | | | | | | | | | 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.
* 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.
* Fixed bug in line info. when using 'not' operatorRoberto Ierusalimschy2018-07-111-1/+21
| | | | | | | | | When creating code for a jump on a 'not' condition, the code generator was removing an instruction (the OP_NOT) without adjusting its corresponding line information. This fix also added tests for this case and extra functionality in the test library to debug line info. structures.
* Opcode names moved to a new header fileRoberto Ierusalimschy2018-07-091-3/+4
| | | | | | | The array with the names of the opcodes was moved to a header file ('lopnames.h'), as it is not used by the Lua kernel. Files that need that array ('luac.c' and 'ltests.c') include the header file to get a private (static) copy.
* field 'sizearray' in struct 'Table' changed to 'alimit', which canRoberto Ierusalimschy2018-06-151-5/+10
| | | | be used as a hint for '#t'
* no more 'TESTGRAYBIT' (to free this bit for real uses)Roberto Ierusalimschy2018-06-111-21/+4
|
* details (casts between 'lua_Number' and 'double')Roberto Ierusalimschy2018-03-091-3/+3
|