fix sharetable update and tail call (#1253)

Co-authored-by: zixun <lvzxiun@gmail.com>
This commit is contained in:
子熏
2020-10-23 14:42:31 +08:00
committed by GitHub
parent 6c3e969e91
commit 1e945a1dec

View File

@@ -265,7 +265,7 @@ local function resolve_replace(replace_map)
local f = match[tv] local f = match[tv]
if f then if f then
record_map[v] = true record_map[v] = true
f(v) return f(v)
end end
end end
@@ -277,7 +277,7 @@ local function resolve_replace(replace_map)
nv = getnv(mt) nv = getnv(mt)
debug.setmetatable(v, nv) debug.setmetatable(v, nv)
else else
match_value(mt) return match_value(mt)
end end
end end
end end
@@ -294,7 +294,7 @@ local function resolve_replace(replace_map)
for _,v in pairs(internal_types) do for _,v in pairs(internal_types) do
match_mt(v) match_mt(v)
end end
match_mt(nil) return match_mt(nil)
end end
@@ -331,7 +331,7 @@ local function resolve_replace(replace_map)
end end
end end
end end
match_mt(t) return match_mt(t)
end end
local function match_userdata(u) local function match_userdata(u)
@@ -341,7 +341,7 @@ local function resolve_replace(replace_map)
nv = getnv(uv) nv = getnv(uv)
setuservalue(u, nv) setuservalue(u, nv)
end end
match_mt(u) return match_mt(u)
end end
local function match_funcinfo(info) local function match_funcinfo(info)
@@ -381,7 +381,7 @@ local function resolve_replace(replace_map)
local function match_function(f) local function match_function(f)
local info = getinfo(f, "uf") local info = getinfo(f, "uf")
match_funcinfo(info) return match_funcinfo(info)
end end
local function match_thread(co, level) local function match_thread(co, level)
@@ -393,13 +393,14 @@ local function resolve_replace(replace_map)
match_value(v) match_value(v)
end end
local uplevel = co == coroutine.running() and 1 or 0
level = level or 1 level = level or 1
while true do while true do
local info = getinfo(co, level, "uf") local info = getinfo(co, level, "uf")
if not info then if not info then
break break
end end
info.level = level info.level = level + uplevel
info.curco = co info.curco = co
match_funcinfo(info) match_funcinfo(info)
level = level + 1 level = level + 1
@@ -412,6 +413,7 @@ local function resolve_replace(replace_map)
record_map[match] = true record_map[match] = true
record_map[RECORD] = true record_map[RECORD] = true
record_map[record_map] = true record_map[record_map] = true
record_map[replace_map] = true
record_map[insert_replace] = true record_map[insert_replace] = true
record_map[resolve_replace] = true record_map[resolve_replace] = true
assert(getinfo(co, 3, "f").func == sharetable.update) assert(getinfo(co, 3, "f").func == sharetable.update)
@@ -449,7 +451,7 @@ function sharetable.update(...)
end end
if next(replace_map) then if next(replace_map) then
resolve_replace(replace_map) resolve_replace(replace_map)
end end
end end