aboutsummaryrefslogtreecommitdiff
path: root/lapi.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2025-02-28Error object cannot be nilRoberto Ierusalimschy4-8/+23
Lua will change a nil as error object to a string message, so that it never reports an error with nil as the error object.
2025-02-28'__close' gets no error object if there is no errorRoberto Ierusalimschy4-27/+60
Instead of receiving nil as a second argument, __close metamethods are called with just one argument when there are no errors.
2025-02-26'lua_State.nci' must be an integerRoberto Ierusalimschy3-3/+18
Lua can easily overflow an unsigned short counting nested calls. (The limit to this value is the maximum stack size, LUAI_MAXSTACK, which is currently 1e6.)
2025-02-26DetailsRoberto Ierusalimschy5-9/+33
Comments, small changes in the manual, an extra test for errors in error handling, small changes in tests.
2025-02-20Array sizes in undump changed from unsigned to intRoberto Ierusalimschy2-33/+27
Array sizes are always int and are dumped as int, so there is no reason to read them back as unsigned.
2025-02-18Added macro LUAI_STRICT_ADDRESSRoberto Ierusalimschy2-10/+22
By default, the code assumes it is safe to use a dealocated pointer as long as the code does not access it.
2025-01-31Main thread is a regular field of global_StateRoberto Ierusalimschy6-75/+65
They were already allocated as a single block, so there is no need for the global_State to point to its main thread.
2025-01-30New type 'TStatus' for thread status/error codesRoberto Ierusalimschy10-46/+56
2025-01-29Details (in test library)Roberto Ierusalimschy1-5/+16
- Added support for negative stack indices in the "C interpreter" - Improved format when printing values
2025-01-28CallInfo bit CIST_CLSRET broken in twoRoberto Ierusalimschy4-15/+44
Since commit f407b3c4a, it was being used for two distinct (and incompatible) meanings: A: Function has TBC variables (now bit CIST_TBC) B: Interpreter is closing TBC variables (original bit CIST_CLSRET) B implies A, but A does not imply B.
2025-01-27Renaming two new functionsRoberto Ierusalimschy7-13/+13
'lua_numbertostrbuff' -> 'lua_numbertocstring' 'lua_pushextlstring' -> 'lua_pushexternalstring'
2025-01-21Parameters for 'lua_createtable' back to intRoberto Ierusalimschy7-16/+18
Tables don't accept sizes larger than int.
2025-01-16Small change in macro 'isvalid'Roberto Ierusalimschy1-3/+1
The "faster way" to check whether a value is not 'nilvalue' is not faster. (Both forms entail one memory access.)
2025-01-16fixing 'lua_status' in panic.Roberto Ierusalimschy3-2/+28
'luaD_throw' may call 'luaE_resetthread', which returns an error code but clears 'L->status'; so, 'luaD_throw' should set that status again.
2025-01-16DetailsRoberto Ierusalimschy15-25/+24
New year (2024->2025), typos in comments
2025-01-14Fixed conversion warnings from clangRoberto Ierusalimschy9-13/+17
Plus some other details. (Option '-Wuninitialized' was removed from the makefile because it is already enabled by -Wall.)
2025-01-13Error "break outside loop" made a syntax errorRoberto Ierusalimschy1-11/+14
Syntax errors are easier to handle than semantic errors.
2025-01-10Details in lparser.cRoberto Ierusalimschy1-10/+13
Added comments so that all braces pair correctly. (The parser has several instances of unmatched braces as characters ('{' or '}'), which hinders matching regular braces in the code.)
2025-01-10New optimization option for testingRoberto Ierusalimschy1-1/+1
Using gcc's option '-Og' (instead of '-O0') for testing/debugging.
2025-01-10Improvements in the manualRoberto Ierusalimschy4-18/+23
Plus details
2025-01-10Another way to compile goto'sRoberto Ierusalimschy6-121/+119
The compilation of a goto or a label just create an entry and generate boilerplate code for the gotos. As we don't know yet whether it needs a CLOSE, we code a jump followed by a CLOSE, which is then dead code. When a block ends (and then we know for sure whether there are variables that need to be closed), we check the goto's against the labels of that block. When closing a goto against a label, if it needs a CLOSE, the compiler swaps the order of the jump and the CLOSE, making the CLOSE active.
2025-01-06DetailRoberto Ierusalimschy1-2/+6
Small improvement in line-tracing for internal debugging.
2025-01-06Detail (debugging aid)Roberto Ierusalimschy2-4/+6
When compiling with option HARDMEMTESTS, every creation of a new key in a table forces an emergency GC.
2024-12-30Scanner doesn't need to anchor reserved wordsRoberto Ierusalimschy2-12/+20
2024-12-28Small optimization in 'luaH_psetshortstr'Roberto Ierusalimschy1-18/+63
Do not optimize only for table updates (key already present). Creation of new short keys in new tables can be quite common in programs that create lots of small tables, for instance with constructors like {x=e1,y=e2}.
2024-12-28When parser reuses constants, only floats can collideRoberto Ierusalimschy1-26/+28
Ensure that float constants never use integer keys, so that only floats can collide in 'k2proto'.
2024-12-17Detail in 'luaD_inctop'Roberto Ierusalimschy1-1/+1
Protect stack top before possible stack reallocation. (In the current implementation, a stack reallocation cannot call an emergency collection, so there is no bug, but it is safer not to depend on that.)
2024-12-17Scanner and parser use different tables for constantsRoberto Ierusalimschy6-28/+20
Moreover, each function being parsed has its own table. The code is cleaner when each table is used for one specific purpose: The scanner uses its table to anchor and unify strings, mapping strings to themselves; the parser uses it to reuse constants in the code, mapping constants to their indices in the constant table. A different table for each task avoids false collisions.
2024-12-16'addk' broken in two functionsRoberto Ierusalimschy1-19/+28
2024-12-11'luaH_fastseti' uses 'checknoTM'Roberto Ierusalimschy1-1/+1
The extra check in checknoTM (versus only checking whether there is a metatable) is cheap, and it is not that uncommon for a table to have a metatable without a __newindex metafield.
2024-12-11OP_SELF restricted to constant short stringsRoberto Ierusalimschy5-34/+35
Optimize this opcode for the common case. For long names or method calls after too many constants, operation can be coded as a move followed by 'gettable'.
2024-12-05Rehash reinserts elements with "lighter" functionsRoberto Ierusalimschy1-17/+33
When reinserting elements into a table during a rehash, the code does not need to invoke all the complexity of a full 'luaH_set': - The table has space for all keys. - The key cannot exist in the new hash. - The keys are valid (not NaN nor nil). - The keys are normalized (1.0 -> 1). - The values cannot be nil. - No barrier needed (the table already pointed to the key and value).
2024-12-05Refactoring of 'luaH_newkey'Roberto Ierusalimschy2-56/+79
Function broke in two and some checks moved to the caller. (We may want to call it without the checks.)
2024-12-03Fix in the definition of 'sizeLclosure'Roberto Ierusalimschy1-1/+1
The array at the end of a Lua closure has pointers to upvalues, not to tagged values. This bug cannot cause any issue: The ISO C standard requires that all pointers to structures have the same representation, so sizeof(TValue*) must be equal to sizeof(UpVal*).
2024-12-02New function 'lua_printvalue' for internal debuggingRoberto Ierusalimschy2-4/+43
2024-11-29DetailsRoberto Ierusalimschy1-2/+2
Added two warnings to the makefile.
2024-11-29New way to keep hints for table lengthRoberto Ierusalimschy7-249/+146
Instead of using 'alimit' for keeping the size of the array and at the same time being a hint for '#t', a table now keeps these two values separate. The Table structure has a field 'asize' with the size of the array, while the length hint is kept in the array itself. That way, tables with no array part waste no space with that field. Moreover, the space for the hint may have zero cost for small arrays, if the array of tags plus the hint still fits in a single word.
2024-11-27Avoid an extra call to 'concretesize' in 'resizearray'Roberto Ierusalimschy1-5/+5
2024-11-25Change to macro 'LUAI_TRY'Roberto Ierusalimschy2-8/+7
The call to 'f' is done by the macro, to give it more flexibility.
2024-11-19Debug information about extra arguments from __callRoberto Ierusalimschy9-12/+83
'debug.getinfo' can return number of extra arguments added to a call by a chain of __call metavalues. That information is being used to improve error messages about errors in these extra arguments.
2024-11-16Counter for length of chains of __call metamethodsRoberto Ierusalimschy4-28/+68
This counter will allow (in a later commit) error messages to correct argument numbers in functions called through __call metamethods.
2024-11-15More integration of 'nresults' into 'callstatus'Roberto Ierusalimschy3-28/+33
2024-11-15'objsize' returns 'l_mem'Roberto Ierusalimschy7-25/+40
Sums of size_t may not fit in a size_t.
2024-11-15New macro 'assert_code'Roberto Ierusalimschy1-5/+6
It allows code that is only used by assertions but that are not assertions (e.g., declaration of a variable used in a later assertion).
2024-11-15Ease slightly making Lua with C89Roberto Ierusalimschy2-1/+8
2024-11-15Dummy node has a non-nil keyRoberto Ierusalimschy1-25/+28
That allows 'getfreepos' to treat it like a regular hash part that has a deleted entry.
2024-11-14Add extra size when resizing tables with deleted keysRoberto Ierusalimschy2-6/+82
Without this extra space, sequences of insertions/deletions (and some other uses) can have unpexpected low performances. See the added tests for an example, and *Mathematical Models to Analyze Lua Hybrid Tables and Why They Need a Fix* (Martínez, Nicaud, Rotondo; arXiv:2208.13602v2) for detais.
2024-11-13New rule for size of array partRoberto Ierusalimschy3-29/+81
Array part needs 1/3 of its elements filled, instead of 1/2. Array entries use ~1/3 the memory of hash entries, so this new rule still ensures that array parts do not use more memory than keeping the values in the hash, while allowing more uses of the array part, which is more efficient than the hash.
2024-10-28New structure to count keys in a table for rehashingRoberto Ierusalimschy1-50/+65
2024-10-28Table rehash can resize only the hash partRoberto Ierusalimschy2-17/+41
If there are no integer keys outside the array part, there is no reason to resize it, saving the time to count its elements. Moreover, assignments to non-integer keys will not collapse a table created with 'table.create'.