[Tarantool-patches] [PATCH v2 luajit 08/30] test: disable JIT for GC step counting tests

Sergey Kaplun skaplun at tarantool.org
Fri Mar 26 10:42:51 MSK 2021


JIT compilation can unpredictable 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-Lua-5.1-tests/gc.lua | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/test/PUC-Lua-5.1-tests/gc.lua b/test/PUC-Lua-5.1-tests/gc.lua
index 86a9f75..072bbe9 100644
--- a/test/PUC-Lua-5.1-tests/gc.lua
+++ b/test/PUC-Lua-5.1-tests/gc.lua
@@ -108,11 +108,21 @@ local function dosteps (siz)
   return i
 end
 
+-- LuaJIT: JIT compilation can unpredictable 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