aboutsummaryrefslogtreecommitdiff
path: root/lgc.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Bug: set correct pause when (re)entering gen. collection.Roberto Ierusalimschy2022-08-231-32/+31
|
* Bug: finalizer calling exit can corrupt finalization orderRoberto Ierusalimschy2021-12-221-5/+5
| | | | | 'os.exit' can call lua_close again, separating new finalizers created after all previous finalizers were already separated.
* Fix debug information about finalizersRoberto Ierusalimschy2021-12-141-1/+1
| | | | | | 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.)
* Bug: GC is not reentrantRoberto Ierusalimschy2021-12-131-4/+7
| | | | As the GC is not reentrant, finalizers should not be able to invoke it.
* New control for reentrancy of emergency collectionsRoberto Ierusalimschy2021-02-261-12/+24
| | | | | | 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.
* Broadening the use of branch hintsRoberto Ierusalimschy2021-02-241-1/+1
| | | | | | 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).
* Bug when growing a stackRoberto Ierusalimschy2020-11-081-2/+2
| | | | | | 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.)
* Fixed bug of keys removed from tables vs 'next'Roberto Ierusalimschy2020-10-141-9/+8
| | | | | | 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.
* DetailsRoberto Ierusalimschy2020-10-121-11/+19
| | | | | | | - 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
* No more field 'lua_State.stacksize'Roberto Ierusalimschy2020-10-121-3/+2
| | | | | | 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.
* Better control of gray objectsRoberto Ierusalimschy2020-08-171-44/+50
| | | | | | 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.
* Small changes in macros that change GC colorsRoberto Ierusalimschy2020-08-131-27/+27
| | | | | | | | | | | | | - 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.)
* TOUCHED2 objects are not always blackRoberto Ierusalimschy2020-08-131-8/+2
| | | | | | | 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).
* Open upvalues should be gray when entering gen. modeRoberto Ierusalimschy2020-08-071-8/+13
| | | | | Open upvalues are never black; so, when entering generational mode, they must be colored gray, not black.
* Detail (in asserts)Roberto Ierusalimschy2020-08-031-4/+1
| | | | Macro 'checkconsistency' replaced by the similar 'checkliveness".
* Threads don't need to always go to 'grayagain'Roberto Ierusalimschy2020-08-031-18/+29
| | | | | | | In incremental mode, threads don't need to be visited again once visited in the atomic phase. In generational mode (where all visits are in the atomic phase), only old threads need to be kept in the 'grayagain' list for the next cycle.
* Clearer handling of gray lists when entering generational modeRoberto Ierusalimschy2020-08-031-6/+30
| | | | | | | | When entering generational mode, all objects are old. So, the only objects that need to be in a gray list are threads, which can be assigned without barriers. Changes in anything else (e.g., weak tables) will trigger barriers that, if needed, will add the object to a gray list.
* Optimization in 'markold'Roberto Ierusalimschy2020-07-291-17/+42
| | | | | | | | | | OLD1 objects can be potentially anywhere in the 'allgc' list (up to 'reallyold'), but frequently they are all after 'old1' (natural evolution of survivals) or do not exist at all (when all objects die young). So, instead of 'markold' starts looking for them always from the start of 'allgc', the collector keeps an extra pointer, 'firstold1', that points to the first OLD1 object in the 'allgc' list, or is NULL if there are no OLD1 objects in that list.
* DetailsRoberto Ierusalimschy2020-07-291-15/+15
| | | | | The fields 'old' and 'finobjold' were renamed 'old1' and 'finobjold1', respectively, to make clearer the main ages of their elements.
* OLD1 ages advanced by 'markold'Roberto Ierusalimschy2020-07-291-5/+6
| | | | | Objects aged OLD1 have their ages advanced by 'markold', which has to visit them anyway. So, the GC doesn't need to "sweep" the old1 list.
* Same changes around 'correctgraylist'Roberto Ierusalimschy2020-07-281-53/+66
| | | | | | | Instead of adding all tables and userdata back to the 'grayagain' list to be checked by 'correctgraylist', the collector adds only the objects that will remain in that list (objects aged TOUCHED1). This commit also rewrites 'correctgraylist' with a clearer logic.
* All objects are kept 'new' in incremental GCRoberto Ierusalimschy2020-07-271-17/+21
| | | | | | Small changes to ensure that all objects are kept 'new' in incremental GC (except for fixed strings, which are always old) and to make that fact clearer.
* Fixed bug: barriers cannot be active during sweepRoberto Ierusalimschy2020-07-271-16/+32
| | | | | | | Barriers cannot be active during sweep, even in generational mode. (Although gen. mode is not incremental, it can hit a barrier when deleting a thread and closing its upvalues.) The colors of objects are being changed during sweep and, therefore, cannot be trusted.
* Fixed bug of old finalized objects in the GCRoberto Ierusalimschy2020-07-101-6/+4
| | | | | | When an object aged OLD1 is finalized, it is moved from the list 'finobj' to the *beginning* of the list 'allgc'. So, this part of the list (and not only the survival list) must be visited by 'markold'.
* Added 'simplesect' sections to the manualRoberto Ierusalimschy2020-04-131-1/+1
| | | | | | | 'simplesect' encloses the introductory text of sections with subsections, so that each section either is all text or is all subsections. (This commit also corrects a small brace error in the manual and extra spaces/tabs in some other files.)
* Clearer distinction between types and tagsRoberto Ierusalimschy2020-01-311-29/+29
| | | | | LUA_T* represents only types; tags (types + Variants) are represented by LUA_V* constants.
* Details (mostly comments)Roberto Ierusalimschy2019-10-221-0/+1
|
* Fixed a warning and other minor issuesRoberto Ierusalimschy2019-10-041-1/+1
| | | | Fixed some minor issues from the feedback for 5.4-beta rc1.
* Supressed errors in '__close' generate warningsRoberto Ierusalimschy2019-08-161-6/+1
|
* Small optimization in 'convergeephemerons'Roberto Ierusalimschy2019-08-121-9/+20
| | | | | | When converging marks on ephemeron tables, change the direction the tables are traversed at each iteration, to try to avoid bad-case scenarios with linked lists of entries in a table.
* Do not collect open upvaluesRoberto Ierusalimschy2019-07-221-4/+2
| | | | | | | | Open upvalues are kept alive together with their corresponding stack. This change makes a simpler and safer fix to the issue in commit 440a5ee78c8, about upvalues in the list of open upvalues being collected while others are being created. (That previous fix may not be correct.)
* Tag LUA_TUPVALTBC replaced by a flagRoberto Ierusalimschy2019-07-191-4/+2
| | | | | It is simpler to signal a to-be-closed upvalue with a boolean flag, instead of using a different tag.
* Some details in 'lmem.c' and 'lgc.c'Roberto Ierusalimschy2019-07-191-3/+4
| | | | | | | | - Several new comments in 'lmem.c'. - Both 'luaM_growaux_' and 'luaM_shrinkvector_' use 'luaM_saferealloc_' to check for errors. Moreover, the use of 'luaM_saferealloc_' makes 'luaM_shrinkvector_' try again if shrink fails (which can happen now). - In 'checkSizes', save old debt only when needed.
* Details (typos in comments)Roberto Ierusalimschy2019-07-051-1/+1
|
* Fixed bug [5.4 alpha] for errors in finalizersRoberto Ierusalimschy2019-06-211-4/+4
| | | | | | | | Fixes the bug related in [1] (Lua can crash after raising an error in a finalizer), following the lead in [2]. [1] http://lua-users.org/lists/lua-l/2019-06/msg00448.html [2] http://lua-users.org/lists/lua-l/2019-06/msg00450.html
* DetailsRoberto Ierusalimschy2019-06-031-2/+2
| | | | | Several small changes from feedback on 5.4 alhpa rc1 (warnings, typos in the manual, and the like)
* Avoid moving the collector while in 'GCSenteratomic' stateRoberto Ierusalimschy2019-04-011-2/+2
| | | | | | The 'GCSenteratomic' is just an auxiliary state for transitioning to 'GCSatomic'. All GC traversals should be done either on the 'GCSpropagate' state or the 'GCSatomic' state.
* Finalizers must be callableRoberto Ierusalimschy2019-03-141-1/+1
| | | | | Non-function __gc metamethods are not ignored; if present, the metamethod will be called even if it is not a function.
* Changes in the warning systemRoberto Ierusalimschy2019-03-141-4/+4
| | | | | | | | - The warning functions get an extra parameter that tells whether message is to be continued (instead of using end-of-lines as a signal). - The user data for the warning function is a regular value, instead of a writable slot inside the Lua state.
* After a "bad collections", avoid switching back back to generationalRoberto Ierusalimschy2019-01-301-44/+114
| | | | | | | 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).
* No more LUA_ERRGCMM errorsRoberto Ierusalimschy2019-01-011-15/+13
| | | | | Errors in finalizers (__gc metamethods) are never propagated. Instead, they generate a warning.
* Removed internal cache for closuresRoberto Ierusalimschy2018-11-011-63/+1
| | | | | | | | | | | | | | | | | | | 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.)
* First "complete" implementation of to-be-closed variablesRoberto Ierusalimschy2018-10-171-0/+5
| | | | | | | Still missing: - handling of memory errors when creating upvalue (must run closing method all the same) - interaction with coroutines
* Towards "to closed" local variablesRoberto Ierusalimschy2018-10-081-1/+3
| | | | | | | | | | | | 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.
* Comments about OLD0/OLD1 agesRoberto Ierusalimschy2018-07-181-24/+30
| | | | | Improved the comments in file 'lgc.c' explaining the roles of "ages" OLD0 and OLD1 in the generacional collector.
* Fixed bug in generational collection of userdataRoberto Ierusalimschy2018-07-131-11/+15
| | | | | | | | | During generational collection, a userdatum must become gray and go to a gray list after being traversed (like tables), so that 'correctgraylist' can handle it to its next stage. This commit also added minimum tests for the generational collector, including one that would detect this bug.
* Generational mode may wait longer after a major collectionRoberto Ierusalimschy2018-07-091-8/+25
| | | | | | | | When Lua is building large long-duration structures, frequent small minor collections just waste time. Trying to avoid this, the collector will do a larger pause after a major collection when it does not collect enough garbage (which is a hint that memory is being used for long-lasting objects).
* field 'sizearray' in struct 'Table' changed to 'alimit', which canRoberto Ierusalimschy2018-06-151-6/+9
| | | | be used as a hint for '#t'
* FALLTHROUGH comment must be last "statement"Roberto Ierusalimschy2018-03-161-3/+3
| | | | (so it does not work when inside a block)
* special compact representation for userdata with no user valuesRoberto Ierusalimschy2018-02-261-3/+16
| | | | (a common case)