Commit Graph

472 Commits

Author SHA1 Message Date
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
a006514ea1 Big revamp in the implmentation of labels/gotos
Added restriction that, when a label is created, there cannot be
another label with the same name visible. That allows backward goto's
to be resolved when they are read. Backward goto's get a close if
they jump out of the scope of some variable; labels get a close only
if previous goto to it jumps out of the scope of some upvalue.
2018-10-29 14:26:48 -03:00
Roberto Ierusalimschy
34840301b5 To-be-closed variables in the C API 2018-10-25 15:30:15 -03:00
Roberto Ierusalimschy
bd96330d03 First "complete" implementation of to-be-closed variables
Still missing:
- handling of memory errors when creating upvalue (must run closing
method all the same)
- interaction with coroutines
2018-10-17 10:44:42 -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
4d5de1c1fb Fixed bug in line info. when using 'not' operator
When creating code for a jump on a 'not' condition, the code generator
was removing an instruction (the OP_NOT) without adjusting its
corresponding line information.

This fix also added tests for this case and extra functionality in
the test library to debug line info. structures.
2018-07-11 12:53:23 -03:00
Roberto Ierusalimschy
b08c9079c5 Opcode names moved to a new header file
The array with the names of the opcodes was moved to a header file
('lopnames.h'), as it is not used by the Lua kernel. Files that need
that array ('luac.c' and 'ltests.c') include the header file to get
a private (static) copy.
2018-07-09 12:50:51 -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
992b6d2712 no more 'TESTGRAYBIT' (to free this bit for real uses) 2018-06-11 11:19:50 -03:00
Roberto Ierusalimschy
9e3db70482 details (casts between 'lua_Number' and 'double') 2018-03-09 16:24:45 -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
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
33e3774f44 keep more opcode arguments byte-aligned 2018-01-09 09:24:12 -02:00
Roberto Ierusalimschy
c6fedc92f8 new command 'print' (to print literal strings) in mini-language 2017-12-29 13:59:37 -02:00
Roberto Ierusalimschy
f8c1c1469a some cleaning on signed opcode parameters 2017-12-15 16:53:48 -02:00
Roberto Ierusalimschy
3cf340f676 allows memory-allocation errors when shrinking blocks 2017-12-11 16:55:31 -02:00
Roberto Ierusalimschy
40f823ec90 new C instruction "rawcheckstack" (to test failing in 'lua_checkstack') 2017-12-08 13:19:13 -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
39f26b1480 more information from 'T.stacklevel' 2017-11-23 13:38:42 -02:00
Roberto Ierusalimschy
7c0175bc83 removed unused variable 'islocked' 2017-11-09 11:31:29 -02:00
Roberto Ierusalimschy
c3e5946fb2 new format for JUMP instructions (to allow larger offsets) 2017-11-07 15:20:42 -02:00
Roberto Ierusalimschy
ad0704e40c back to 'CallInfo' (no gains with its removal) 2017-11-07 11:25:26 -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
ba36180fd7 new API for 'lua_resume' + cleaning the uses of the 'extra' field in
'CallInfo'
2017-11-02 09:28:56 -02:00
Roberto Ierusalimschy
b9e76be8a6 using 'L->func' when possible 2017-11-01 16:20:48 -02:00
Roberto Ierusalimschy
a1ef58b3a5 eplicit 1-bit opcode operand 'k' 2017-10-04 18:56:32 -03:00
Roberto Ierusalimschy
7f9a32ad85 new function 'printcode' 2017-10-01 16:17:51 -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
5a1c8d8ef3 new constant 'LUA_GNAME' for the name of the global table "_G" 2017-06-27 15:32:49 -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
8821746841 updated GC states in function 'T.gcstate' 2017-05-31 15:54:58 -03:00
Roberto Ierusalimschy
2376eb6347 barrier for prototype's cache (with new gray list 'protogray' to keep
prototypes to have their caches visited again) + constant 'MAXMISS'
2017-05-04 10:32:01 -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
69371c4b84 'KGC_NORMAL' -> 'KGC_INC' + emergency GC signalled by flag (instead
of mode)
2017-04-24 13:59:26 -03:00
Roberto Ierusalimschy
7ae180f8e8 corrected some checks about colors of old objects + new test function
'gcage'
2017-04-19 15:46:47 -03:00
Roberto Ierusalimschy
4679294796 memory check adapted to generational mode 2017-04-18 16:42:12 -03:00
Roberto Ierusalimschy
f5f3df3bd1 generational collection: new attempt (still incomplete) 2017-02-23 18:07:34 -03:00
Roberto Ierusalimschy
b2aa2ba046 using constants for "_LOADED" and "PRELOAD" 2016-12-04 18:17:24 -02:00
Roberto Ierusalimschy
7b1fba69b7 using 'lastfree == NULL' to signal that table is using the dummy
node for its hash part + new macro 'allocsizenode'
2016-11-07 10:38:35 -02:00
Roberto Ierusalimschy
880f82d089 '*' as a number means stack size, so that "return *" returns
all values in the stack.
2015-10-12 13:38:19 -03:00
Roberto Ierusalimschy
53be1451a8 new definition for macro 'checkliveness' 2015-09-08 13:55:43 -03:00
Roberto Ierusalimschy
2de3361c6c detail 2015-07-01 14:47:12 -03:00
Roberto Ierusalimschy
cbe05b48bb using 'lua_longassert' to avoid warnings 2015-06-18 11:25:26 -03:00
Roberto Ierusalimschy
4998e852ec new function 'log2' to test 'luaO_ceillog2' (if needed) 2015-04-02 18:10:21 -03:00
Roberto Ierusalimschy
331632e8d8 code detail ('if' -> '?:') 2015-03-13 13:24:50 -03:00
Roberto Ierusalimschy
0cf3b6495a 'ci_func' don't need to be exported 2015-03-11 13:10:41 -03:00
Roberto Ierusalimschy
7e2015a46d size of short strings stored in a single byte, to reduce the size
of struct 'TString'
2015-01-16 14:54:37 -02:00
Roberto Ierusalimschy
77e786d436 stupid bug in T.stacklevel (not in use by the tests) 2014-12-18 10:13:42 -02:00
Roberto Ierusalimschy
741ad97e92 new parameter for testC instruction 'pcall' (error handler) 2014-12-10 09:30:51 -02:00
Roberto Ierusalimschy
177807f21e casts ('(int)' -> 'cast_int') 2014-11-29 15:38:33 -02:00
Roberto Ierusalimschy
fd179ab4b8 clearer notation for "compare" instruction 2014-11-25 12:51:33 -02:00
Roberto Ierusalimschy
5bdfefd3a5 allows calling luaL_checkstack with no message (in runC) 2014-11-14 16:15:17 -02:00
Roberto Ierusalimschy
6624ccff26 independent code for 'printstack' + test for panic function can
ran code there
2014-11-11 15:15:06 -02:00
Roberto Ierusalimschy
79b0d05480 new function 'T.checkpanic' (to check panic errors) 2014-11-10 15:41:36 -02:00
Roberto Ierusalimschy
b6911c177d luaL_loadbuffer replaced by luaL_loadstring (to test luaL_loadstring)
+ 'rawgetp'/'rawsetp' added to C interpreter
2014-11-10 12:47:29 -02:00
Roberto Ierusalimschy
a113e1498d when checking thread consistency, check its entire stack (always
the entire stack must have valid values)
2014-11-07 16:07:17 -02:00
Roberto Ierusalimschy
28fdbcf393 added include for 'lprefix.h', for stuff that must be added before
any other header file
2014-11-02 17:19:04 -02:00
Roberto Ierusalimschy
4542fb9f78 comments (a few extra quotes around identifiers) 2014-10-30 16:53:28 -02:00
Roberto Ierusalimschy
7314acaa80 'T.limits' reports some more useful limits 2014-10-27 15:00:02 -02:00
Roberto Ierusalimschy
bdf566a8a3 `name' in comments changed to 'name' 2014-10-25 09:50:46 -02:00
Roberto Ierusalimschy
2a21f6c894 'lua_Kcontext' -> 'lua_KContext' 2014-10-07 15:29:13 -03:00
Roberto Ierusalimschy
e14a02c24f when thread yields, real "func" is in field 'extra', not in 'func' 2014-10-06 14:06:49 -03:00
Roberto Ierusalimschy
798660c9cd deprecated "cast macros" ('luaL_checkint', 'luaL_optint', etc.) 2014-10-01 08:54:56 -03:00
Roberto Ierusalimschy
3a15c7ce43 size for array part of a table ('sizearray') changed from 'int' to
'unsigned int', which allows twice as many elements in the array part
2014-09-04 15:15:29 -03:00
Roberto Ierusalimschy
22952d8973 'T.gccolor' classify dead objects too 2014-09-01 14:58:55 -03:00
Roberto Ierusalimschy
2be88d5084 'lua_Ctx' -> 'lua_Kcontext' 2014-08-01 14:33:08 -03:00
Roberto Ierusalimschy
73ad16b5c6 no need for type 'pCallInfo' 2014-07-23 13:44:30 -03:00
Roberto Ierusalimschy
3c6d0aaa7d 'iswhite' and related macros now can work directly on any object
(no need to convert to 'GCObject')
2014-07-19 12:14:46 -03:00
Roberto Ierusalimschy
bb12903120 type 'Udata' refers directly to structure inside the union (union
used only for aligning purposes now)
2014-07-18 11:46:47 -03:00
Roberto Ierusalimschy
ca41b43f53 type 'TString' refers directly to the structure inside the union
(union used only for size purposes)
2014-07-18 10:36:14 -03:00
Roberto Ierusalimschy
56137d58ff added check for conversion 'obj2gco' (and corrections for small
problems detected by this check)
2014-07-18 09:17:54 -03:00
Roberto Ierusalimschy
9aec500a26 no need for field 'gch' anymore 2014-07-17 14:27:49 -03:00
Roberto Ierusalimschy
1aa4f69b51 new type 'lua_Ctx' for continuation-function contexts (to allow type
to be configurable)
2014-07-17 10:53:37 -03:00
Roberto Ierusalimschy
c229ed597f 'requiref' checks 'package.loaded' before loading a module 2014-07-16 11:51:36 -03:00
Roberto Ierusalimschy
a77d263e86 unsigned-manipulation functions (lua_puhsunsigned, lua_tounsigned, etc.)
deprecated
2014-06-26 15:38:28 -03:00
Roberto Ierusalimschy
d2ab1aef31 detail (avoid too large macro) 2014-06-19 15:29:30 -03:00
Roberto Ierusalimschy
3fc25ff15b macro 'checkobjref' accepts NULL (as all its uses checked for NULL
before) + user value from a userdata may not be a GC object
2014-06-17 14:13:29 -03:00
Roberto Ierusalimschy
6f6fd96e3b new type lua_KFunction + no more 'lua_getctx' 2014-06-10 14:41:38 -03:00
Roberto Ierusalimschy
5a5a834975 new API function 'lua_rotate' 2014-05-13 16:40:28 -03:00
Roberto Ierusalimschy
a09bd59615 'T.totalmem' accepts 0 for unlimited memory 2014-05-08 16:08:46 -03:00
Roberto Ierusalimschy
5c46b7b8cf instructions in 'runC' sorted alphabetically + new instructions
'tointeger'/'tounsigned'
2014-04-14 15:42:44 -03:00
Roberto Ierusalimschy
c86b9da022 userdata can have any Lua value as uservalue 2014-02-19 10:52:42 -03:00
Roberto Ierusalimschy
3f78de256e no need to keep threads in a different GC list, now that there is the
'twups' list
2014-02-18 10:46:26 -03:00
Roberto Ierusalimschy
ffa96d988d field 'op' renamed to 'open' 2014-02-15 11:12:01 -02:00
Roberto Ierusalimschy
733c58595b no more local collection 2014-02-13 10:11:34 -02:00
Roberto Ierusalimschy
ba3586cc90 keep a single list of objects to be finalized (with local and non-local
objects), to ensure finalization order
2014-02-11 10:18:12 -02:00
Roberto Ierusalimschy
1ea2d20f74 first implementation of '<<', '>>', and '~' (bitwise not) 2013-12-30 18:47:58 -02:00
Roberto Ierusalimschy
c0edab0f6d first implementation of bitwise operators '&' (band), '|' (bor),
and '~' (bxor)
2013-12-18 12:12:03 -02:00
Roberto Ierusalimschy
a948054a19 new order for binary operations (grouping them by type of result) 2013-12-16 17:06:52 -02:00
Roberto Ierusalimschy
4eeb1831be new names and better order for GC states (sweep first lists that
can have dead objects)
2013-09-11 11:47:08 -03:00
Roberto Ierusalimschy
dd373a8f66 threads are kept in a separated GC list, linked after the main thread 2013-09-11 11:09:55 -03:00
Roberto Ierusalimschy
d8aa8dd97e objects in list 'tobefnz' have a GC life-cycle like all others
(specifically they are cleaned during sweep phase)
2013-09-11 09:47:48 -03:00
Roberto Ierusalimschy
79ab21be90 more invariants added to memory check 2013-09-11 09:26:14 -03:00
Roberto Ierusalimschy
d3bbb34c24 back to open hashing for the string table (but with a different
'hnext' field, to strings are still collected like all other
objects)
2013-09-05 16:31:49 -03:00
Roberto Ierusalimschy
0ad15fc100 better (and correct!) control of 'maybedead' 2013-09-04 12:34:24 -03:00