aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* Avoid using addresses of static variables as unique keysRoberto Ierusalimschy2019-07-193-16/+17
| | | | | | The addresses of static variables may be different for different instances of Lua, making these instances incompatible if they use these addresses as unique keys in the registry (or other tables).
* Fixed bug for emergency collection in upvalue creationRoberto Ierusalimschy2019-07-193-8/+10
| | | | | | | | | | | 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-195-18/+13
| | | | | It is simpler to signal a to-be-closed upvalue with a boolean flag, instead of using a different tag.
* Some details in 'lmem.c' and 'lgc.c'Roberto Ierusalimschy2019-07-192-27/+42
| | | | | | | | - Several new comments in 'lmem.c'. - Both 'luaM_growaux_' and 'luaM_shrinkvector_' use 'luaM_saferealloc_' to check for errors. Moreover, the use of 'luaM_saferealloc_' makes 'luaM_shrinkvector_' try again if shrink fails (which can happen now). - In 'checkSizes', save old debt only when needed.
* DetailsRoberto Ierusalimschy2019-07-183-25/+17
| | | | | | | - Macro 'checkliveness' (for debug) always uses 'L', to avoid warnings. - Some old 'while' changed to 'for' in 'testes/gc.lua'. - In 'testes/libs/makefile', do not make files depend on 'ltests.h', which may not even exist.
* Reviving HARDMEMTESTSRoberto Ierusalimschy2019-07-184-15/+35
| | | | | | | | | | | This commit brings a new implementation for HARDMEMTESTS, which forces an emergency GC whenever possible. It also fixes some issues detected with this option: - A small bug in lvm.c: a closure could be collected by an emergency GC while being initialized. - Some tests: a memory address can be immediatly reused after a GC; for instance, two consecutive '{}' expressions can return exactly the same address, if the first one is not anchored.
* Small bug with stack reallocationRoberto Ierusalimschy2019-07-182-7/+9
| | | | | | | | 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.)
* 'math.randomseed()' returns the seeds it usedRoberto Ierusalimschy2019-07-174-7/+27
| | | | | A call to 'math.randomseed()' returns the two components of the seed it set, so that they can be used to set that same seed again.
* Calls 'luaF_close' in 'lua_settop' only when neededRoberto Ierusalimschy2019-07-171-5/+7
| | | | | In 'lua_settop', avoid calling 'luaF_close' when increasing the stack or when the function has no to-be-closed variables.
* Fixed small issue with constant propagationRoberto Ierusalimschy2019-07-172-7/+21
| | | | | | | | Constants directly assigned to other constants were not propagating: For instance, in local <const> k1 = 10 local <const> k2 = k1 'k2' were not treated as a compile-time constant.
* New kind of expression VKSTRRoberto Ierusalimschy2019-07-175-18/+54
| | | | | | | String literal expressions have their own kind VKSTR, instead of the generic VK. This allows strings to "cross" functions without entering their constant tables (e.g., if they are used only by some nested function).
* Micro optimization in OP_RETURN and OP_TAILCALLRoberto Ierusalimschy2019-07-163-15/+13
| | | | | Many functions are vararg but create no upvalues, so it is better to separate the tests for these two kinds of "extra work".
* '__close' method may be called again in case of errorRoberto Ierusalimschy2019-07-163-22/+32
| | | | | | | | | 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-163-9/+13
| | | | | | 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.
* Unification of size representation in OP_NEWTABLE and OP_SETLISTRoberto Ierusalimschy2019-07-156-72/+80
| | | | | | Opcodes OP_NEWTABLE and OP_SETLIST use the same representation to store the size of the array part of a table. This new representation can go up to 2^33 (8 + 25 bits).
* Reordering of instructions in the main loopRoberto Ierusalimschy2019-07-121-44/+44
| | | | | The instructions in the main interpreter loop were reordered to the same order of their enumeration in 'lopcodes.h'.
* OP_NEWTABLE keeps exact size of arraysRoberto Ierusalimschy2019-07-1210-88/+67
| | | | | | 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.)
* First implementation of constant propagationRoberto Ierusalimschy2019-07-1212-119/+249
| | | | | Local constant variables initialized with compile-time constants are optimized away from the code.
* DetailsRoberto Ierusalimschy2019-07-103-13/+13
| | | | | | | | In the generic for loop, it is simpler for OP_TFORLOOP to use the same 'ra' as OP_TFORCALL. Moreover, the internal names of the loop temporaries "(for ...)" don't need to leak internal details (even because the numerical for loop doesn't have a fixed role for each of its temporaries).
* Towards constant propagationRoberto Ierusalimschy2019-07-103-42/+87
| | | | | | | This commit detaches the number of active variables from the number of variables in the stack, during compilation. Soon, compile-time constants will be propagated and therefore will not exist during run time (in the stack).
* New implementation for constantsRoberto Ierusalimschy2019-07-098-131/+125
| | | | | | | | | VLOCAL expressions keep a reference to their corresponding 'Vardesc', and 'Upvaldesc' (for upvalues) has a field 'ro' (read-only). So, it is easier to check whether a variable is read-only. The decoupling in VLOCAL between 'vidx' ('Vardesc' index) and 'sidx' (stack index) should also help the forthcoming implementation of compile-time constant propagation.
* Details (typos in comments)Roberto Ierusalimschy2019-07-059-19/+19
|
* Local attributes can be used in list of local variablesRoberto Ierusalimschy2019-07-033-81/+103
| | | | | | | | | | | | The syntax for local attributes ('const'/'toclose') was unified with the regular syntax for local variables, so that we can have variables with attributes in local definitions with multiple names; for instance: local <toclose> f, <const> err = io.open(fname) This new syntax does not implement constant propagation, yet. This commit also has some small improvements to the manual.
* First take on constant propagationRoberto Ierusalimschy2019-07-014-26/+73
|
* Methods separated from metamethods in 'io'Roberto Ierusalimschy2019-07-011-10/+20
| | | | | | | In the 'io' library, changed the use of the metatable also as its own "method table", so that metamethods cannot be accessed as if they were methods. (For instance, 'io.stdin.__gc' does not result in the finalizer metamethod anymore.)
* Small changes around C-stack limitRoberto Ierusalimschy2019-06-264-10/+24
| | | | | | | | | - Better documentation in 'testes/cstack.lua' about using 'debug.setCstacklimit' to find a good limit. - Constant LUAI_MAXCSTACK gets added CSTACKERR (extra stack for error handling), so that it is compatible with the argument to 'debug.setCstacklimit'.
* '__call' metamethod can be any callable objectRoberto Ierusalimschy2019-06-252-14/+31
| | | | | Removed the restriction that a '__call' metamethod must be an actual function.
* A few more tests for table access in the APIRoberto Ierusalimschy2019-06-252-1/+63
| | | | | Added tests where the table being accessed is also the index or value in the operation.
* Added script 'packtests' to the projectRoberto Ierusalimschy2019-06-211-0/+52
| | | | | The script 'packtests' creates the 'tar.gz' to deploy the test suite for Lua.
* Details in testsRoberto Ierusalimschy2019-06-212-18/+10
| | | | | | | | | | - Added a test for calling 'debug.traceback' after yields inside hooks. (Lua 5.3 seems to have a bug there.) - Removed test "repeat test with '__open' metamethod instead of a function", as the previous test already uses the '__open' metamethod. (It changed when functions were removed as possible to-be-closed variables).
* Structure 'Vardesc' does not need a 'name' fieldRoberto Ierusalimschy2019-06-212-13/+13
| | | | | | Removed the field 'name' from the structure 'Vardesc', as the name of the local variable is already available in the prototype of the function, through the index 'idx'.
* Cleaning macros in 'luaV_execute'Roberto Ierusalimschy2019-06-211-6/+14
| | | | | | Ensure that operation macros, such as 'luai_numdiv' and 'luai_numidiv', operate only on variables, or at most at 's2v(ra)'. ('s2v' is a nop, a cast from pointer to pointer.)
* Fixed bug [5.4 alpha] for errors in finalizersRoberto Ierusalimschy2019-06-211-4/+4
| | | | | | | | Fixes the bug related in [1] (Lua can crash after raising an error in a finalizer), following the lead in [2]. [1] http://lua-users.org/lists/lua-l/2019-06/msg00448.html [2] http://lua-users.org/lists/lua-l/2019-06/msg00450.html
* New function 'setCstacklimit'Roberto Ierusalimschy2019-06-189-12/+149
| | | | | 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-124-51/+80
| | | | | The field 'L->nCcalls' now counts downwards, so that the C-stack limits do not depend on the stack size.
* Detail in the manualRoberto Ierusalimschy2019-06-101-5/+6
| | | | | More precision describing the variables that won't be closed if a coroutine yields forever.
* Updated the documentation for the API function 'lua_gc'v5.4-alphaRoberto Ierusalimschy2019-06-061-53/+62
|
* Detail in makefileRoberto Ierusalimschy2019-06-051-1/+1
|
* Multiple errors in '__toclose' report the first oneRoberto Ierusalimschy2019-06-055-28/+56
| | | | | | | | 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.
* Function 'warn' is varargRoberto Ierusalimschy2019-06-044-20/+43
| | | | | | | Instead of a 'tocont' flag, the function 'warn' in Lua now receives all message pieces as multiple arguments in a single call. Besides being simpler to use, this implementation ensures that Lua code cannot create unfinished warnings.
* 'coroutine.kill' renamed 'coroutine.close'Roberto Ierusalimschy2019-06-033-28/+29
|
* bug in 5.4 alpha rc1: to-be-closed x vararg functionsRoberto Ierusalimschy2019-06-032-1/+10
| | | | | | Closing methods must be run before correcting 'ci->func' when exiting a vararg function, to get correct debug information (e.g., in case of errors).
* DetailsRoberto Ierusalimschy2019-06-038-23/+23
| | | | | Several small changes from feedback on 5.4 alhpa rc1 (warnings, typos in the manual, and the like)
* Improvements in 'testes/cstack.lua'Roberto Ierusalimschy2019-06-031-12/+32
| | | | | | - tests show progress in real time, so that we can see maximum stack levels even if test crashes. - new test for recursion continuing into message handler.
* Improvements in 'luaL_traceback'Roberto Ierusalimschy2019-05-281-24/+29
| | | | | | | | 'luaL_traceback' changed to use an aux buffer instead of concats. This should reduce the quantity of garbage it generates (in the form of intermediate strings) while producing a trackback. It also added information about the number of levels skipped when skipping levels in a trace.
* DetailsRoberto Ierusalimschy2019-05-289-23/+46
| | | | | | | - new error message for "attempt to assign to const variable" - note in the manual about compatibility options - comments - small changes in 'read_line' and 'pushstr'
* First implementation for 'const' variablesRoberto Ierusalimschy2019-05-177-56/+205
| | | | | A variable can be declared const, which means it cannot be assigned to, with the syntax 'local <const> name = exp'.
* Define LUA_MAXUNSIGNED as a preprocessor constantRoberto Ierusalimschy2019-05-142-3/+10
| | | | | The previous definition of LUA_MAXUNSIGNED used a typecast, making it unsuitable for constant expressions in the preprocessor.
* DetailsRoberto Ierusalimschy2019-05-135-11/+13
| | | | | | - 'luaL_setfuncs' avoids creating closures for placeholders. - Fixed some warnings about unused values in comma expressions. - Comments.
* A few changes in tests about number of bits in integersRoberto Ierusalimschy2019-05-136-18/+19
| | | | | | - The preprocessor must work with at least 'long', and therefore must do shifts of up to 31 bits correctly. - Whenever possible, use unsigned types in shifts.