Roberto I
140b672e2e
Vararg table
...
Not yet optimized nor documented.
2025-09-16 13:26:24 -03:00
Roberto Ierusalimschy
03bf7fdd4f
Added missing casts from lua_Unsigned to size_t
...
size_t can be smaller than lua_Usigned.
2025-07-01 16:07:03 -03:00
Roberto Ierusalimschy
f711567448
Check string indices when loading binary chunk
...
Lua is not religious about that, but it tries to avoid crashes when
loading binary chunks.
2025-06-17 11:40:49 -03:00
Roberto Ierusalimschy
0cecf1ab6d
Dump uses varints also for integer constants
...
Unlike sizes, these constants can be negative, so it encodes those
integers into unsigned integers in a way that keeps small numbers
small.
2025-06-13 14:14:50 -03:00
Roberto Ierusalimschy
d05fe48bfd
Loading a binary chunk should not break assertions
...
Although the execution of a bad binary chunk can crash the interpreter,
simply loading it should be safe.
2025-06-04 12:55:43 -03:00
Roberto Ierusalimschy
7ade155762
Janitorial work on casts
2025-05-08 15:18:57 -03:00
Roberto Ierusalimschy
b5b1995f29
Checks for type 'int' added to binary header
...
The structure 'AbsLineInfo' is hard-dumped into binary chunks, and
it comprises two 'int' fields.
2025-03-10 15:21:32 -03:00
Roberto Ierusalimschy
e5f4927a0b
Array sizes in undump changed from unsigned to int
...
Array sizes are always int and are dumped as int, so there is no reason
to read them back as unsigned.
2025-02-20 10:09:04 -03:00
Roberto Ierusalimschy
2d8d5c74b5
Details
...
New year (2024->2025), typos in comments
2025-01-16 11:51:16 -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
c1dc08e8e8
Length of external strings must fit in Lua integer
...
(As the length of any string in Lua.)
2024-06-24 12:03:59 -03:00
Roberto Ierusalimschy
0593256707
'luaH_get' functions return tag of the result
...
Undoing previous commit. Returning TValue increases code size without
any visible gains. Returning the tag is a little simpler than returning
a special code (HOK/HNOTFOUND) and the tag is useful by itself in
some cases.
2024-03-21 11:23:21 -03:00
Roberto Ierusalimschy
ce6f5502c9
'luaH_get' functions return 'TValue'
...
Instead of receiving a parameter telling them where to put the result
of the query, these functions return the TValue directly. (That is,
they return a structure.)
2024-03-18 15:56:32 -03:00
Roberto Ierusalimschy
cc2b66c856
Removed type 'varint_t'
...
size_t should be big enough to count the number of strings in a dump.
(And, by definition, it is big enough to count the length of each
string.)
2024-03-13 09:16:51 -03:00
Roberto Ierusalimschy
c8121ce34b
Revising code for Varint encoding in dumps
...
- Usign lua_Unsigned to count strings.
- Varint uses a type large enough both for size_t and lua_Unsigned.
- Most-Significant Bit 0 means last byte, to conform to common usage.
- (unrelated) Change in macro 'getaddr' so that multiplication is
by constants.
2024-02-12 15:16:11 -03:00
Roberto Ierusalimschy
e7af9cdf0b
Fixed buffers reuse absolute line information
2023-12-27 17:42:00 -03:00
Roberto Ierusalimschy
4eda1acafa
Cleaner protocol between 'lua_dump' and writer function
...
'lua_dump' signals to the writer function the end of a dump, so that
is has more freedom when using the stack.
2023-12-14 11:41:57 -03:00
Roberto Ierusalimschy
eabf425c76
Correct anchoring and GC barriers in 'loadString'
...
Call to 'luaH_setint' could call the GC with the string unanchored.
Moreover, previously saved strings were being assigned to the prototype
without a barrier.
2023-11-13 13:11:09 -03:00
Roberto Ierusalimschy
3b57e37e48
Fixed buffers save long strings as external.
2023-11-10 12:35:48 -03:00
Roberto Ierusalimschy
19afd91687
Solving merge issue with use of tables in dump/undump
...
The use of tables in dump/undump to reuse strings did not exist in
the version that changed the representation of arrays, so it was not
corrected for the new API for tables.
2023-11-08 10:02:06 -03:00
Roberto Ierusalimschy
9e99f3071d
Merge branch 'master' into nextversion
2023-11-07 17:25:46 -03:00
Roberto Ierusalimschy
6baee9ef9d
Removed test for "corrupted binary dump"
...
Test is too non portable. (For instance, it does not work for
different number types.)
2023-09-08 16:19:21 -03:00
Roberto Ierusalimschy
14e416355f
Added suport for Fixed Buffers
...
A fixed buffer keeps a binary chunk "forever", so that the program
does not need to copy some of its parts when loading it.
2023-09-05 15:30:45 -03:00
Roberto Ierusalimschy
96f7714237
Field 'Proto.is_vararg' uses only one bit
...
So that the other bits can be used for other purposes.
2023-08-30 10:44:28 -03:00
Roberto Ierusalimschy
0554581605
Opcode in dumps is stored properly aligned
2023-08-25 17:40:20 -03:00
Roberto Ierusalimschy
c815c2f0eb
Merge branch 'master' into nextversion
2023-08-23 15:14:03 -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
ab6a949522
Merge branch 'master' into nextversion
2023-06-22 11:41:48 -03:00
Roberto Ierusalimschy
ab859fe59b
Bug: Loading a corrupted binary file can segfault
...
The size of the list of upvalue names are stored separated from the
size of the list of upvalues, but they share the same array.
2023-03-17 15:52:09 -03:00
Roberto Ierusalimschy
7d6a97e42b
Dump doesn't need to reuse 'source'
...
All strings are being reused now, including 'source'.
2022-12-20 11:14:52 -03:00
Roberto Ierusalimschy
d70a0c91ad
Dump/undump reuse strings
...
A repeated string in a dump is represented as an index to its first
occurence, instead of another copy of the string.
2022-12-15 16:44:22 -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
6bc0f13505
Fixed bug of long strings in binary chunks
...
When "undumping" a long string, the function 'loadVector' can call the
reader function, which can run the garbage collector, which can collect
the string being read. So, the string must be anchored during the call
to 'loadVector'.
2020-08-18 14:42:11 -03:00
Roberto Ierusalimschy
422ce50d2e
Fixed detail in 'loadUpvalues'
...
In 'lundump.c', when loading the upvalues of a function, there can be
a read error if the chunk is truncated. In that case, the creation
of the error message can trigger an emergency collection while the
prototype is still anchored. So, the prototype must be GC consistent
before loading the upvales, which implies that it the 'name' fields
must be filled with NULL before the reading.
2020-06-30 15:36:26 -03:00
Roberto Ierusalimschy
c33b1728ae
Details
...
Added as incompatibility, in the manual, the extra return of 'io.lines'.
2020-06-18 11:07:27 -03:00
Roberto Ierusalimschy
6d7cd31fee
Fixed missing GC barriers in compiler and undump
...
While building a new prototype, the GC needs barriers for every object
(strings and nested prototypes) that is attached to the new prototype.
2020-06-16 09:54:20 -03:00
Roberto Ierusalimschy
61a4e64a66
Back to old encoding of versions in binary files
...
(Undoing part of commit f53eabeed8.) It is better to keep this encoding
stable, so that all Lua versions can read at least the version of a
binary file.
2020-05-06 14:19:08 -03:00
Roberto Ierusalimschy
e8a52281d9
Code style in 'ldump'/'lundump'.
...
- function names start with lower case;
- state is always the first parameter.
2020-02-27 15:17:44 -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
5ff408d218
Changed internal representation of booleans
...
Instead of an explicit value (field 'b'), true and false use different
tag variants. This avoids reading an extra field and results in more
direct code. (Most code that uses booleans needs to distinguish between
true and false anyway.)
2020-01-06 11:38:31 -03:00
Roberto Ierusalimschy
f6aab3ec1f
First implementation of constant propagation
...
Local constant variables initialized with compile-time constants
are optimized away from the code.
2019-07-12 11:38:42 -03:00
Roberto Ierusalimschy
54f7b46c1e
New implementation for constants
...
VLOCAL expressions keep a reference to their corresponding 'Vardesc',
and 'Upvaldesc' (for upvalues) has a field 'ro' (read-only). So, it is
easier to check whether a variable is read-only. The decoupling in
VLOCAL between 'vidx' ('Vardesc' index) and 'sidx' (stack index)
should also help the forthcoming implementation of compile-time
constant propagation.
2019-07-09 10:43:17 -03:00
Roberto Ierusalimschy
ed2872cd3b
'require' returns where module was found
...
The function 'require' returns the *loader data* as a second result.
For file searchers, this data is the path where they found the module.
2019-04-17 14:57:29 -03:00
Roberto Ierusalimschy
f53eabeed8
Small changes in the header of binary files
...
- LUAC_VERSION is equal to LUA_VERSION_NUM, and it is stored
as an int.
- 'sizeof(int)' and 'sizeof(size_t)' removed from the header, as
the binary format does not depend on these sizes. (It uses its
own serialization for unsigned integer values.)
2019-03-19 15:31:08 -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
b397064955
avoid craches when loading tampered code with NULL as a string constant
2018-06-01 13:45:58 -03:00
Roberto Ierusalimschy
7622373033
using explicit tests for allocation overflow whenever possible
2017-12-07 16:59:52 -02:00
Roberto Ierusalimschy
dfd188ba12
detail (identation of switch)
2017-11-28 09:19:07 -02: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
124bfd2081
dumping ints and size_ts compacted
2017-06-27 11:21:12 -03:00