Commit Graph

295 Commits

Author SHA1 Message Date
Roberto Ierusalimschy
69b77b6fde Changed the growth rate of string buffers
The growth rate of string buffers was reduced from 2 to 1.5 (3/2).
As string buffers start larger (256~1024 bytes), they don't need to
grow that fast. Moreover, a lower rate allows multiplicative growth up
to larger sizes (3/2 of the maximum). (After that, the growth becomes
linear, which is mostly useless.)
2022-09-06 10:58:55 -03:00
Roberto Ierusalimschy
4a00f61276 'lua_checkstack' doesn't need to check stack overflow
'luaD_growstack' already checks that. This commit also fixes an
internal bug in 'luaD_growstack': a large 'n' could cause an arithmetic
overflow when computing 'needed'.
2022-05-23 10:38:03 -03:00
Roberto Ierusalimschy
1e6918d553 Details
- Removed unused (and trivial) definition LUA_UNSIGNEDBITS
- Alignment structure in pack/unpack moved to a narrower scope
2021-05-24 16:48:09 -03:00
Roberto Ierusalimschy
eadd8c7178 Added option LUA_NOBUILTIN
This option allows external code to avoid the use of gcc builtin macro
'__builtin_expect' in the Lua API.
2021-03-12 15:03:33 -03:00
Roberto Ierusalimschy
a7b8b27dd3 Uses of "likely" in macros active to all users
The use of 'l_likely' in auxlib macros 'luaL_argcheck' and
'luaL_argexpected' should not be restricted to Lua's own code.
For that, 'l_likely' was renamed to 'luai_likely' to be exported
to external code.
2021-03-09 12:50:59 -03:00
Roberto Ierusalimschy
59c88f846d Broadening the use of branch hints
More uses of macros 'likely'/'unlikely' (renamed to
'l_likely'/'l_unlikely'), both in range (extended to the
libraries) and in scope (extended to hooks, stack growth).
2021-02-24 11:14:44 -03:00
Roberto Ierusalimschy
dee6433a89 Forbid changing numerical types through compiler options
'luaconf.h' always defines options LUA_32BITS, LUA_C89_NUMBERS,
LUA_INT_TYPE, and LUA_FLOAT_TYPE (using 0/1 for the first two),
to avoid they being set through compiler options. (It is too easy
to forget these options when compiling other software that
interoperates with Lua.)
2021-02-05 15:30:34 -03:00
Roberto Ierusalimschy
287b302acb Revision of stackless implementation
- more organized handling of 'nCcalls'
- comments
- deprecation of 'setcstacklimit'
2020-10-12 12:29:09 -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
2d92102dee 'l_mathlim' renamed to 'l_floatatt'
That macro is applied to float attributes, not to limits.
2019-12-05 13:31:07 -03:00
Roberto Ierusalimschy
e888976bc6 Details (typos in comments) 2019-07-05 15:03:15 -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
b293ae0577 Details
- 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'
2019-05-28 15:46:49 -03:00
Roberto Ierusalimschy
347d6961ac Define LUA_MAXUNSIGNED as a preprocessor constant
The previous definition of LUA_MAXUNSIGNED used a typecast,
making it unsuitable for constant expressions in the preprocessor.
2019-05-14 11:10:24 -03:00
Roberto Ierusalimschy
279c3a6961 A few changes in tests about number of bits in integers
- 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.
2019-05-13 16:17:21 -03:00
Roberto Ierusalimschy
49c42f3615 Some improvements in 'luaconf.h'
Added '#if !defined' in some definitions to allow external definitions;
more comments; other small changes.
2019-05-13 14:24:10 -03:00
Roberto Ierusalimschy
7c5786479c A few more improvements in 'luaO_pushvfstring'
- '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
2019-05-03 10:18:44 -03:00
Roberto Ierusalimschy
3da34a5fa7 Revamp of 'lua_pushfstring' / 'luaO_pushvfstring'
The function 'luaO_pushvfstring' now uses an internal buffer to
concatenate small strings, instead of pushing all pieces on the
stack. This avoids the creation of several small Lua strings for each
piece of the result. (For instance, a format like "n: '%d'" used to
create three intermediate strings: "n: '", the numeral, and "'".
Now it creates none.)
2019-04-24 14:01:20 -03:00
Roberto Ierusalimschy
2d3f095448 Avoid using large buffers in 'string.format'
The result of "string.format("%.99f", -1e308) is 410 characters long,
but all other formats have much smaller limits (at most 99 plus a fex
extras). This commit avoids 'string.format' asking for a buffer
~400 chars large when ~100 will do.
2019-04-12 11:48:24 -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
d40cd315f5 Visibility of non-API functions changed to "internal"
The visibility for functions marked as LUAI_FUNC was changed from
"hidden" to "internal". These functions cannot be called from
outside the Lua kernel, and "internal" visibility offers more
chances for optimizations.
2018-11-13 13:58:46 -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
f59e6a93c0 opening functions must be exported! 2018-06-19 16:23:57 -03:00
Roberto Ierusalimschy
b43300c14f change in 'LUAI_DDEC' to allow variables to be static in 'onelua'
+ change in 'LUAMOD_API' as opening functions do not need to be global
2018-06-18 09:51:05 -03:00
Roberto Ierusalimschy
b6780ee41b detail (removed unused definition for 'LUA_QS') 2018-06-15 12:49:28 -03:00
Roberto Ierusalimschy
8d50a998e3 definition for LUA_UNSIGNEDBITS (number of bits in a LUA_UNSIGNED) 2018-04-02 10:58:33 -03:00
Roberto Ierusalimschy
40683b4934 added definition for LUA_MAXUNSIGNED 2018-03-09 11:56:02 -03:00
Roberto Ierusalimschy
0eb10c6303 'LUA_USE_READLINE' moved to the make file 2018-03-02 15:31:51 -03:00
Roberto Ierusalimschy
34b00c16e2 removed compatibility code with older versions 2018-02-27 15:47:32 -03:00
Roberto Ierusalimschy
6353d619a5 detail (comment) 2018-02-20 17:52:50 -03:00
Roberto Ierusalimschy
a9295a2b8e typos in comments 2017-12-30 18:46:18 -02:00
Roberto Ierusalimschy
46bc7f2bf7 detail (comment) 2017-12-07 16:53:33 -02:00
Roberto Ierusalimschy
2caecf1b3e type 'L_Umaxalign' replaced by macro 'LUAI_MAXALIGN', which is also added
to the auxlib buffer
2017-04-24 15:06:12 -03:00
Roberto Ierusalimschy
a45945b6d5 new macro 'lua_pointer2str' to encapsulate use of 'l_sprintf' inside
the kernel
2017-04-19 13:34:35 -03:00
Roberto Ierusalimschy
2a235312f0 detail (removing spaces at end of lines) 2016-12-22 11:08:50 -02:00
Roberto Ierusalimschy
9903dd52a3 Using LUAI_UAC* types more consistently on vararg calls 2016-12-20 16:37:00 -02:00
Roberto Ierusalimschy
349badabc1 wrong test in '#if' for floating-point type 2016-08-22 14:21:12 -03:00
Roberto Ierusalimschy
de3fd8ab83 Handling of LUA_PATH/LUA_CPATH moved from package library to stand
alone interpreter (so that 'lua.c' concentrates all handling of
environment variables)
2016-07-18 14:55:59 -03:00
Roberto Ierusalimschy
792ffaccf2 detail (macro should "use" all its arguments) 2016-05-01 17:06:09 -03:00
Roberto Ierusalimschy
48098c42ff generic definitions for float types moved to before variable definitions
(so that specific cases can redefine these generic definitions if
needed)
2015-10-21 16:17:40 -02:00
Roberto Ierusalimschy
cb1e451999 detail 2015-06-24 15:23:57 -03:00
Roberto Ierusalimschy
19eb6ae580 using 'snprintf' in C99 (both for documentation of buffer sizes
and some complains from tools)
2015-06-18 11:26:05 -03:00
Roberto Ierusalimschy
99391e24ea new configuration macro 'l_mathlim' (simplifies some dependencies
on float type)
2015-05-20 14:39:23 -03:00
Roberto Ierusalimschy
48d0674c2e more consistent use of locale radix character across Lua 2015-04-03 15:41:57 -03:00
Roberto Ierusalimschy
cfc84c856d 'LUA_REAL_*' -> 'LUA_FLOAT_*' (everywhere else we are using 'float') 2015-03-31 09:00:07 -03:00
Roberto Ierusalimschy
a30c66f0fc macro 'luai_apicheck'/'api_check' back with a 'lua_State' parameter
(some people use it)
2015-03-06 16:49:50 -03:00
Roberto Ierusalimschy
951b562cf8 configuration for numerical types through only one #define for
each type
2015-03-02 13:59:01 -03:00
Roberto Ierusalimschy
91efb4b895 LUA_COMPAT_5_1 needs some options deprecated from 5.2 to 5.3 2015-02-28 16:22:31 -03:00