Commit Graph

524 Commits

Author SHA1 Message Date
Roberto Ierusalimschy
86a8e74824 Details 2024-03-28 17:11:33 -03:00
Roberto Ierusalimschy
ba71060381 Removed "bulk operations"
Negligible performance gains don't justify extra complexity.
2024-03-15 11:23:35 -03:00
Roberto Ierusalimschy
3823fc6c81 Added "bulk operations" to arrays
A few operations on arrays can be performed "in bulk", treating all
tags of a cell as a simple (or a few) word(s).
2024-03-15 11:01:34 -03:00
Roberto Ierusalimschy
8eb0abc9db Removed uses of LUA_NUMTAGS
That constant was already deprecated (see commit 6aabf4b15e).
2024-01-13 18:10:50 -03:00
Roberto Ierusalimschy
7827c40c49 A few more tweaks in the garbage collector 2024-01-10 14:45:58 -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
ad73b33224 Check minor->major made at the end of a minor cycle
It does not make sense to wait for another cycle to decide when much of
the information about creation of old objects is already available.
2023-12-07 15:45:41 -03:00
Roberto Ierusalimschy
925fe8a0f2 First criteria for shifts minor<->major 2023-12-07 15:45:11 -03:00
Roberto Ierusalimschy
789e7acdea Major collections done incrementally
Major collections do not need to "stop the world". Still pending:
criteria for shifts minor-major, shifts generational-incremental.
2023-12-06 10:49:56 -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
024f9064f1 External strings
Strings can use external buffers to store their contents.
2023-11-09 17:05:42 -03:00
Roberto Ierusalimschy
7f4906f565 Towards external strings
Long strings have a pointer to string contents.
2023-11-08 13:24:38 -03:00
Roberto Ierusalimschy
37c215b43f Merge branch 'newarray' into nextversion 2023-11-07 17:26:15 -03:00
Roberto Ierusalimschy
fa075b7953 Merge branch 'master' into newarray 2023-11-03 15:39:14 -03:00
Roberto Ierusalimschy
08a077d673 Full implementation of new representation for arrays 2023-11-03 15:26:13 -03:00
Roberto Ierusalimschy
43c8e5bded Full abstraction for representation of array values 2023-10-30 14:25:59 -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
6b51133a98 Thread stacks resized in the atomic phase
Although stack resize can be a little expensive, it seems unusual to
have too many threads needing resize during one GC cycle. On the other
hand, the change allows full collections to skip the propagate phase,
going straight from a pause to the atomic phase.
2023-07-13 14:55:46 -03:00
Roberto Ierusalimschy
9be74ccc21 Several functions turned 'static'
Several functions that were already being used only inside their
own file have been declared as 'static'.
2023-05-22 14:47:54 -03:00
Roberto Ierusalimschy
8dea54877a Do not avoid major collections when GCdebt is zero
'collectgarbage("step")' (without an argument) does not have any
special meaning, it means "do a step with some default size".
2022-12-29 15:41:07 -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
ff106c028c Merge branch 'master' into nextversion 2022-12-12 14:08:55 -03:00
Roberto Ierusalimschy
fa2f294dd1 Reduce calls to 'luaC_step' when GC is stopped 2022-12-09 16:35:19 -03:00
Roberto Ierusalimschy
0270c204c2 Simplification in handling of GC debt
Each incremental step has always the same size (stepsize), and the
debt for next step also is always the same.
2022-12-06 12:02:34 -03:00
Roberto Ierusalimschy
d324a0ccf9 Simpler control for major collections 2022-11-29 10:37:08 -03:00
Roberto Ierusalimschy
152b51955a Removed GC checks from function calls
Function calls do not create new objects. (It may use memory with
stack reallocation, but now that is irrelevant to the GC.)
2022-11-24 10:20:15 -03:00
Roberto Ierusalimschy
ec61be9a7e 'l_mem' renamed to 'l_obj' to count objects 2022-11-23 17:29:03 -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
76953316d1 Added a counter of the total number of existing objects
It may simplify the control of the garbage collector.
2022-11-03 16:37:13 -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
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
a1f77a234a Bug: set correct pause when (re)entering gen. collection. 2022-08-23 16:06:23 -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
066e0f93c4 Fix debug information about finalizers
The flag CIST_FIN does not mark a finalizer, but the function that was
running when the finalizer was called. (So, the function did not call
the finalizer, but it looks that way in the stack.)
2021-12-14 12:50:05 -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
1537d6680b New control for reentrancy of emergency collections
Instead of assuming that shrinking a block may be an emergency
collection, use an explicit field ('gcstopem') to stop emergency
collections while GC is working.
2021-02-26 11:41:02 -03:00
Roberto Ierusalimschy
59c88f846d Broadening the use of branch hints
More uses of macros 'likely'/'unlikely' (renamed to
'l_likely'/'l_unlikely'), both in range (extended to the
libraries) and in scope (extended to hooks, stack growth).
2021-02-24 11:14:44 -03:00
Roberto Ierusalimschy
d282652561 Bug when growing a stack
When a stack grows, its extra area can be in use, and it becomes part
of the common area. So, the extra area must be kept correct all the
times. (Bug introduced by commit 5aa36e894f5.)
2020-11-08 11:52:26 -03:00
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
c23cc86c54 Details
- After converting a generic GCObject to a specific type ('gco2*'),
  avoid using the original GCObject (to reduce aliasing).
- Small corrections in comments in 'lopcodes.h'
- Added tests about who calls __close metamethods
2020-10-12 12:29:09 -03:00
Roberto Ierusalimschy
5aa36e894f No more field 'lua_State.stacksize'
The stack size is derived from 'stack_last', when needed. Moreover,
the handling of stack sizes is more consistent, always excluding the
extra space except when allocating/deallocating the array.
2020-10-12 12:29:09 -03:00
Roberto Ierusalimschy
8a89da07ba Better control of gray objects
Avoid turning an object to gray except at the moment it is inserted in a
gray list or in the explicit exceptional cases such as open upvalues and
fixed strings.
2020-08-17 15:38:51 -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
f7ce7e5faa TOUCHED2 objects are not always black
This commit fixes a bug introduced in commit 9cf3299fa. TOUCHED2
objects are always black while the mutator runs, but they can become
temporarily gray inside a minor collection (e.g., if the object is a
weak table).
2020-08-13 14:31:27 -03:00
Roberto Ierusalimschy
65141832d2 Open upvalues should be gray when entering gen. mode
Open upvalues are never black; so, when entering generational mode,
they must be colored gray, not black.
2020-08-07 14:53:38 -03:00