Commit Graph

250 Commits

Author SHA1 Message Date
Roberto Ierusalimschy
c31d6774ac Details 2024-01-29 14:29:24 -03:00
Roberto Ierusalimschy
12b6f610b0 Several tweaks in the garbage collector
- back with step size in collectgarbage("step")
- adjustments in defaults for some GC parameters
- adjustments in 'luaO_codeparam'
2023-12-27 12:09:11 -03:00
Roberto Ierusalimschy
ad0ea7813b GC parameters encoded as floating-point bytes
This encoding brings more precision and a larger range for these
parameters.
2023-12-20 16:25:20 -03:00
Roberto Ierusalimschy
9b4f39ab14 More disciplined use of 'getstr' and 'tsslen'
We may want to add other string variants in the future; this change
documents better where the code may need to handle those variants.
2023-08-17 15:59:28 -03:00
Roberto Ierusalimschy
413a393e62 Stack indices changed to union's
That will allow to change pointers to offsets while reallocating
the stack.
2022-10-29 12:06:37 -03:00
Roberto Ierusalimschy
26be27459b Negation in constant folding of '>>' may overflow 2022-09-23 11:08:10 -03:00
Roberto Ierusalimschy
d61b0c6028 More checks and documentation for uses of EXTRA_STACK 2022-05-26 15:14:54 -03:00
Roberto Ierusalimschy
8dd2c912d2 Detail
Warnings with clang when using long double for Lua floats.
2022-01-03 09:12:17 -03:00
Roberto Ierusalimschy
58216600eb 'luaL_newstate' should not allocate extra memory
The allocation of a userdata for the state of the warn system can
cause a panic if it fails; 'luaL_ref' also can fail. This commit
re-implements the warn system so that it does not need an explicit
state. Instead, the system uses different functions to represent
the different states.
2020-11-03 16:34:36 -03:00
Roberto Ierusalimschy
0280407fc5 Details
Comments in makefile and function 'l_str2d'.
2020-07-03 13:02:41 -03:00
Roberto Ierusalimschy
ae809e9fd1 'luaV_concat' can "concat" one single value
Several of its callers needed that case and had to do the check
themselves.
2020-07-03 11:54:58 -03:00
Roberto Ierusalimschy
e96385aded Simplification and smaller buffers for 'lua_pushfstring'
The function 'lua_pushfstring' is seldom called with large strings,
there is no need to optimize too much for that cases.
2020-07-03 11:36:56 -03:00
Roberto Ierusalimschy
72a094bda7 Undo change in the handling of 'L->top' (commit b80077b8f3)
With MMBIN instructions, there are fewer opcodes that need to update
'L->top', so that change does not seem to pay for the increased
complexity.
2019-08-29 12:52:37 -03:00
Roberto Ierusalimschy
b80077b8f3 Change in the handling of 'L->top' when calling metamethods
Instead of updating 'L->top' in every place that may call a
metamethod, the metamethod functions themselves (luaT_trybinTM and
luaT_callorderTM) correct the top. (When calling metamethods from
the C API, however, the callers must preserve 'L->top'.)
2019-07-26 14:59:39 -03:00
Roberto Ierusalimschy
1fb4d53925 OP_NEWTABLE keeps exact size of arrays
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.)
2019-07-12 16:13:50 -03:00
Roberto Ierusalimschy
2c68e66570 Details
Several small changes from feedback on 5.4 alhpa rc1 (warnings,
typos in the manual, and the like)
2019-06-03 11:36:42 -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
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
b36e26f51b Some more small improvements to 'luaO_pushvfstring'
Details:
- counter 'pushed' moved to the struct 'BuffFS'
- new auxiliar function 'getbuff' to build strings directly on
the buffer.
2019-04-26 11:24:39 -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
5ca1075b71 Added field 'srclen' to structure 'lua_Debug'
This new field gets the length of 'source' in the same structure.
Unlike the other strings in that structure, 'source' can be
relatively large, and Lua already has its length readily available.
2019-04-04 11:45:26 -03:00
Roberto Ierusalimschy
1e0c73d5b6 Changes in the validation of UTF-8
All UTF-8 encoding functionality (including the escape
sequence '\u') accepts all values from the original UTF-8
specification (with sequences of up to six bytes).

By default, the decoding functions in the UTF-8 library do not
accept invalid Unicode code points, such as surrogates. A new
parameter 'nonstrict' makes them accept all code points up to
(2^31)-1, as in the original UTF-8 specification.
2019-03-15 13:14:17 -03:00
Roberto Ierusalimschy
5e76a4fd31 New macros for arithmetic/bitwise operations in 'luaV_execute'
The repetitive code of the arithmetic and bitwise operators in
the main iterpreter loop was moved to appropriate macros.
(As a detail, the function 'luaV_div' was renamed 'luaV_idiv',
as it does an "integer division" (floor division).
2018-11-05 16:10:42 -02:00
Roberto Ierusalimschy
5382a22e0e Corrections in the implementation of '%' for floats.
The multiplication (m*b) used to test whether 'm' is non-zero and
'm' and 'b' have different signs can underflow for very small numbers,
giving a wrong result. The use of explicit comparisons solves this
problem. This commit also adds several new tests for '%' (both for
floats and for integers) to exercise more corner cases, such as
very large and very small values.
2018-08-28 12:36:58 -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
505fc91222 no more 'luaO_nilobject' to avoid comparison of global variable addresses
(now uses static variables)
2018-06-01 14:40:38 -03:00
Roberto Ierusalimschy
deb807837c 'luaO_pushvfstring' does not need to reallocate stack
(less error cases in the API)
2018-04-25 13:26:20 -03:00
Roberto Ierusalimschy
34b00c16e2 removed compatibility code with older versions 2018-02-27 15:47:32 -03:00
Roberto Ierusalimschy
e2b15aa21d janitor work on casts 2018-01-28 13:13:26 -02:00
Roberto Ierusalimschy
a9295a2b8e typos in comments 2017-12-30 18:46:18 -02:00
Roberto Ierusalimschy
599f1742c6 detail (typo in comments) 2017-11-23 17:29:04 -02:00
Roberto Ierusalimschy
e4e5aa85a2 detail ('signal' -> 'sign' in comments) 2017-11-16 11:19:06 -02:00
Roberto Ierusalimschy
26679ea35b new function 'luaV_flttointeger' to convert floats to integers (without
string coercions) + string operands to bitwise operations handled
by string metamethods
2017-11-08 12:50:23 -02:00
Roberto Ierusalimschy
911f1e3e7f raw operation should not convert strings to numbers 2017-10-10 17:05:40 -03:00
Roberto Ierusalimschy
4dff277255 coercion string->number in arithmetic operations moved to string
library
2017-07-07 13:34:32 -03:00
Roberto Ierusalimschy
f96497397a new type 'StackValue' for stack elements
(we may want to put extra info there in the future)
2017-06-29 12:06:44 -03:00
Roberto Ierusalimschy
a9dbc2d641 assert removed in 'luaO_arith'
(nobody calls it with L==NULL)
2017-05-24 10:47:11 -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
09c9fa36ea small corrections for C++ compliance 2016-06-27 10:15:08 -03:00
Roberto Ierusalimschy
10b0b09555 do not convert decimal constants with overflow to integers.
(Therefore, they will be converted as floats)
2016-05-20 11:07:48 -03:00
Roberto Ierusalimschy
ed110f66c5 'luaO_str2num' (and, therefore, 'lua_stringtonumber', 'number',
and coercions) accepts both the locale point and a dot as its
radix character
2016-05-02 11:00:32 -03:00
Roberto Ierusalimschy
2d1d57bc18 comments 2015-12-14 09:53:27 -02:00
Roberto Ierusalimschy
8c1fb91802 macro 'incr_top' replaced by function 'luaD_inctop'. (It is not used
in critical time pathes, can save a few bytes without the macro)
2015-11-02 14:09:30 -02:00
Roberto Ierusalimschy
332a06bbd1 'luaO_pushvfstring' now uses 'incr_top' to increment top. 2015-11-02 12:02:35 -02:00
Roberto Ierusalimschy
e89763e964 simpler code for 'luaO_fb2int' 2015-06-26 16:32:07 -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
69b5f7a410 some details in 'luaO_int2fb' + more consistent use of the locale
decimal point
2015-04-11 15:30:08 -03:00
Roberto Ierusalimschy
e723c75c02 details (avoid 'lint' warnings) 2015-03-28 16:14:47 -03:00
Roberto Ierusalimschy
c8d6cb0136 macros 'luai_num*' (for float arithmetic operations) moved to
llimits.h.
2015-02-05 15:15:33 -02:00