114 Commits

Author SHA1 Message Date
Roberto I
f791bb6906 Details
- New macro l_strcoll to ease changing 'strcoll' to something else.
- MAXINDEXRK==1 in 'ltests.h' is enough to run test 'code.lua'.
- Removed unused '#include' in 'lutf8lib.c'.
2025-10-31 14:48:55 -03:00
Roberto I
03a3473687 'ltests.h' should not use LUAI_FUNC
LUAI_FUNC is now defined in llimits.h.
2025-08-27 10:28:31 -03:00
Roberto I
06c5d3825f Removed code for compatibility with version 5.3 2025-08-20 16:10:54 -03:00
Roberto Ierusalimschy
8fddca81e7 'onelua' can use the test library
Just add -DLUA_USER_H='"ltests.h"' when compiling it.
2025-07-29 14:35:04 -03:00
Roberto Ierusalimschy
59a1adf194 LUAI_MAXSTACK defined privately
LUAI_MAXSTACK is limited to INT_MAX/2, so can use INT_MAX/2 to define
pseudo-indices (LUA_REGISTRYINDEX) in 'lua.h'. A change in the maximum
stack size does not need to change the Lua-C ABI.
2025-07-01 10:57:02 -03:00
Roberto Ierusalimschy
be81209063 First implementation of global declarations 2025-05-05 16:24:59 -03:00
Roberto Ierusalimschy
93e347b519 Corrections of stack addresses back to strict mode
It can be a little slower, but only for quite large stacks and moreover
stack reallocation is not a common operation.  With no strong contrary
reason, it is better to follow the standard.
2025-04-01 10:41:25 -03:00
Roberto Ierusalimschy
ef5d171cc8 New macro 'l_numbits' 2025-03-27 12:38:29 -03:00
Roberto Ierusalimschy
205f9aa67b New function 'printallstack' in test library 2025-03-17 14:30:43 -03:00
Roberto Ierusalimschy
f9e35627ed 'lua_State.nci' must be an integer
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-26 11:31:10 -03:00
Roberto Ierusalimschy
cd38fe8cf3 Added macro LUAI_STRICT_ADDRESS
By default, the code assumes it is safe to use a dealocated pointer
as long as the code does not access it.
2025-02-18 17:02:32 -03:00
Roberto Ierusalimschy
04e495403b New function 'lua_printvalue' for internal debugging 2024-12-02 11:19:03 -03:00
Roberto Ierusalimschy
258355734d Better support in 'ltests' for tracing the GC 2024-10-21 15:18:20 -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
e81f586001 Removed compatibility option LUA_COMPAT_GCPARAMS
The meaning of different GC parameters changed, so there is point in
supporting old values for them. The new code simply ignores the
parameters when changing the GC mode, so the incompatibility is small.
2023-12-22 14:57:43 -03:00
Roberto Ierusalimschy
e2cc179454 New option "setparms" for 'collectgarbage'
The generational mode also uses the parameters for the incremental
mode in its major collections, so it should be easy to change those
parameters without having to change the GC mode.
2023-12-22 14:48:07 -03:00
Roberto Ierusalimschy
5a04f1851e New function 'luaL_makeseed'
This function unifies code from 'lua_newstate', 'math.randomseed',
and 'table.sort' that tries to create a value with a minimum level
of randomness.
2023-03-20 16:13:17 -03:00
Roberto Ierusalimschy
d738c8d18b New function 'luaL_openselectedlibs'
Makes it easier to start Lua with only some standard libraries.
2022-12-07 15:12:52 -03:00
Roberto Ierusalimschy
c764ca71a6 Bug: Wrong code generation in bitwise operations 2022-04-25 14:42:51 -03:00
Roberto Ierusalimschy
e2ea3b31c9 Details (do not affect regular code)
* Avoids multiple definitions of 'lua_assert' in test file.
* Smaller C-stack limit in test mode.
* Note in the manual about the use of false
* Extra test for constant reuse.
2020-12-07 11:17:30 -03:00
Roberto Ierusalimschy
5d8ce05b3f Back to a stackless implementation
A "with stack" implementation gains too little in performance to be
worth all the noise from C-stack overflows.

This commit is almost a sketch, to test performance. There are several
pending stuff:

- review control of C-stack overflow and error messages;
- what to do with setcstacklimit;
- review comments;
- review unroll of Lua calls.
2020-10-12 12:29:09 -03:00
Roberto Ierusalimschy
b9b554e0f6 Clearer handling of gray lists when entering generational mode
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.
2020-08-03 13:22:57 -03:00
Roberto Ierusalimschy
8c7c9ea065 Function 'printobj' in 'ltests.c' made public
It helps to have this function available for debugging.
2020-07-27 11:24:03 -03:00
Roberto Ierusalimschy
6f5bd5072d Macro LUAI_ASSERT eases turning assertions on 2020-07-08 15:51:55 -03:00
Roberto Ierusalimschy
948fb628d9 Details
When in test mode (#include "tests.h"), force Lua to use its own
implementation of 'lua_strx2number' and 'lua_number2strx' to test them.
2020-04-30 17:29:27 -03:00
Roberto Ierusalimschy
6eb53b7526 Details
Several details in code (e.g., moving a variable to the most inner
scope that encloses its uses), comments, parameter names, extra tests.
2020-02-27 12:59:22 -03:00
Roberto Ierusalimschy
46c3587a6f Clearer distinction between types and tags
LUA_T* represents only types; tags (types + Variants) are represented
by LUA_V* constants.
2020-01-31 11:09:53 -03:00
Roberto Ierusalimschy
8b7cfee26b Small changes around C-stack limit
- 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'.
2019-06-26 13:26:36 -03:00
Roberto Ierusalimschy
be73f72fcc New function 'setCstacklimit'
Added new functions to dynamically set the C-stack limit
('lua_setCstacklimit' in the C-API, 'debug.setCstacklimit' in Lua).
2019-06-18 16:52:22 -03:00
Roberto Ierusalimschy
0443ad9e28 LUAI_MAXCCALLS renamed LUAI_MAXCSTACK
The limit LUAI_MAXCCALLS was renamed LUAI_MAXCSTACK, which better
represents its meaning. Moreover, its definition was moved to
'luaconf.h', given its importance now that Lua does not use
a "stackless" implementation.
2019-03-25 14:12:06 -03:00
Roberto Ierusalimschy
ba7da13ec5 Changes in the control of C-stack overflow
* unification of the 'nny' and 'nCcalls' counters;
  * external C functions ('lua_CFunction') count more "slots" in
    the C stack (to allow for their possible use of buffers)
  * added a new test script specific for C-stack overflows. (Most
    of those tests were already present, but concentrating them
    in a single script easies the task of checking whether
    'LUAI_MAXCCALLS' is adequate in a system.)
2018-12-27 14:32:29 -02:00
Roberto Ierusalimschy
84e32ad2eb Added opcodes for arithmetic with K operands
Added opcodes for all seven arithmetic operators with K operands
(that is, operands that are numbers in the array of constants of
the function). They cover the cases of constant float operands
(e.g., 'x + .0.0', 'x^0.5') and large integer operands (e.g.,
'x % 10000').
2018-11-23 12:23:45 -02:00
Roberto Ierusalimschy
8c8a91f2ef Deprecated the emulation of '__le' using '__lt'
As hinted in the manual for Lua 5.3, the emulation of the metamethod
for '__le' using '__le' has been deprecated. It is slow, complicates
the logic, and it is easy to avoid this emulation by defining a proper
'__le' function.

Moreover, often this emulation was used wrongly, with a programmer
assuming that an order is total when it is not (e.g., NaN in
floating-point numbers).
2018-08-24 10:17:54 -03:00
Roberto Ierusalimschy
f99509581e Removed extra information from RCS keyword strings
Version numbers and dates (mostly wrong) from RCS keyword strings
removed from all source files; only the file name are kept.
2018-08-23 14:26:12 -03:00
Roberto Ierusalimschy
3e7415e846 reorganization of '#if's for sellecting a type for 'Rand64' +
comments
2018-05-04 17:01:45 -03:00
Roberto Ierusalimschy
26eb144541 no need to define 'luaP_opnames' in regular builds 2018-04-19 12:42:41 -03:00
Roberto Ierusalimschy
f9c3d6fdbe use test mode to test the interpreter without jump tables 2018-04-11 13:49:36 -03:00
Roberto Ierusalimschy
34b00c16e2 removed compatibility code with older versions 2018-02-27 15:47:32 -03:00
Roberto Ierusalimschy
7024f49c42 default now is compiling without compatibility options + smaller
stack size in debug mode (clang uses still more stack space when
debugging).
2017-12-18 11:01:49 -02:00
Roberto Ierusalimschy
cc01d46247 new test function 'T.allocount' to restrict number of allocations
before a memory-allocation error
2017-12-07 16:51:39 -02:00
Roberto Ierusalimschy
196c87c9ce no more 'stackless' implementation; 'luaV_execute' calls itself
recursively to execute function calls. 'unroll' continues all
executions suspended by an yield (through a long jump)
2017-11-23 14:41:16 -02:00
Roberto Ierusalimschy
fb9be62f79 includes 'stdio.h' to allow prints when testing 2017-11-13 10:19:35 -02:00
Roberto Ierusalimschy
b42430fd3a 'lineinfo' in prototypes saved as differences instead of absolute
values, so that the array can use bytes instead of ints, reducing
its size. (A new array 'abslineinfo' is used when line differences
do not fit in a byte.)
2017-06-27 08:35:31 -03:00
Roberto Ierusalimschy
d55fd3455b redefine MAXINDEXRK (for debugging, to force most values to
go through registers)
2016-07-19 14:13:00 -03:00
Roberto Ierusalimschy
9fae7b6d3f code for string cache generalized for "associative sets" (compiler
will optimize away or inline the extra loops)
2015-09-22 11:18:24 -03:00
Roberto Ierusalimschy
95c3144393 redefine 'l_sprintf' to test correctness of buffer sizes given
to 'snprintf'
2015-06-18 11:27:44 -03:00
Roberto Ierusalimschy
a51069202a removed macro 'luai_numinvalidop' (main motivation removed, as folding
does not handle any division by zero by default)
2014-12-26 12:44:44 -02:00
Roberto Ierusalimschy
3ae21a352c detail (in test for 'luai_numinvalidop', use a round float) 2014-12-19 11:33:06 -02:00
Roberto Ierusalimschy
5fae2a5b05 redefinition of LUAI_MAXSTACK to make stack-overflow tests run faster 2014-12-09 15:17:40 -02:00
Roberto Ierusalimschy
36efa6a6b9 no more 'preloadedlibs' when opening libraries (as it is dead code now) 2014-12-09 13:00:17 -02:00