summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* Some improvements in 'luaconf.h'Roberto Ierusalimschy2019-05-133-36/+65
| | | | | Added '#if !defined' in some definitions to allow external definitions; more comments; other small changes.
* Flag for to-be-closed variables changed to '<toclose>'Roberto Ierusalimschy2019-05-098-38/+40
| | | | | | | The flag for to-be-closed variables was changed from '*toclose' to '<toclose>'. Several people found confusing the old syntax and the new one has a clear terminator, making it more flexible for future changes.
* Test for dead coroutine moved to 'lua_resume'Roberto Ierusalimschy2019-05-092-4/+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-096-26/+80
| | | | | | | | | | | 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.
* File 'lib2-v2.so' generated from its own sourceRoberto Ierusalimschy2019-05-033-3/+28
| | | | | Instead of being a copy of 'lib2.so', 'lib2-v2.so' has its own source file ('lib22.c'), so that the test can distinguish both libraries.
* A few more improvements in 'luaO_pushvfstring'Roberto Ierusalimschy2019-05-034-35/+52
| | | | | | | | - 'L' added to the 'BuffFS' structure - '%c' does not handle control characters (it is not its business. This now is done by the lexer, who is the one in charge of that kind of errors.) - avoid the direct use of 'l_sprintf' in the Lua kernel
* Avoid the creation of too many strings in 'package'Roberto Ierusalimschy2019-05-034-41/+79
| | | | | | | | | Both when setting a path and searching for a file ('searchpath'), this commit reduces the number of intermediate strings created in Lua. (For setting a path the change is not relevant, because this is done only twice when loading the module. Anyway, it is a nice example of how to use auxlib buffers to manipulate strings in the C API.)
* Some more small improvements to 'luaO_pushvfstring'Roberto Ierusalimschy2019-04-262-54/+71
| | | | | | | Details: - counter 'pushed' moved to the struct 'BuffFS' - new auxiliar function 'getbuff' to build strings directly on the buffer.
* Fixed bug with to-be-closed variables in base C levelRoberto Ierusalimschy2019-04-261-0/+2
| | | | | | | | To-be-closed variables in C use 'ci.nresults' to code that there is a variable to be closed in that function. The intialization of the base C level (the one "running" when calling API functions outside any Lua call) did not initialize 'ci.nresults', creating (correct) warnings in valgrind.
* New function 'luaL_addgsub'Roberto Ierusalimschy2019-04-243-13/+58
| | | | | | | | Added a new function 'luaL_addgsub', similar to 'luaL_gsub' but that adds its result directly to a preexisting buffer, avoiding the creation of one extra intermediate string. Also added two simple macros, 'luaL_bufflen' and 'luaL_buffaddr', to query the current length and the contents address of a buffer.