diff --git a/test/LuaJIT-tests/misc/wbarrier_obar.lua b/test/LuaJIT-tests/misc/wbarrier_obar.lua deleted file mode 100644 index 258db2158e..0000000000 --- a/test/LuaJIT-tests/misc/wbarrier_obar.lua +++ /dev/null @@ -1,22 +0,0 @@ --- DSE of USTORE must eliminate OBAR, too. - -if jit and jit.opt then pcall(jit.opt.start, "-sink") end - -local f -do - local x - f = function() - local y = 0 - for i=1,10000 do - x = {1} - if y > 0 then end - x = 1 - end - end -end - -collectgarbage() -collectgarbage("setstepmul", 1) -collectgarbage("restart") -f() - diff --git a/test/LuaJIT-tests/trace/wbarrier.lua b/test/LuaJIT-tests/trace/wbarrier.lua index 625c0ff2e6..9c9c50aff4 100644 --- a/test/LuaJIT-tests/trace/wbarrier.lua +++ b/test/LuaJIT-tests/trace/wbarrier.lua @@ -1,3 +1,12 @@ +local function jit_opt_is_on(needed) + for _, opt in ipairs({jit.status()}) do + if opt == needed then + return true + end + end + return false +end + do --- TBAR for HSTORE. local t = {[0]={}} for i = 1, 1e5 do t[i] = {t[i - 1]} end @@ -14,3 +23,35 @@ do --- OBAR for USTORE. end f() end + +do --- DSE of USTORE must eliminate OBAR too. + local need_restore_sink = false + if jit_opt_is_on("sink") then + need_restore_sink = true + jit.opt.start("-sink") + end + + local f + do + local x + f = function() + local y = 0 + for _ = 1, 10000 do + x = {1} + if y > 0 then end + x = 1 + end + end + end + + collectgarbage() + local oldstepmul = collectgarbage("setstepmul", 1) + collectgarbage("restart") + + f() + + collectgarbage("setstepmul", oldstepmul) + if need_restore_sink then + jit.opt.start("+sink") + end +end