Antonio Nikishaev
2014-09-17 16:02:22 UTC
Help me to understand causes for how things work.
luajit v2.1 HEAD
-----------------------------------------
local function qux (state)
state.x = 1
state.y = state.x
end
local function main1 () -- gc
local state = {}
qux (state)
end
local function main2 () -- no gc
local state = { x=0 }
qux (state)
end
local function main3 () -- gc
local state = { }
state.x = 0
qux (state)
end
local function main4 () -- gc
local state = { x=0, z={} }
qux (state)
end
local function quux (state)
state.z = {}
end
local function main5 () -- gc
local state = {}
quux (state)
end
for i = 1, 1e7 do
main1()
end
----------------------------------------- code end
1) Are there any particular reasons for this behaviour I don't see?
2) I'm very interested in the main5 case. Any way to do it gc-free?
luajit v2.1 HEAD
-----------------------------------------
local function qux (state)
state.x = 1
state.y = state.x
end
local function main1 () -- gc
local state = {}
qux (state)
end
local function main2 () -- no gc
local state = { x=0 }
qux (state)
end
local function main3 () -- gc
local state = { }
state.x = 0
qux (state)
end
local function main4 () -- gc
local state = { x=0, z={} }
qux (state)
end
local function quux (state)
state.z = {}
end
local function main5 () -- gc
local state = {}
quux (state)
end
for i = 1, 1e7 do
main1()
end
----------------------------------------- code end
1) Are there any particular reasons for this behaviour I don't see?
2) I'm very interested in the main5 case. Any way to do it gc-free?
--
lelf
lelf