Commit Graph

328 Commits

Author SHA1 Message Date
Roberto Ierusalimschy
52c8679760 Fixed bug of keys removed from tables vs 'next'
Fixed the bug that a key removed from a table might not be found
again by 'next'. (This is needed to allow keys to be removed during a
traversal.) This bug was introduced in commit 73ec04fc.
2020-10-14 15:46:58 -03:00
Roberto Ierusalimschy
7c3cb71fa4 Free bit 7 of GC 'marked' field
Tables were using this bit to indicate their array sizes were real
('isrealasize'), but this bit can be useful for tests. Instead, they
can use bit 7 of their 'flag' field for that purpose. (There are only
six fast-access metamethods.) This 'flag' field only exists in tables,
so this use does not affect other types.
2020-08-07 11:21:44 -03:00
Roberto Ierusalimschy
68109afcdb Detail (in asserts)
Macro 'checkconsistency' replaced by the similar 'checkliveness".
2020-08-03 16:05:10 -03:00
Roberto Ierusalimschy
9514abc2da Cleaner definition for 'TString'
Use a variable-sized array to store string contents at the end of a
structure 'TString', instead of raw memory.
2020-05-19 12:42:20 -03:00
Roberto Ierusalimschy
0ddc0f47bd Several details about 5.4.0 rc1
Corrected several small details: added 'const', adjusts in tabs x
spaces, removed unused #includes and #defines, misspellings, etc.
2020-04-23 14:48:15 -03:00
Roberto Ierusalimschy
28ef7061bb Tag values don't need to be different from type values
Variants can use zero for first variant.
2020-01-31 13:13:28 -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
69c7139ff8 New macro 'makevariant' to codify variant tags 2020-01-06 14:50:36 -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
b8cdea0190 Changed definition of macro 'l_isfalse'
The old definition did one test for nil, but three tests for the all
too common booleans (and two tests for other values); this definition
does two tests for all values.
2019-10-22 14:10:54 -03:00
Roberto Ierusalimschy
e592f94a64 Details (mostly comments) 2019-10-22 14:08:22 -03:00
Roberto Ierusalimschy
dc07719b0d Tag LUA_TUPVALTBC replaced by a flag
It is simpler to signal a to-be-closed upvalue with a boolean flag,
instead of using a different tag.
2019-07-19 11:12:31 -03:00
Roberto Ierusalimschy
3c1d415bd3 Details
- Macro 'checkliveness' (for debug) always uses 'L', to avoid warnings.
- Some old 'while' changed to 'for' in 'testes/gc.lua'.
- In 'testes/libs/makefile', do not make files depend on 'ltests.h',
which may not even exist.
2019-07-18 15:31:22 -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
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
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
c5feac2b5e Strings inside Lua are not fully aligned
Removed code to ensure that strings inside Lua (as returned by
'lua_tolstring') always start in fully aligned addresses.
Since version 5.3 the documentation does not ensure that.
2019-03-13 14:14:40 -03:00
Roberto Ierusalimschy
e8c779736f Removed internal cache for closures
The mechanism of "caching the last closure created for a prototype to
try to reuse it the next time a closure for that prototype is created"
was removed. There are several reasons:

- It is hard to find a natural example where this cache has a measurable
impact on performance.

- Programmers already perceive closure creation as something slow,
so they tend to avoid it inside hot paths. (Any case where the cache
could reuse a closure can be rewritten predefining the closure in some
variable and using that variable.)

- The implementation was somewhat complex, due to a bad interaction
with the generational collector. (Typically, new closures are new,
while prototypes are old. So, the cache breaks the invariant that
old objects should not point to new ones.)
2018-11-01 13:21:00 -03:00
Roberto Ierusalimschy
4cd1f4aac0 Towards "to closed" local variables
Start of the implementation of "scoped variables" or "to be closed"
variables, local variables whose '__close' (or themselves) are called
when they go out of scope. This commit implements the syntax, the
opcode, and the creation of the corresponding upvalue, but it still
does not call the finalizations when the variable goes out of scope
(the most important part).

Currently, the syntax is 'local scoped name = exp', but that will
probably change.
2018-10-08 10:42:07 -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
b95e466218 new field 'nilvalue' in struct 'global_State' to avoid the use of
addresses of static variables
2018-06-15 16:31:22 -03:00
Roberto Ierusalimschy
6e600695f8 field 'sizearray' in struct 'Table' changed to 'alimit', which can
be used as a hint for '#t'
2018-06-15 11:14:20 -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
fb8fa66136 no more 'luaH_emptyobject' and comparisons of addresses of global variables
(instead, use a different kind of nil to signal the fake entry returned
when a key is not found in a table)
2018-06-01 13:51:34 -03:00
Roberto Ierusalimschy
03c6a05ec8 no more nil-in-table 2018-04-04 11:23:41 -03:00
Roberto Ierusalimschy
ef8263f81f better names for macros for tags and types.
rttype -> rawtt; ttyperaw -> withvariant; ttype -> ttypetag;
tnov -> ttype
2018-02-26 11:16:05 -03:00
Roberto Ierusalimschy
2952bc5fc9 special compact representation for userdata with no user values
(a common case)
2018-02-26 10:35:03 -03:00
Roberto Ierusalimschy
75efc6722b avoid variant tags with the same value of the original type
(to expose bugs more easily)
2018-02-25 09:52:32 -03:00
Roberto Ierusalimschy
d766e2ae17 first (parcial) implementation of 'keyin'/'removekey'
(still no metamethods, no raw verssions)
2018-02-25 09:48:16 -03:00
Roberto Ierusalimschy
9243c414d9 first version of empty entries in tables
(so that, in the future, tables can contain regular nil entries)
2018-02-23 10:16:18 -03:00
Roberto Ierusalimschy
477ca2fe8c some reorganization in 'lobject.h'
(just moving stuff around)
2018-02-22 14:28:10 -03:00
Roberto Ierusalimschy
c80c7a49fd details (comments) 2018-02-21 13:28:12 -03:00
Roberto Ierusalimschy
ca6fe7449a userdata can have multiple user values 2018-02-20 13:52:50 -03:00
Roberto Ierusalimschy
e2b15aa21d janitor work on casts 2018-01-28 13:13:26 -02:00
Roberto Ierusalimschy
6710a2b0ef detail (comment) 2018-01-28 10:07:53 -02:00
Roberto Ierusalimschy
599f1742c6 detail (typo in comments) 2017-11-23 17:29:04 -02:00
Roberto Ierusalimschy
ad0704e40c back to 'CallInfo' (no gains with its removal) 2017-11-07 11:25:26 -02:00
Roberto Ierusalimschy
5a3f26f855 fitting a StackValue structure into 32 bytes (for 64-bit machines) 2017-11-06 15:34:06 -02:00
Roberto Ierusalimschy
472c560705 no more useful fields in CallInfo 2017-11-03 15:22:54 -02:00
Roberto Ierusalimschy
54eb35a8aa more fields moved out of 'CallInfo' 2017-11-03 10:12:30 -02:00
Roberto Ierusalimschy
c5482468fd baby steps to remove 'CallInfo': keeping 'L->func' correct 2017-10-31 15:54:35 -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
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
73ec04fcf3 no more 'DEADKEY'. Table traversals do not need to consider dead keys;
if the key is dead, it cannot be given to 'next'. Instead, we now
use a 'table' tag without the collectable bit, which makes it
a unique tag good enough to reserve space.
2017-06-12 11:21:44 -03:00
Roberto Ierusalimschy
b6f87491af in hash nodes, keys are stored in separate pieces to avoid wasting
space with alignments
2017-06-09 13:48:44 -03:00
Roberto Ierusalimschy
4bb30f461b when assigning to a 'TValue', better assign only exact fields,
to allow us to put stuff after the 'TValuefields' if needed
2017-06-01 17:24:05 -03:00
Roberto Ierusalimschy
8634b2a011 added 'cachemiss' field to prototype to avoid wasting time checking
hits that fail too often
2017-04-30 17:43:26 -03: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
a3d36fe283 Upvalues collected like everything else (with mark-sweep) instead
of reference count (simpler and better for generational mode)
2017-04-11 15:41:09 -03:00