aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-07-29 17:05:47 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-07-29 17:05:47 -0300
commit0dc5deca1c0182a4a3db2fcfd7bc721f27fb352b (patch)
treeb7af445c2b08aa760b3315c6083c4bb30387f2ee /testes
parentb4c353434f28f3e9d4c45e61d42b4fd07d76cad2 (diff)
downloadlua-0dc5deca1c0182a4a3db2fcfd7bc721f27fb352b.tar.gz
lua-0dc5deca1c0182a4a3db2fcfd7bc721f27fb352b.tar.bz2
lua-0dc5deca1c0182a4a3db2fcfd7bc721f27fb352b.zip
Optimization in 'markold'
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.
Diffstat (limited to 'testes')
-rw-r--r--testes/gengc.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/testes/gengc.lua b/testes/gengc.lua
index 7a7dabdd..93b5afd7 100644
--- a/testes/gengc.lua
+++ b/testes/gengc.lua
@@ -37,6 +37,22 @@ do
37end 37end
38 38
39 39
40do
41 -- ensure that 'firstold1' is corrected when object is removed from
42 -- the 'allgc' list
43 local function foo () end
44 local old = {10}
45 collectgarbage() -- make 'old' old
46 assert(not T or T.gcage(old) == "old")
47 setmetatable(old, {}) -- new table becomes OLD0 (barrier)
48 assert(not T or T.gcage(getmetatable(old)) == "old0")
49 collectgarbage("step", 0) -- new table becomes OLD1 and firstold1
50 assert(not T or T.gcage(getmetatable(old)) == "old1")
51 setmetatable(getmetatable(old), {__gc = foo}) -- get it out of allgc list
52 collectgarbage("step", 0) -- should not seg. fault
53end
54
55
40do -- bug in 5.4.0 56do -- bug in 5.4.0
41-- When an object aged OLD1 is finalized, it is moved from the list 57-- When an object aged OLD1 is finalized, it is moved from the list
42-- 'finobj' to the *beginning* of the list 'allgc', but that part of the 58-- 'finobj' to the *beginning* of the list 'allgc', but that part of the