Commit Graph

156 Commits

Author SHA1 Message Date
Roberto Ierusalimschy 262dc5729a Details
Corrections in comments and manual. Added note in the manual about
local variables in the REPL.
2024-05-08 17:50:10 -03:00
Roberto Ierusalimschy 7827c40c49 A few more tweaks in the garbage collector 2024-01-10 14:45:58 -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 e2cc179454 New option "setparms" for 'collectgarbage'
The generational mode also uses the parameters for the incremental
mode in its major collections, so it should be easy to change those
parameters without having to change the GC mode.
2023-12-22 14:48:07 -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 666e95a66d Option 0 for step multiplier makes GC non-incremental 2023-12-20 11:06:27 -03:00
Roberto Ierusalimschy 925fe8a0f2 First criteria for shifts minor<->major 2023-12-07 15:45:11 -03:00
Roberto Ierusalimschy 74b4013538 Removed macro 'changeage'
It is simpler to use always 'setage'. The saving from 'changeage'
is too irrelevant.
2023-12-01 16:42:01 -03:00
Roberto Ierusalimschy 63d68bd657 Comments detailing the ages for generational GC
Plus other comments and small details.
2023-11-29 16:22:09 -03:00
Roberto Ierusalimschy 3e6818ca87 Merge branch 'master' into nextversion 2022-12-15 14:23:59 -03:00
Roberto Ierusalimschy f874d37fa2 Small change in barrier macros
Reuse macros for objects when defining the macros for values.
2022-12-15 14:18:03 -03:00
Roberto Ierusalimschy 5d8b5b9290 Changed signal of GC debt
Positive debts seems more natural then negative ones.
2022-12-13 15:45:57 -03:00
Roberto Ierusalimschy 40565b4a08 Revamp of GC parameters
More uniformity when handling GC parameters + avoid divisions by 100
when applying them.
2022-12-13 11:55:14 -03:00
Roberto Ierusalimschy d324a0ccf9 Simpler control for major collections 2022-11-29 10:37:08 -03:00
Roberto Ierusalimschy f356d5acdd First version of GC counting objects for control
Still needs to review generational mode.
2022-11-23 17:17:20 -03:00
Roberto Ierusalimschy 9ede317c70 Threads are created like other objects
Using a version of 'luaC_newobj' that allows offsets (extra space
before the object itself).
2022-11-01 17:14:01 -03:00
Roberto Ierusalimschy 597a53bbc6 Bug: finalizer calling exit can corrupt finalization order
'os.exit' can call lua_close again, separating new finalizers
created after all previous finalizers were already separated.
2021-12-22 09:00:52 -03:00
Roberto Ierusalimschy 0bfc572e51 Bug: GC is not reentrant
As the GC is not reentrant, finalizers should not be able to invoke it.
2021-12-13 10:41:17 -03:00
Roberto Ierusalimschy f849885a4b Small changes in macros that change GC colors
- Macro 'gray2black' was renamed 'nw2black' (Non-White to black), as it
was already being used on objects that could be already black.

- Macros 'white2gray' and 'black2gray' were unified in 'set2gray'; no
reason to have two macros when one will do and, again, 'black2gray' was
already being used on objects that could be already gray.

Moreover, macros 'maskcolors' and 'maskgcbits' were negated to have
ones in the described bits, instead of zeros. (This naming seems more
intuitive.)
2020-08-13 15:23:21 -03:00
Roberto Ierusalimschy f13dc59416 Better tests for gray lists
Test uses an extra bit in 'marked' to mark all elements in gray lists
and then check against elements colored gray.
2020-08-07 14:45:20 -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 b14609032c Avoid the creation of too many strings in 'package'
Both when setting a path and searching for a file ('searchpath'),
this commit reduces the number of intermediate strings created
in Lua.
(For setting a path the change is not relevant, because this is
done only twice when loading the module. Anyway, it is a nice example
of how to use auxlib buffers to manipulate strings in the C API.)
2019-05-03 10:14:25 -03:00
Roberto Ierusalimschy 2c32bff609 After a "bad collections", avoid switching back back to generational
After a major bad collection (one that collects too few objects),
next collection will be major again. In that case, avoid switching
back to generational mode (as it will have to switch again to
incremental to do next major collection).
2019-01-30 11:44:42 -02: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 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 992b6d2712 no more 'TESTGRAYBIT' (to free this bit for real uses) 2018-06-11 11:19:50 -03:00
Roberto Ierusalimschy 1afd5a152d more generic way to handle 'gclist' 2018-02-19 17:06:56 -03:00
Roberto Ierusalimschy a131eae925 default for minor collection intervals a little larger 2018-02-05 15:14:29 -02:00
Roberto Ierusalimschy e2b15aa21d janitor work on casts 2018-01-28 13:13:26 -02:00
Roberto Ierusalimschy 1d8920dd7f some cleaning in GC parameters 2017-10-11 09:38:45 -03:00
Roberto Ierusalimschy 72d82a296c revamping the incremental collector
Some simplifications (not counting bytes, couting only slots visited;
no more 'gcfinnum'); more GC parameters; using vararg in 'lua_gc' to
set parameters in different GC modes
2017-05-26 16:14:29 -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 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
Roberto Ierusalimschy 9569ad6b0d Comments for generational collector 2017-04-10 10:33:04 -03:00
Roberto Ierusalimschy 2331e1beec small changes in 'luaC_upvalbarrier' 2017-04-06 10:08:56 -03:00
Roberto Ierusalimschy e4287da3a6 generational collector (still not complete) 2017-04-05 13:50:51 -03:00
Roberto Ierusalimschy f5f3df3bd1 generational collection: new attempt (still incomplete) 2017-02-23 18:07:34 -03:00
Roberto Ierusalimschy c0836dda74 avoid empty macro arguments (invalid in C89) 2015-12-21 11:02:14 -02:00
Roberto Ierusalimschy 3ad55386c4 'condchangemem' also may need to run 'pre'/'pos' 2015-10-21 16:15:15 -02:00
Roberto Ierusalimschy caf8278710 added comments 2015-10-20 16:00:19 -02:00
Roberto Ierusalimschy f7670781cf cleaner definition for 'luaC_condGC', using 'pre'/'pos' parameters 2015-10-20 15:56:21 -02:00
Roberto Ierusalimschy 20b9e59441 barrier macros rewritten as expressions 2015-08-03 16:40:42 -03:00
Roberto Ierusalimschy bdf566a8a3 `name' in comments changed to 'name' 2014-10-25 09:50:46 -02: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 e43612aaf6 put the restriction that 'luaC_barrierback' works only on tables
in its prototype
2014-07-19 12:09:37 -03:00
Roberto Ierusalimschy 9aec500a26 no need for field 'gch' anymore 2014-07-17 14:27:49 -03:00
Roberto Ierusalimschy ed795d5ff4 detail (removed unused prototype) 2014-03-19 15:51:16 -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 1cce3e6842 change in the way 'collectgarbage("step", size)' interprets 'size'
(mimicking the way the GC itself behaves when Lua allocates 'size'
Kbytes)
2014-02-14 14:43:14 -02:00
Roberto Ierusalimschy de3b1c9b53 better control for number of finalizers called at each GC cycle
(increases progressively)
2014-02-13 12:46:38 -02:00