[Tarantool-patches] [PATCH luajit v3 08/29] test: adapt PUC-Rio tests counting GC steps

Sergey Kaplun skaplun at tarantool.org
Tue Apr 13 16:27:08 MSK 2021


JIT compilation can unpredictably allocate or reference objects (or
traces itself). So, the amount of GC steps can vary from run to run.

This patch disables JIT machinery, if it is enabled, for stable GC
results.

Part of tarantool/tarantool#5845
Part of tarantool/tarantool#4473
---
 test/PUC-Rio-Lua-5.1-tests/gc.lua | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/test/PUC-Rio-Lua-5.1-tests/gc.lua b/test/PUC-Rio-Lua-5.1-tests/gc.lua
index 86a9f758..b6925b69 100644
--- a/test/PUC-Rio-Lua-5.1-tests/gc.lua
+++ b/test/PUC-Rio-Lua-5.1-tests/gc.lua
@@ -108,11 +108,21 @@ local function dosteps (siz)
   return i
 end
 
+-- LuaJIT: JIT compilation can unpredictably allocate or reference
+-- objects (or traces itself). Disable it if necessary for
+-- this chunk for stable GC results.
+local jit_is_enabled = jit.status()
+if jit_is_enabled then
+  jit.off()
+end
 assert(dosteps(0) > 10)
 assert(dosteps(6) < dosteps(2))
 assert(dosteps(10000) == 1)
 assert(collectgarbage("step", 1000000) == true)
 assert(collectgarbage("step", 1000000))
+if jit_is_enabled then
+  jit.on()
+end
 
 
 do
-- 
2.31.0



More information about the Tarantool-patches mailing list