Commit Graph

5661 Commits

Author SHA1 Message Date
Roberto Ierusalimschy
50c7c915ee Debug information about extra arguments from __call
'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-19 14:09:18 -03:00
Roberto Ierusalimschy
b117bdb344 Counter for length of chains of __call metamethods
This counter will allow (in a later commit) error messages to correct
argument numbers in functions called through __call metamethods.
2024-11-16 12:00:28 -03:00
Roberto Ierusalimschy
f12ce4029d More integration of 'nresults' into 'callstatus' 2024-11-15 15:25:11 -03:00
Roberto Ierusalimschy
a4762b6ffe 'objsize' returns 'l_mem'
Sums of size_t may not fit in a size_t.
2024-11-15 12:04:53 -03:00
Roberto Ierusalimschy
d4247befa1 New macro 'assert_code'
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-15 11:57:18 -03:00
Roberto Ierusalimschy
ee6a4cd1ec Ease slightly making Lua with C89 2024-11-15 11:43:32 -03:00
Roberto Ierusalimschy
8a4419b119 Dummy node has a non-nil key
That allows 'getfreepos' to treat it like a regular hash part that has
a deleted entry.
2024-11-15 10:48:52 -03:00
Roberto Ierusalimschy
9a91fe1640 Add extra size when resizing tables with deleted keys
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-14 11:48:25 -03:00
Roberto Ierusalimschy
2491b87c10 New rule for size of array part
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-11-13 13:37:24 -03:00
Roberto Ierusalimschy
0de8191152 New structure to count keys in a table for rehashing 2024-10-28 14:15:21 -03:00
Roberto Ierusalimschy
853311e5b1 Table rehash can resize only the hash part
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'.
2024-10-28 10:54:36 -03:00
Roberto Ierusalimschy
25a2dac2bc Always use unsigned int for indexing table-arrays 2024-10-24 15:33:25 -03:00
Roberto Ierusalimschy
e3ce88c9e8 New function 'lua_numbertostrbuff'
It converts a Lua number to a string in a buffer, without creating
a new Lua string.
2024-10-23 17:16:17 -03:00
Roberto Ierusalimschy
5ffcd458f0 Some changes in default GC parameters 2024-10-23 17:15:06 -03:00
Roberto Ierusalimschy
9b01da97e3 Small bug in 'luaE_luaE_statesize'
Plus, function was renamed to 'luaE_threadsize'.
2024-10-21 15:30:35 -03:00
Roberto Ierusalimschy
258355734d Better support in 'ltests' for tracing the GC 2024-10-21 15:18:20 -03:00
Roberto Ierusalimschy
d0815046d0 Some adjustments in transition minor->major
Plus extra comments and other details.
2024-10-18 17:10:20 -03:00
Roberto Ierusalimschy
3d54b42d59 'objsize' broke in smaller pieces 2024-09-30 14:01:42 -03:00
Roberto Ierusalimschy
e4f418f07c Local declaration in the REPL generates a warning 2024-09-27 10:00:35 -03:00
Roberto Ierusalimschy
20d42ccaae No errors in 'luaO_pushvfstring'
Any call to 'va_start' must have a corresponding call to 'va_end';
so, functions called between them (luaO_pushvfstring in particular)
cannot raise errors.
2024-09-20 15:56:39 -03:00
Roberto Ierusalimschy
70d6975018 Towards no errors in 'luaO_pushvfstring'
Any call to 'va_start' must have a corresponding call to 'va_end';
so, functions called between them (luaO_pushvfstring in particular)
cannot raise errors.
2024-09-20 12:21:11 -03:00
Roberto Ierusalimschy
00e34375ec In 'luaO_pushvfstring', all options use 'addstr2buff' 2024-09-20 10:06:06 -03:00
Roberto Ierusalimschy
45a8f1b593 Removed 'if' left from commit ddfa1fbccf 2024-09-20 09:43:46 -03:00
Roberto Ierusalimschy
8fac494509 Avoid Microsoft warning
> warning C4334: '<<': result of 32-bit shift implicitly converted to
> 64 bits (was 64-bit shift intended?)
2024-09-19 19:09:35 -03:00
Roberto Ierusalimschy
9b72355f99 USHRT_MAX changed to SHRT_MAX
USHRT_MAX does not fit in an 'int' in 16-bit systems.
2024-09-19 19:06:16 -03:00
Roberto Ierusalimschy
ddfa1fbccf GC back to controling pace counting bytes
Memory is the resource we want to save. Still to be reviewed again.
2024-09-19 19:02:14 -03:00
Roberto Ierusalimschy
b443145ff3 Details
Fixed comments in sort partition.
2024-09-12 11:08:11 -03:00
Roberto Ierusalimschy
4901853c11 Parameter for lua_gc/LUA_GCSTEP changed to 'size_t'
'size_t' is the common type for measuring memory. 'int' can be too
small for steps.
2024-09-10 17:05:39 -03:00
Roberto Ierusalimschy
a04e0ffdb9 Rename of fields in global state that control GC
All fields in the global state that control the pace of the garbage
collector prefixed with 'GC'.
2024-09-06 14:38:39 -03:00
Roberto Ierusalimschy
007b8c7a01 Details
Identation + comments
2024-09-06 14:35:04 -03:00
Roberto Ierusalimschy
fd0e1f530d Added option for direct correction of stack pointers
The use of a pointer (not access, only for computations) after its
deallocation is forbiden in ISO C, but seems to work fine in all
platforms we are aware of. So, using that to correct stack pointers
after a stack reallocation seems safe and is much simpler than the
current implementation (first change all pointers to offsets and
then changing the offsets back to pointers). Anyway, for now that
option is disabled.
2024-08-22 11:11:00 -03:00
Roberto Ierusalimschy
75620b45ae 'lcode.c' can use 'checklimit', too 2024-08-20 15:15:23 -03:00
Roberto Ierusalimschy
3e88b72b8e A return can have at most 254 values 2024-08-19 18:39:25 -03:00
Roberto Ierusalimschy
8b752ddf14 Bug: wrong code gen. for indices with comparisons
In function 'luaK_exp2val', used to generate code for indices: Macro
'hasjumps' does not consider the case when the whole expression is a
"jump" (a test). In all other of its uses, the surrounding code ensures
that the expression cannot be VJMP.
2024-08-17 12:47:28 -03:00
Roberto Ierusalimschy
1bf4b80f1a Floats formatted with "correct" precision
Conversion float->string ensures that, for any float f,
tonumber(tostring(f)) == f, but still avoiding noise like 1.1
converting to "1.1000000000000001".
2024-08-02 15:09:30 -03:00
Roberto Ierusalimschy
4c6afbcb01 Struct 'transferinfo' moved to "lua_State"
That reduces the size of "CallInfo". Moreover, bit CIST_HOOKED from
call status is not needed. When in a hook, 'transferinfo' is always
valid, being zero when the hook is not call/return.
2024-07-30 10:16:19 -03:00
Roberto Ierusalimschy
f2206b2abe '-Wconversion' extended to all options of Lua numbers 2024-07-27 15:13:21 -03:00
Roberto Ierusalimschy
0acd55898d Added gcc option '-Wconversion'
No warnings for standard numerical types. Still pending alternative
numerical types.
2024-07-27 13:32:59 -03:00
Roberto Ierusalimschy
15231d4fb2 'nresults' moved into 'callstatus'
That gives us more free bits in 'callstatus', for future use.
2024-07-21 14:56:59 -03:00
Roberto Ierusalimschy
f407b3c4a1 Using CIST_CLSRET instead of trick with 'nresults'
The callstatus flag CIST_CLSRET is used in all tests for the
presence of variables to be closed in C functions.
2024-07-19 17:34:22 -03:00
Roberto Ierusalimschy
a546138d15 Explicit limit for number of results in a call
The parameter 'nresults' in 'lua_call' and similar functions has a
limit of 250. It already had an undocumented (and unchecked) limit of
SHRT_MAX, but it is seldom larger than 2.
2024-07-18 14:44:40 -03:00
Roberto Ierusalimschy
cd4de92762 Maximum stack size may not fit in unsigned short
Therefore, fields ftransfer/ntransfer in lua_Debug must have type
'int'. (Maximum stack size must fit in an 'int'.) Also, this commit
adds check that maximum stack size respects size_t for size in bytes.
2024-07-16 11:33:30 -03:00
Roberto Ierusalimschy
6b45ccf4ed Removed compatibility with "= exp" in the REPL 2024-07-05 15:19:11 -03:00
Roberto Ierusalimschy
93fd6892f8 Fixed bug in 'multiline'
'incomplete' was popping error message that should be used in case
there is no more lines to complete the input, that is, 'pushline'
returns NULL, due to end of file.
2024-07-05 15:13:46 -03:00
Roberto Ierusalimschy
193bf7919e 'printstack' (from ltests.c) made public
That function is useful for debugging the API.
2024-07-05 14:57:11 -03:00
Roberto Ierusalimschy
366c855648 lua.c loads 'readline' dynamically
(See comments in luaconf.h.) This change allows easier compilation,
as Lua compiles and works even if the package 'readline' is absent
from the system. Moreover, non-interactive uses don't load the library,
making the stand-alone slightly faster for small loads.
2024-07-04 17:11:58 -03:00
Roberto Ierusalimschy
781219dbe1 Small changes in casts from void* to functions
Macro moved to llimits.h, and casts from void* to lua_CFunction first
go through 'voidf' (a pointer to a function from void to void), a kind
of void* for functions.
2024-07-02 11:09:46 -03:00
Roberto Ierusalimschy
d71fbc3175 Updated dependencies in the make file
Mainly to include 'llimits.h' in the non-kernel files
2024-07-01 15:58:07 -03:00
Roberto Ierusalimschy
c403e456b6 New instruction format for SETLIST/NEWTABLE
New instruction format 'ivABC' (a variant of iABC where parameter vC has
10 bits) allows constructors of up to 1024 elements to be coded without
EXTRAARG.
2024-06-28 11:18:14 -03:00
Roberto Ierusalimschy
6ac7219da3 'isIT'/'isOT' turned from macros to functions 2024-06-27 15:01:57 -03:00