aboutsummaryrefslogtreecommitdiff
path: root/testes/gengc.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-12-22 14:57:43 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-12-22 14:57:43 -0300
commite81f586001d767c8de9b760ae2e2c3b5da1542c6 (patch)
tree26032fb57c824d62a4c1547159d58f5d5c223e96 /testes/gengc.lua
parente2cc179454c6aa6cde5f98954bd3783e0d5d53a3 (diff)
downloadlua-e81f586001d767c8de9b760ae2e2c3b5da1542c6.tar.gz
lua-e81f586001d767c8de9b760ae2e2c3b5da1542c6.tar.bz2
lua-e81f586001d767c8de9b760ae2e2c3b5da1542c6.zip
Removed compatibility option LUA_COMPAT_GCPARAMS
The meaning of different GC parameters changed, so there is point in supporting old values for them. The new code simply ignores the parameters when changing the GC mode, so the incompatibility is small.
Diffstat (limited to 'testes/gengc.lua')
-rw-r--r--testes/gengc.lua30
1 files changed, 15 insertions, 15 deletions
diff --git a/testes/gengc.lua b/testes/gengc.lua
index cae07285..51872cc1 100644
--- a/testes/gengc.lua
+++ b/testes/gengc.lua
@@ -24,12 +24,12 @@ do
24 assert(not T or (T.gcage(U) == "touched1" and T.gcage(U[1]) == "new")) 24 assert(not T or (T.gcage(U) == "touched1" and T.gcage(U[1]) == "new"))
25 25
26 -- both U and the table survive one more collection 26 -- both U and the table survive one more collection
27 collectgarbage("step", 0) 27 collectgarbage("step")
28 assert(not T or (T.gcage(U) == "touched2" and T.gcage(U[1]) == "survival")) 28 assert(not T or (T.gcage(U) == "touched2" and T.gcage(U[1]) == "survival"))
29 29
30 -- both U and the table survive yet another collection 30 -- both U and the table survive yet another collection
31 -- now everything is old 31 -- now everything is old
32 collectgarbage("step", 0) 32 collectgarbage("step")
33 assert(not T or (T.gcage(U) == "old" and T.gcage(U[1]) == "old1")) 33 assert(not T or (T.gcage(U) == "old" and T.gcage(U[1]) == "old1"))
34 34
35 -- data was not corrupted 35 -- data was not corrupted
@@ -46,10 +46,10 @@ do
46 assert(not T or T.gcage(old) == "old") 46 assert(not T or T.gcage(old) == "old")
47 setmetatable(old, {}) -- new table becomes OLD0 (barrier) 47 setmetatable(old, {}) -- new table becomes OLD0 (barrier)
48 assert(not T or T.gcage(getmetatable(old)) == "old0") 48 assert(not T or T.gcage(getmetatable(old)) == "old0")
49 collectgarbage("step", 0) -- new table becomes OLD1 and firstold1 49 collectgarbage("step") -- new table becomes OLD1 and firstold1
50 assert(not T or T.gcage(getmetatable(old)) == "old1") 50 assert(not T or T.gcage(getmetatable(old)) == "old1")
51 setmetatable(getmetatable(old), {__gc = foo}) -- get it out of allgc list 51 setmetatable(getmetatable(old), {__gc = foo}) -- get it out of allgc list
52 collectgarbage("step", 0) -- should not seg. fault 52 collectgarbage("step") -- should not seg. fault
53end 53end
54 54
55 55
@@ -65,18 +65,18 @@ do -- bug in 5.4.0
65 A[1] = obj -- anchor object 65 A[1] = obj -- anchor object
66 assert(not T or T.gcage(obj) == "old1") 66 assert(not T or T.gcage(obj) == "old1")
67 obj = nil -- remove it from the stack 67 obj = nil -- remove it from the stack
68 collectgarbage("step", 0) -- do a young collection 68 collectgarbage("step") -- do a young collection
69 print(getmetatable(A[1]).x) -- metatable was collected 69 print(getmetatable(A[1]).x) -- metatable was collected
70 end 70 end
71 71
72 collectgarbage() -- make A old 72 collectgarbage() -- make A old
73 local obj = {} -- create a new object 73 local obj = {} -- create a new object
74 collectgarbage("step", 0) -- make it a survival 74 collectgarbage("step") -- make it a survival
75 assert(not T or T.gcage(obj) == "survival") 75 assert(not T or T.gcage(obj) == "survival")
76 setmetatable(obj, {__gc = gcf, x = "+"}) -- create its metatable 76 setmetatable(obj, {__gc = gcf, x = "+"}) -- create its metatable
77 assert(not T or T.gcage(getmetatable(obj)) == "new") 77 assert(not T or T.gcage(getmetatable(obj)) == "new")
78 obj = nil -- clear object 78 obj = nil -- clear object
79 collectgarbage("step", 0) -- will call obj's finalizer 79 collectgarbage("step") -- will call obj's finalizer
80end 80end
81 81
82 82
@@ -94,13 +94,13 @@ do -- another bug in 5.4.0
94 end 94 end
95 ) 95 )
96 local _, f = coroutine.resume(co) -- create closure over 'x' in coroutine 96 local _, f = coroutine.resume(co) -- create closure over 'x' in coroutine
97 collectgarbage("step", 0) -- make upvalue a survival 97 collectgarbage("step") -- make upvalue a survival
98 old[1] = {"hello"} -- 'old' go to grayagain as 'touched1' 98 old[1] = {"hello"} -- 'old' go to grayagain as 'touched1'
99 coroutine.resume(co, {123}) -- its value will be new 99 coroutine.resume(co, {123}) -- its value will be new
100 co = nil 100 co = nil
101 collectgarbage("step", 0) -- hit the barrier 101 collectgarbage("step") -- hit the barrier
102 assert(f() == 123 and old[1][1] == "hello") 102 assert(f() == 123 and old[1][1] == "hello")
103 collectgarbage("step", 0) -- run the collector once more 103 collectgarbage("step") -- run the collector once more
104 -- make sure old[1] was not collected 104 -- make sure old[1] was not collected
105 assert(f() == 123 and old[1][1] == "hello") 105 assert(f() == 123 and old[1][1] == "hello")
106end 106end
@@ -112,12 +112,12 @@ do -- bug introduced in commit 9cf3299fa
112 assert(not T or T.gcage(t) == "old") 112 assert(not T or T.gcage(t) == "old")
113 t[1] = {10} 113 t[1] = {10}
114 assert(not T or (T.gcage(t) == "touched1" and T.gccolor(t) == "gray")) 114 assert(not T or (T.gcage(t) == "touched1" and T.gccolor(t) == "gray"))
115 collectgarbage("step", 0) -- minor collection 115 collectgarbage("step") -- minor collection
116 assert(not T or (T.gcage(t) == "touched2" and T.gccolor(t) == "black")) 116 assert(not T or (T.gcage(t) == "touched2" and T.gccolor(t) == "black"))
117 collectgarbage("step", 0) -- minor collection 117 collectgarbage("step") -- minor collection
118 assert(not T or T.gcage(t) == "old") -- t should be black, but it was gray 118 assert(not T or T.gcage(t) == "old") -- t should be black, but it was gray
119 t[1] = {10} -- no barrier here, so t was still old 119 t[1] = {10} -- no barrier here, so t was still old
120 collectgarbage("step", 0) -- minor collection 120 collectgarbage("step") -- minor collection
121 -- t, being old, is ignored by the collection, so it is not cleared 121 -- t, being old, is ignored by the collection, so it is not cleared
122 assert(t[1] == nil) -- fails with the bug 122 assert(t[1] == nil) -- fails with the bug
123end 123end
@@ -144,13 +144,13 @@ do
144 T.gcage(debug.getuservalue(U)) == "new") 144 T.gcage(debug.getuservalue(U)) == "new")
145 145
146 -- both U and the table survive one more collection 146 -- both U and the table survive one more collection
147 collectgarbage("step", 0) 147 collectgarbage("step")
148 assert(T.gcage(U) == "touched2" and 148 assert(T.gcage(U) == "touched2" and
149 T.gcage(debug.getuservalue(U)) == "survival") 149 T.gcage(debug.getuservalue(U)) == "survival")
150 150
151 -- both U and the table survive yet another collection 151 -- both U and the table survive yet another collection
152 -- now everything is old 152 -- now everything is old
153 collectgarbage("step", 0) 153 collectgarbage("step")
154 assert(T.gcage(U) == "old" and 154 assert(T.gcage(U) == "old" and
155 T.gcage(debug.getuservalue(U)) == "old1") 155 T.gcage(debug.getuservalue(U)) == "old1")
156 156