Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests
@ 2024-08-14 13:55 Sergey Kaplun via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 01/36] test: don't run JIT-based LuaJIT tests without JIT Sergey Kaplun via Tarantool-patches
                   ` (35 more replies)
  0 siblings, 36 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch set handles all tests from <misc/> directory: removes
duplicates or enables them as part of other categories.

Branch: https://github.com/tarantool/luajit/tree/skaplun/gh-9398-more-luajit-tests-p2
Issue: https://github.com/tarantool/tarantool/issues/9398

Sergey Kaplun (36):
  test: don't run JIT-based LuaJIT tests without JIT
  test: enable <misc/alias_alloc.lua> LuaJIT test
  test: refactor <lang/coroutine.lua> LuaJIT test
  test: remove <misc/coro_yield.lua> LuaJIT test
  test: enable <misc/debug_gc.lua> LuaJIT test
  test: enable <misc/dualnum.lua> LuaJIT test
  test: remove <misc/fori_coerce.lua> LuaJIT test
  test: remove <misc/fori_dir.lua> LuaJIT test
  test: remove <misc/gc_rechain.lua> LuaJIT test
  test: enable <misc/gc_trace.lua> LuaJIT test
  test: enable <misc/gcstep.lua> LuaJIT test
  test: enable <misc/hook_active.lua> LuaJIT test
  test: enable <misc/hook_line.lua> LuaJIT test
  test: enable <misc/hook_norecord.lua> LuaJIT test
  test: enable <misc/hook_record.lua> LuaJIT test
  test: enable <misc/hook_top.lua> LuaJIT test
  test: enable <misc/jit_flush.lua> LuaJIT test
  test: remove <misc/loop_unroll.lua> LuaJIT test
  test: enable <misc/parse_comp.lua> LuaJIT test
  test: enable <misc/parse_esc.lua> LuaJIT test
  test: enable <misc/parse_misc.lua> LuaJIT test
  test: enable <misc/phi_conv.lua> LuaJIT test
  test: enable <misc/recurse_deep.lua> LuaJIT test
  test: remove <misc/recurse_tail.lua> LuaJIT test
  test: enable <misc/stack_gc.lua> LuaJIT test
  test: enable <misc/stack_purge.lua> LuaJIT test
  test: enable <misc/stackov.lua> LuaJIT test
  test: enable <misc/stackovc.lua> LuaJIT test
  test: enable <misc/tcall_base.lua> LuaJIT test
  test: enable <misc/tcall_loop.lua> LuaJIT test
  test: enable <misc/tonumber_scan.lua> LuaJIT test
  test: remove <misc/uclo.lua> LuaJIT test
  test: enable <misc/unordered_jit.lua> LuaJIT test
  test: enable <misc/wbarrier.lua> LuaJIT test
  test: enable <misc/wbarrier_jit.lua> LuaJIT test
  test: enable <misc/wbarrier_obar.lua> LuaJIT test

 test/LuaJIT-tests/CMakeLists.txt              |  10 +-
 test/LuaJIT-tests/lang/coroutine.lua          |   8 -
 .../deep_recursion.lua}                       |   8 +-
 test/LuaJIT-tests/{misc => lang}/dualnum.lua  |  24 +-
 .../{misc/debug_gc.lua => lang/gc_debug.lua}  |  31 ++-
 .../{misc/stack_gc.lua => lang/gc_stack.lua}  |   6 +-
 test/LuaJIT-tests/lang/gc_step.lua            |  39 +++
 test/LuaJIT-tests/lang/hook_active.lua        | 102 ++++++++
 test/LuaJIT-tests/lang/hook_line.lua          |  44 ++++
 test/LuaJIT-tests/lang/hook_top.lua           |  59 +++++
 test/LuaJIT-tests/lang/index                  |  15 +-
 test/LuaJIT-tests/lang/parse_comp.lua         |  12 +
 test/LuaJIT-tests/lang/parse_esc.lua          |  10 +
 test/LuaJIT-tests/lang/parse_misc.lua         |  31 +++
 test/LuaJIT-tests/lang/stackov.lua            |  48 ++++
 test/LuaJIT-tests/lang/stackov_c.lua          |  12 +
 test/LuaJIT-tests/lang/wbarrier.lua           |  11 +
 test/LuaJIT-tests/lib/base/index              |   1 +
 .../{misc => lib/base}/tonumber_scan.lua      |  58 +++--
 test/LuaJIT-tests/lib/coroutine/index         |   1 +
 test/LuaJIT-tests/lib/coroutine/traceback.lua |  14 +
 test/LuaJIT-tests/misc/coro_traceback.lua     |   8 -
 test/LuaJIT-tests/misc/coro_yield.lua         | 111 --------
 test/LuaJIT-tests/misc/for_dir.lua            |  13 -
 test/LuaJIT-tests/misc/fori_coerce.lua        |  33 ---
 test/LuaJIT-tests/misc/gc_rechain.lua         |  32 ---
 test/LuaJIT-tests/misc/gcstep.lua             |  33 ---
 test/LuaJIT-tests/misc/hook_active.lua        |  95 -------
 test/LuaJIT-tests/misc/hook_line.lua          |  41 ---
 test/LuaJIT-tests/misc/hook_norecord.lua      |  12 -
 test/LuaJIT-tests/misc/hook_record.lua        |   8 -
 test/LuaJIT-tests/misc/hook_top.lua           |  55 ----
 test/LuaJIT-tests/misc/jit_flush.lua          |  50 ----
 test/LuaJIT-tests/misc/loop_unroll.lua        |  35 ---
 test/LuaJIT-tests/misc/parse_comp.lua         |  13 -
 test/LuaJIT-tests/misc/parse_esc.lua          |   7 -
 test/LuaJIT-tests/misc/parse_misc.lua         |  31 ---
 test/LuaJIT-tests/misc/recurse_tail.lua       |  22 --
 test/LuaJIT-tests/misc/stackov.lua            |  40 ---
 test/LuaJIT-tests/misc/stackovc.lua           |   4 -
 test/LuaJIT-tests/misc/tcall_loop.lua         |   8 -
 test/LuaJIT-tests/misc/uclo.lua               |  91 -------
 test/LuaJIT-tests/misc/unordered_jit.lua      |  96 -------
 test/LuaJIT-tests/misc/wbarrier.lua           |   7 -
 test/LuaJIT-tests/misc/wbarrier_jit.lua       |  18 --
 test/LuaJIT-tests/misc/wbarrier_obar.lua      |  22 --
 test/LuaJIT-tests/opt/index                   |   1 +
 .../{misc => opt/mem}/alias_alloc.lua         |  30 +--
 test/LuaJIT-tests/opt/mem/index               |   1 +
 .../{misc/gc_trace.lua => trace/gc.lua}       |  27 +-
 test/LuaJIT-tests/trace/hook_norecord.lua     |  12 +
 test/LuaJIT-tests/trace/hook_record.lua       |   7 +
 test/LuaJIT-tests/trace/index                 |   9 +
 test/LuaJIT-tests/trace/jit_flush.lua         |  66 +++++
 .../{misc/phi_conv.lua => trace/phi/conv.lua} |  35 +--
 test/LuaJIT-tests/trace/phi/index             |   1 +
 .../{misc => trace}/stack_purge.lua           |  14 +-
 .../{misc => trace}/tcall_base.lua            |  12 +-
 test/LuaJIT-tests/trace/tcall_loop.lua        |  10 +
 test/LuaJIT-tests/trace/unordered_jit.lua     | 240 ++++++++++++++++++
 test/LuaJIT-tests/trace/wbarrier.lua          |  57 +++++
 61 files changed, 939 insertions(+), 1012 deletions(-)
 delete mode 100644 test/LuaJIT-tests/lang/coroutine.lua
 rename test/LuaJIT-tests/{misc/recurse_deep.lua => lang/deep_recursion.lua} (84%)
 rename test/LuaJIT-tests/{misc => lang}/dualnum.lua (57%)
 rename test/LuaJIT-tests/{misc/debug_gc.lua => lang/gc_debug.lua} (63%)
 rename test/LuaJIT-tests/{misc/stack_gc.lua => lang/gc_stack.lua} (76%)
 create mode 100644 test/LuaJIT-tests/lang/gc_step.lua
 create mode 100644 test/LuaJIT-tests/lang/hook_active.lua
 create mode 100644 test/LuaJIT-tests/lang/hook_line.lua
 create mode 100644 test/LuaJIT-tests/lang/hook_top.lua
 create mode 100644 test/LuaJIT-tests/lang/parse_comp.lua
 create mode 100644 test/LuaJIT-tests/lang/parse_esc.lua
 create mode 100644 test/LuaJIT-tests/lang/parse_misc.lua
 create mode 100644 test/LuaJIT-tests/lang/stackov.lua
 create mode 100644 test/LuaJIT-tests/lang/stackov_c.lua
 create mode 100644 test/LuaJIT-tests/lang/wbarrier.lua
 rename test/LuaJIT-tests/{misc => lib/base}/tonumber_scan.lua (93%)
 create mode 100644 test/LuaJIT-tests/lib/coroutine/traceback.lua
 delete mode 100644 test/LuaJIT-tests/misc/coro_traceback.lua
 delete mode 100644 test/LuaJIT-tests/misc/coro_yield.lua
 delete mode 100644 test/LuaJIT-tests/misc/for_dir.lua
 delete mode 100644 test/LuaJIT-tests/misc/fori_coerce.lua
 delete mode 100644 test/LuaJIT-tests/misc/gc_rechain.lua
 delete mode 100644 test/LuaJIT-tests/misc/gcstep.lua
 delete mode 100644 test/LuaJIT-tests/misc/hook_active.lua
 delete mode 100644 test/LuaJIT-tests/misc/hook_line.lua
 delete mode 100644 test/LuaJIT-tests/misc/hook_norecord.lua
 delete mode 100644 test/LuaJIT-tests/misc/hook_record.lua
 delete mode 100644 test/LuaJIT-tests/misc/hook_top.lua
 delete mode 100644 test/LuaJIT-tests/misc/jit_flush.lua
 delete mode 100644 test/LuaJIT-tests/misc/loop_unroll.lua
 delete mode 100644 test/LuaJIT-tests/misc/parse_comp.lua
 delete mode 100644 test/LuaJIT-tests/misc/parse_esc.lua
 delete mode 100644 test/LuaJIT-tests/misc/parse_misc.lua
 delete mode 100644 test/LuaJIT-tests/misc/recurse_tail.lua
 delete mode 100644 test/LuaJIT-tests/misc/stackov.lua
 delete mode 100644 test/LuaJIT-tests/misc/stackovc.lua
 delete mode 100644 test/LuaJIT-tests/misc/tcall_loop.lua
 delete mode 100644 test/LuaJIT-tests/misc/uclo.lua
 delete mode 100644 test/LuaJIT-tests/misc/unordered_jit.lua
 delete mode 100644 test/LuaJIT-tests/misc/wbarrier.lua
 delete mode 100644 test/LuaJIT-tests/misc/wbarrier_jit.lua
 delete mode 100644 test/LuaJIT-tests/misc/wbarrier_obar.lua
 rename test/LuaJIT-tests/{misc => opt/mem}/alias_alloc.lua (53%)
 create mode 100644 test/LuaJIT-tests/opt/mem/index
 rename test/LuaJIT-tests/{misc/gc_trace.lua => trace/gc.lua} (60%)
 create mode 100644 test/LuaJIT-tests/trace/hook_norecord.lua
 create mode 100644 test/LuaJIT-tests/trace/hook_record.lua
 create mode 100644 test/LuaJIT-tests/trace/jit_flush.lua
 rename test/LuaJIT-tests/{misc/phi_conv.lua => trace/phi/conv.lua} (67%)
 rename test/LuaJIT-tests/{misc => trace}/stack_purge.lua (74%)
 rename test/LuaJIT-tests/{misc => trace}/tcall_base.lua (62%)
 create mode 100644 test/LuaJIT-tests/trace/tcall_loop.lua
 create mode 100644 test/LuaJIT-tests/trace/unordered_jit.lua
 create mode 100644 test/LuaJIT-tests/trace/wbarrier.lua

-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 01/36] test: don't run JIT-based LuaJIT tests without JIT
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-15 12:47   ` Sergey Bronnikov via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 02/36] test: enable <misc/alias_alloc.lua> LuaJIT test Sergey Kaplun via Tarantool-patches
                   ` (34 subsequent siblings)
  35 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

Before this patch +jit flag is given to the LuaJIT test suite
unconditionally even when LuaJIT is built as a pure interpreter.

This patch fixes the behaviour by setting the flag only when
`LUAJIT_DISABLE_JIT` option is not set.

Needed for tarantool/tarantool#9398
---
 test/LuaJIT-tests/CMakeLists.txt | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt
index 9fbe9bf5..019762e0 100644
--- a/test/LuaJIT-tests/CMakeLists.txt
+++ b/test/LuaJIT-tests/CMakeLists.txt
@@ -42,11 +42,15 @@ if(LUAJIT_USE_ASAN)
   endif()
 endif()
 
+if(NOT LUAJIT_DISABLE_JIT)
+  list(APPEND LUAJIT_TEST_TAGS_EXTRA +jit)
+endif()
+
 if(LUAJIT_NO_UNWIND)
   # Test <catch_cpp.lua> verifies the interoperability with C++
   # ABI exceptions, so it requires external unwinding enabled.
   # Hence, skip them otherwise.
-  set(LUAJIT_TEST_TAGS_EXTRA +internal_unwinder)
+  list(APPEND LUAJIT_TEST_TAGS_EXTRA +internal_unwinder)
 endif()
 
 if(CMAKE_C_FLAGS MATCHES "-march=skylake-avx512")
@@ -55,7 +59,7 @@ if(CMAKE_C_FLAGS MATCHES "-march=skylake-avx512")
   # built with the enabled AVX512 instruction set, see
   # https://github.com/tarantool/tarantool/issues/6787.
   # Hence, skip this when "skylake-avx512" is passed.
-  set(LUAJIT_TEST_TAGS_EXTRA +avx512)
+  list(APPEND LUAJIT_TEST_TAGS_EXTRA +avx512)
 endif()
 
 set(TEST_SUITE_NAME "LuaJIT-tests")
@@ -73,7 +77,7 @@ add_test_suite_target(LuaJIT-tests
 set(test_title "test/${TEST_SUITE_NAME}")
 add_test(NAME "${test_title}"
   COMMAND ${LUAJIT_TEST_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/test.lua
-                                 +slow +ffi +bit +jit ${LUAJIT_TEST_TAGS_EXTRA}
+                                 +slow +ffi +bit ${LUAJIT_TEST_TAGS_EXTRA}
   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
 )
 set_tests_properties("${test_title}" PROPERTIES
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 02/36] test: enable <misc/alias_alloc.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 01/36] test: don't run JIT-based LuaJIT tests without JIT Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-15 12:51   ` Sergey Bronnikov via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 03/36] test: refactor <lang/coroutine.lua> " Sergey Kaplun via Tarantool-patches
                   ` (33 subsequent siblings)
  35 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the <alias_alloc.lua> test from the <misc> to the
created <opt/mem> directory, includes it in <index>, and names subtests.

Testing optimizations in <lj_opt_mem.c> requires CSE, DCE, FOLD, and FWD
optimizations enabled. Hence, the corresponding flags are used for the
<mem> directory in <index>.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/opt/index                   |  1 +
 .../{misc => opt/mem}/alias_alloc.lua         | 30 +++++++++----------
 test/LuaJIT-tests/opt/mem/index               |  1 +
 3 files changed, 16 insertions(+), 16 deletions(-)
 rename test/LuaJIT-tests/{misc => opt/mem}/alias_alloc.lua (53%)
 create mode 100644 test/LuaJIT-tests/opt/mem/index

diff --git a/test/LuaJIT-tests/opt/index b/test/LuaJIT-tests/opt/index
index 94d50aec..8c43b56e 100644
--- a/test/LuaJIT-tests/opt/index
+++ b/test/LuaJIT-tests/opt/index
@@ -3,4 +3,5 @@ fold +fold
 fwd +fwd
 fuse.lua +fuse
 loop +loop
+mem +cse +dse +fold +fwd
 sink +sink
diff --git a/test/LuaJIT-tests/misc/alias_alloc.lua b/test/LuaJIT-tests/opt/mem/alias_alloc.lua
similarity index 53%
rename from test/LuaJIT-tests/misc/alias_alloc.lua
rename to test/LuaJIT-tests/opt/mem/alias_alloc.lua
index 02fe618d..a9627b55 100644
--- a/test/LuaJIT-tests/misc/alias_alloc.lua
+++ b/test/LuaJIT-tests/opt/mem/alias_alloc.lua
@@ -1,8 +1,7 @@
-
-do
+do --- ALOAD forwarding, same table.
   local t = {1}
   local x
-  for i=1,100 do
+  for i = 1, 100 do
     local v = {i}
     t[1] = v[1]
     x = v[1]
@@ -10,45 +9,44 @@ do
   assert(x == 100 and t[1] == 100)
 end
 
-do
+do --- ALOAD forwarding, different tables.
   local t = {1}
   local x,y
-  for i=1,100 do
+  for i = 1, 100 do
     local v = {i}
-    local w = {i+1}
+    local w = {i + 1}
     x = v[1]
     y = w[1]
   end
   assert(x == 100 and y == 101)
 end
 
-do
+do --- FLOAD forwarding.
   local mt = {}
   local t = setmetatable({}, mt)
   local x
-  for i=1,100 do
+  for _ = 1, 100 do
     local v = {}
     setmetatable(v, getmetatable(t))
     assert(getmetatable(v) == mt)
   end
 end
 
--- See also sink_alloc.lua
-do
-  local x,k={1,2},{3,4}
-  for i=1,100 do x = {x[1]+k[1], x[2]+k[2]} end
+-- See also <opt/sink/alloc.lua>.
+do --- Forwarding the constant-on-trace table in the complex add.
+  local x, k = {1, 2}, {3, 4}
+  for _ = 1, 100 do x = {x[1] + k[1], x[2] + k[2]} end
   assert(x[1] == 301)
   assert(x[2] == 402)
 end
 
--- FLOAD for tab.asize/tab.array crossing NEWREF.
-do
+
+do --- FLOAD forwarding for tab.asize/tab.array crossing NEWREF.
   local t = {1}
-  for i=1,100 do
+  for _ = 1, 100 do
     local v = {}
     local w = {}
     v[1] = t[1]
     w[1] = t[1]
   end
 end
-
diff --git a/test/LuaJIT-tests/opt/mem/index b/test/LuaJIT-tests/opt/mem/index
new file mode 100644
index 00000000..0b1856ed
--- /dev/null
+++ b/test/LuaJIT-tests/opt/mem/index
@@ -0,0 +1 @@
+alias_alloc.lua
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 03/36] test: refactor <lang/coroutine.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 01/36] test: don't run JIT-based LuaJIT tests without JIT Sergey Kaplun via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 02/36] test: enable <misc/alias_alloc.lua> LuaJIT test Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-15 13:00   ` Sergey Bronnikov via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 04/36] test: remove <misc/coro_yield.lua> " Sergey Kaplun via Tarantool-patches
                   ` (32 subsequent siblings)
  35 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch refactors the <lang/coroutine.lua> test by adding a simple
check for the content of a `debug.traceback()` result. Also, the test is
moved to the <lib/coroutine/> directory.

Also, it removes the <misc/coro_traceback.lua> since it is the same test
that wasn't cleaned up during the refactoring in the original
repository.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lang/coroutine.lua          |  8 --------
 test/LuaJIT-tests/lang/index                  |  1 -
 test/LuaJIT-tests/lib/coroutine/index         |  1 +
 test/LuaJIT-tests/lib/coroutine/traceback.lua | 14 ++++++++++++++
 test/LuaJIT-tests/misc/coro_traceback.lua     |  8 --------
 5 files changed, 15 insertions(+), 17 deletions(-)
 delete mode 100644 test/LuaJIT-tests/lang/coroutine.lua
 create mode 100644 test/LuaJIT-tests/lib/coroutine/traceback.lua
 delete mode 100644 test/LuaJIT-tests/misc/coro_traceback.lua

diff --git a/test/LuaJIT-tests/lang/coroutine.lua b/test/LuaJIT-tests/lang/coroutine.lua
deleted file mode 100644
index 405135c9..00000000
--- a/test/LuaJIT-tests/lang/coroutine.lua
+++ /dev/null
@@ -1,8 +0,0 @@
-do --- traceback
-  local co = coroutine.create(function()
-    local x = nil
-    local y = x.x
-  end)
-  assert(coroutine.resume(co) == false)
-  debug.traceback(co)
-end
diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 4ff7a297..803f32d8 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -14,7 +14,6 @@ concat.lua
 self.lua
 table.lua
 upvalue
-coroutine.lua
 tail_recursion.lua
 vararg_jit.lua
 gc.lua
diff --git a/test/LuaJIT-tests/lib/coroutine/index b/test/LuaJIT-tests/lib/coroutine/index
index 9c5c17ec..c4dc6cf1 100644
--- a/test/LuaJIT-tests/lib/coroutine/index
+++ b/test/LuaJIT-tests/lib/coroutine/index
@@ -1 +1,2 @@
+traceback.lua
 yield.lua
diff --git a/test/LuaJIT-tests/lib/coroutine/traceback.lua b/test/LuaJIT-tests/lib/coroutine/traceback.lua
new file mode 100644
index 00000000..2b900ef1
--- /dev/null
+++ b/test/LuaJIT-tests/lib/coroutine/traceback.lua
@@ -0,0 +1,14 @@
+do --- traceback
+  local function badfunc()
+    local x = nil
+    local y = x.x
+  end
+
+  local co = coroutine.create(badfunc)
+  assert(coroutine.resume(co) == false)
+
+  local traceback = debug.traceback(co)
+  local line = debug.getinfo(badfunc).linedefined
+
+  assert(traceback:match('traceback:.*:' .. line))
+end
diff --git a/test/LuaJIT-tests/misc/coro_traceback.lua b/test/LuaJIT-tests/misc/coro_traceback.lua
deleted file mode 100644
index 2676d2c6..00000000
--- a/test/LuaJIT-tests/misc/coro_traceback.lua
+++ /dev/null
@@ -1,8 +0,0 @@
-
-local co = coroutine.create(function()
-  local x = nil
-  local y = x.x
-end)
-assert(coroutine.resume(co) == false)
-debug.traceback(co)
-
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 04/36] test: remove <misc/coro_yield.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (2 preceding siblings ...)
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 03/36] test: refactor <lang/coroutine.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-15 13:05   ` Sergey Bronnikov via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 05/36] test: enable <misc/debug_gc.lua> " Sergey Kaplun via Tarantool-patches
                   ` (31 subsequent siblings)
  35 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch removes the aforementioned test since it is the same test as
<lib/coroutine/yield.lua> that wasn't cleaned up during the refactoring
in the original repository.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/misc/coro_yield.lua | 111 --------------------------
 1 file changed, 111 deletions(-)
 delete mode 100644 test/LuaJIT-tests/misc/coro_yield.lua

diff --git a/test/LuaJIT-tests/misc/coro_yield.lua b/test/LuaJIT-tests/misc/coro_yield.lua
deleted file mode 100644
index ae3206e0..00000000
--- a/test/LuaJIT-tests/misc/coro_yield.lua
+++ /dev/null
@@ -1,111 +0,0 @@
-local create = coroutine.create
-local wrap = coroutine.wrap
-local resume = coroutine.resume
-local yield = coroutine.yield
-
--- Test stack overflow handling on return from coroutine.
-do
-  wrap(function()
-    local co = create(function()
-      yield(string.byte(string.rep(" ", 100), 1, 100))
-    end)
-    assert(select('#', resume(co)) == 101)
-  end)()
-end
-
-do
-  wrap(function()
-    local f = wrap(function()
-      yield(string.byte(string.rep(" ", 100), 1, 100))
-    end)
-    assert(select('#', f()) == 100)
-  end)()
-end
-
-do
-  local function cogen(x)
-    return wrap(function(n) repeat x = x+n; n = yield(x) until false end),
-	   wrap(function(n) repeat x = x*n; n = yield(x) until false end)
-  end
-
-  local a,b=cogen(3)
-  local c,d=cogen(5)
-  assert(d(b(c(a(d(b(c(a(1)))))))) == 168428160)
-end
-
-do
-  local function verify(what, expect, ...)
-    local got = {...}
-    for i=1,100 do
-      if expect[i] ~= got[i] then
-	error("FAIL " .. what)
-      end
-      if expect[i] == nil then
-	break
-      end
-    end
-  end
-
-  local function cofunc(...)
-    verify("call", { 1, "foo" }, ...)
-    verify("yield", { "bar" }, yield(2, "test"))
-    verify("pcall yield", { true, "again" }, pcall(yield, "from pcall"))
-    return "end"
-  end
-
-  local co = create(cofunc)
-  verify("resume", { true, 2, "test" }, resume(co, 1, "foo"))
-  verify("resume pcall", { true, "from pcall" }, resume(co, "bar"))
-  verify("resume end", { true, "end" }, resume(co, "again"))
-end
-
-do
-  local function verify(expect, func, ...)
-    local co = create(func)
-    for i=1,100 do
-      local ok, res = resume(co, ...)
-      if not ok then
-	if expect[i] ~= nil then
-	  error("too few results: ["..i.."] = "..tostring(expect[i]).." (got: "..tostring(res)..")")
-	end
-	break
-      end
-      if expect[i] ~= res then
-	error("bad result: ["..i.."] = "..tostring(res).." (should be: "..tostring(expect[i])..")")
-      end
-    end
-  end
-
-  verify({ 42, 99 },
-    function(x) pcall(yield, x) return 99 end,
-    42)
-
-  verify({ 42, 99 },
-    function(x) pcall(function(y) yield(y) end, x) return 99 end,
-    42)
-
-  verify({ 42, 99 },
-    function(x) xpcall(yield, debug.traceback, x) return 99 end,
-    42)
-
-  verify({ 45, 44, 43, 42, 99 },
-    function(x, y)
-      for i in
-	function(o, k)
-	  yield(o+k)
-	  if k ~= 0 then return k-1 end
-	end,x,y do
-      end
-      return 99
-    end,
-    42, 3)
-
-  verify({ 84, 99 },
-    function(x)
-      local o = setmetatable({ x },
-	{__add = function(a, b) yield(a[1]+b[1]) return 99 end })
-      return o+o
-    end,
-    42)
-end
-
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 05/36] test: enable <misc/debug_gc.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (3 preceding siblings ...)
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 04/36] test: remove <misc/coro_yield.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-15 13:09   ` Sergey Bronnikov via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 06/36] test: enable <misc/dualnum.lua> " Sergey Kaplun via Tarantool-patches
                   ` (30 subsequent siblings)
  35 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <lang/>
directory (with slightly renaming to be consistent with other names),
includes it in <index>, and names the subtest.

Also, it changes the number of iterations to trigger the GC since the
number of objects is different when running the test as a part of the
LuaJIT test suite.

Part of tarantool/tarantool#9398
---
 .../{misc/debug_gc.lua => lang/gc_debug.lua}  | 31 ++++++++++++-------
 test/LuaJIT-tests/lang/index                  |  1 +
 2 files changed, 20 insertions(+), 12 deletions(-)
 rename test/LuaJIT-tests/{misc/debug_gc.lua => lang/gc_debug.lua} (63%)

diff --git a/test/LuaJIT-tests/misc/debug_gc.lua b/test/LuaJIT-tests/lang/gc_debug.lua
similarity index 63%
rename from test/LuaJIT-tests/misc/debug_gc.lua
rename to test/LuaJIT-tests/lang/gc_debug.lua
index 30fb2b99..bb30adc1 100644
--- a/test/LuaJIT-tests/misc/debug_gc.lua
+++ b/test/LuaJIT-tests/lang/gc_debug.lua
@@ -1,12 +1,7 @@
-
--- Do not run this test unless the JIT compiler is turned off.
-if jit and jit.status and jit.status() then return end
-
 local caught, caught_line, caught_mm
 
 local function gcmeta()
   if caught ~= "end" then
---    print(debug.traceback())
     -- This may point to the wrong instruction if in a JIT trace.
     -- But there's no guarantee if, when or where any GC steps occur.
     local dbg = debug.getinfo(2)
@@ -22,7 +17,7 @@ local function testgc(mm, f)
   local u = newproxy(true)
   getmetatable(u).__gc = gcmeta
   u = nil
-  for i=1,100000 do
+  for i = 1, 1e7 do
     f(i)
     -- This check may be hoisted. __gc is not supposed to have side-effects.
     if caught then break end
@@ -38,10 +33,22 @@ local function testgc(mm, f)
   end
 end
 
-local x
-testgc("__gc", function(i) x = {} end)
-testgc("__gc", function(i) x = {1} end)
-testgc("__gc", function(i) x = function() end end)
-testgc("__concat", function(i) x = i.."" end)
+do --- Test __gc metamethod info
+  -- Do not run this test unless the JIT compiler is turned off.
+  local jit_need_restore = false
+  if jit and jit.status and jit.status() then
+    jit_need_restore = true
+    jit.off()
+  end
+
+  local x
+  testgc("__gc", function(i) x = {} end)
+  testgc("__gc", function(i) x = {1} end)
+  testgc("__gc", function(i) x = function() end end)
+  testgc("__concat", function(i) x = i.."" end)
 
-caught = "end"
+  caught = "end"
+  if jit_need_restore then
+     jit.on()
+  end
+end
diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 803f32d8..4d9feafd 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -17,5 +17,6 @@ upvalue
 tail_recursion.lua
 vararg_jit.lua
 gc.lua
+gc_debug.lua
 goto.lua +goto
 meta
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 06/36] test: enable <misc/dualnum.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (4 preceding siblings ...)
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 05/36] test: enable <misc/debug_gc.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-15 13:11   ` Sergey Bronnikov via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 07/36] test: remove <misc/fori_coerce.lua> " Sergey Kaplun via Tarantool-patches
                   ` (29 subsequent siblings)
  35 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <lang/>
directory, includes it in <index>, and names subtests.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/{misc => lang}/dualnum.lua | 24 +++++++++-----------
 test/LuaJIT-tests/lang/index                 |  1 +
 2 files changed, 12 insertions(+), 13 deletions(-)
 rename test/LuaJIT-tests/{misc => lang}/dualnum.lua (57%)

diff --git a/test/LuaJIT-tests/misc/dualnum.lua b/test/LuaJIT-tests/lang/dualnum.lua
similarity index 57%
rename from test/LuaJIT-tests/misc/dualnum.lua
rename to test/LuaJIT-tests/lang/dualnum.lua
index 5f1288c8..688920eb 100644
--- a/test/LuaJIT-tests/misc/dualnum.lua
+++ b/test/LuaJIT-tests/lang/dualnum.lua
@@ -1,34 +1,32 @@
+-- Test LuaJIT Dualnum mode behaviour.
 
--- Positive overflow
-do
+do --- Positive overflow.
   local x = 0
-  for i=2147483446,2147483647,2 do x = x + 1 end
+  for _ = 2147483446, 2147483647, 2 do x = x + 1 end
   assert(x == 101)
 end
 
--- Negative overflow
-do
+do --- Negative overflow.
   local x = 0
-  for i=-2147483447,-2147483648,-2 do x = x + 1 end
+  for _ = -2147483447, -2147483648, -2 do x = x + 1 end
   assert(x == 101)
 end
 
--- SLOAD with number to integer conversion.
-do
+do --- SLOAD with number to integer conversion.
   local k = 1
   local a, b, c = 1/k, 20/k, 1/k
-  for i=1,20 do
-    for j=a,b,c do end
+  for i = 1, 20 do
+    for j = a, b, c do end
   end
 end
 
-do
+do --- min/max correctness.
   local function fmin(a, b)
-    for i=1,100 do a = math.min(a, b) end
+    for _ = 1, 100 do a = math.min(a, b) end
     return a
   end
   local function fmax(a, b)
-    for i=1,100 do a = math.max(a, b) end
+    for _ = 1, 100 do a = math.max(a, b) end
     return a
   end
   assert(fmin(1, 3) == 1)
diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 4d9feafd..b0e7f073 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -6,6 +6,7 @@ catch_wrap.lua
 compare.lua
 compare_nan.lua
 constant
+dualnum.lua
 for.lua
 length.lua
 lightud.lua
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 07/36] test: remove <misc/fori_coerce.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (5 preceding siblings ...)
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 06/36] test: enable <misc/dualnum.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-15 13:20   ` Sergey Bronnikov via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 08/36] test: remove <misc/fori_dir.lua> " Sergey Kaplun via Tarantool-patches
                   ` (28 subsequent siblings)
  35 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch removes the aforementioned test since it is part of the
<lang/for.lua> test.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/misc/fori_coerce.lua | 33 --------------------------
 1 file changed, 33 deletions(-)
 delete mode 100644 test/LuaJIT-tests/misc/fori_coerce.lua

diff --git a/test/LuaJIT-tests/misc/fori_coerce.lua b/test/LuaJIT-tests/misc/fori_coerce.lua
deleted file mode 100644
index 7330943b..00000000
--- a/test/LuaJIT-tests/misc/fori_coerce.lua
+++ /dev/null
@@ -1,33 +0,0 @@
-
-do
-  local n = 1
-  local x = 0
-  for i=1,20 do
-    for j=n,100 do x = x + 1 end
-    if i == 13 then n = "2" end
-  end
-  assert(x == 1993)
-end
-
-do
-  local n = 1
-  local x = 0
-  for i=1,20 do
-    for j=n,100 do x = x + 1 end
-    if i == 10 then n = "2" end
-  end
-  assert(x == 1990)
-end
-
-do
-  local function f()
-    local n = 1
-    local x = 0
-    for i=1,20 do
-      for j=n,100 do x = x + 1 end
-      if i == 10 then n = "x" end
-    end
-  end
-  assert(not pcall(f))
-end
-
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 08/36] test: remove <misc/fori_dir.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (6 preceding siblings ...)
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 07/36] test: remove <misc/fori_coerce.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-15 13:21   ` Sergey Bronnikov via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 09/36] test: remove <misc/gc_rechain.lua> " Sergey Kaplun via Tarantool-patches
                   ` (27 subsequent siblings)
  35 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch removes the aforementioned test since it is part of the
<lang/for.lua> test.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/misc/for_dir.lua | 13 -------------
 1 file changed, 13 deletions(-)
 delete mode 100644 test/LuaJIT-tests/misc/for_dir.lua

diff --git a/test/LuaJIT-tests/misc/for_dir.lua b/test/LuaJIT-tests/misc/for_dir.lua
deleted file mode 100644
index 4dd38dee..00000000
--- a/test/LuaJIT-tests/misc/for_dir.lua
+++ /dev/null
@@ -1,13 +0,0 @@
-
-local a,b,c = 10,1,-1
-for i=1,20 do
-  if c == -1 then
-    a,b,c = 1,10,1
-  else
-    a,b,c = 10,1,-1
-  end
-  local x = 0
-  for i=a,b,c do for j=1,10 do end x=x+1 end
-  assert(x == 10)
-end
-
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 09/36] test: remove <misc/gc_rechain.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (7 preceding siblings ...)
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 08/36] test: remove <misc/fori_dir.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-15 13:22   ` Sergey Bronnikov via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 10/36] test: enable <misc/gc_trace.lua> " Sergey Kaplun via Tarantool-patches
                   ` (26 subsequent siblings)
  35 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch removes the aforementioned test since it is part of the
<lang/gc.lua> test.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/misc/gc_rechain.lua | 32 ---------------------------
 1 file changed, 32 deletions(-)
 delete mode 100644 test/LuaJIT-tests/misc/gc_rechain.lua

diff --git a/test/LuaJIT-tests/misc/gc_rechain.lua b/test/LuaJIT-tests/misc/gc_rechain.lua
deleted file mode 100644
index 285f4086..00000000
--- a/test/LuaJIT-tests/misc/gc_rechain.lua
+++ /dev/null
@@ -1,32 +0,0 @@
-
-do
-  local k
-
-  collectgarbage()
-
-  local t = {}
-  t.ac = 1
-
-  t.nn = 1
-  t.mm = 1
-  t.nn = nil
-  t.mm = nil
-
-  k = "a".."i"
-  t[k] = 2
-
-  t.ad = 3
-
-  t[k] = nil
-  k = nil
-
-  collectgarbage()
-
-  k = "a".."f"
-  t[k] = 4
-
-  t.ak = 5
-
-  assert(t[k] == 4)
-end
-
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 10/36] test: enable <misc/gc_trace.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (8 preceding siblings ...)
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 09/36] test: remove <misc/gc_rechain.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-15 13:24   ` Sergey Bronnikov via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 11/36] test: enable <misc/gcstep.lua> " Sergey Kaplun via Tarantool-patches
                   ` (25 subsequent siblings)
  35 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <trace/>
directory, includes it in <index>, and names subtests.

The first test is adjusted to be runable in the test suite.

Part of tarantool/tarantool#9398
---
 .../{misc/gc_trace.lua => trace/gc.lua}       | 27 +++++++++----------
 test/LuaJIT-tests/trace/index                 |  1 +
 2 files changed, 14 insertions(+), 14 deletions(-)
 rename test/LuaJIT-tests/{misc/gc_trace.lua => trace/gc.lua} (60%)

diff --git a/test/LuaJIT-tests/misc/gc_trace.lua b/test/LuaJIT-tests/trace/gc.lua
similarity index 60%
rename from test/LuaJIT-tests/misc/gc_trace.lua
rename to test/LuaJIT-tests/trace/gc.lua
index bc38ce0c..4d984ed6 100644
--- a/test/LuaJIT-tests/misc/gc_trace.lua
+++ b/test/LuaJIT-tests/trace/gc.lua
@@ -1,18 +1,18 @@
+local jutil = require("jit.util")
 
-if not jit or not jit.status or not jit.status() then return end
-
-collectgarbage()
-for j=1,100 do
-  loadstring("for i=1,100 do end")()
+do --- Collect dead traces.
+  jit.flush()
+  collectgarbage()
+  for _ = 1, 100 do
+    loadstring("for _ = 1, 100 do end")()
+  end
+  collectgarbage()
+  assert(jutil.traceinfo(1) == nil)
+  assert(jutil.traceinfo(2) == nil)
+  assert(jutil.traceinfo(3) == nil)
 end
-local jutil = require("jit.util")
-assert(jutil.traceinfo(90) == nil)
-collectgarbage()
-assert(jutil.traceinfo(1) == nil)
-assert(jutil.traceinfo(2) == nil)
-assert(jutil.traceinfo(3) == nil)
 
-do
+do --- Check KGC marking.
   local f
   local function reccb(tr)
     if f == nil then
@@ -24,7 +24,7 @@ do
     end
   end
   jit.attach(reccb, "record")
-  for i=1,200 do
+  for i = 1, 200 do
     if i % 5 == 0 then
       f = function() end
     elseif f then
@@ -34,4 +34,3 @@ do
   end
   jit.attach(reccb)
 end
-
diff --git a/test/LuaJIT-tests/trace/index b/test/LuaJIT-tests/trace/index
index ea7a22e0..46c8f5d2 100644
--- a/test/LuaJIT-tests/trace/index
+++ b/test/LuaJIT-tests/trace/index
@@ -1,6 +1,7 @@
 exit_frame.lua
 exit_growstack.lua
 exit_jfuncf.lua
+gc.lua
 gc64_slot_revival.lua
 phi
 snap.lua
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 11/36] test: enable <misc/gcstep.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (9 preceding siblings ...)
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 10/36] test: enable <misc/gc_trace.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-15 13:34   ` Sergey Bronnikov via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 12/36] test: enable <misc/hook_active.lua> " Sergey Kaplun via Tarantool-patches
                   ` (24 subsequent siblings)
  35 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <lang/>
directory (with slightly renaming to be consistent with other names),
includes it in <index>, and names the subtests.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lang/gc_step.lua | 39 ++++++++++++++++++++++++++++++
 test/LuaJIT-tests/lang/index       |  1 +
 test/LuaJIT-tests/misc/gcstep.lua  | 33 -------------------------
 3 files changed, 40 insertions(+), 33 deletions(-)
 create mode 100644 test/LuaJIT-tests/lang/gc_step.lua
 delete mode 100644 test/LuaJIT-tests/misc/gcstep.lua

diff --git a/test/LuaJIT-tests/lang/gc_step.lua b/test/LuaJIT-tests/lang/gc_step.lua
new file mode 100644
index 00000000..756d7a61
--- /dev/null
+++ b/test/LuaJIT-tests/lang/gc_step.lua
@@ -0,0 +1,39 @@
+local function testgc(what, func)
+  collectgarbage()
+  local oc = gcinfo()
+  func()
+  local nc = gcinfo()
+  assert(nc < oc * 4, "GC step missing for " .. what)
+end
+
+do --- TNEW
+  testgc("TNEW", function()
+    for _ = 1, 10000 do
+      local _ = {}
+    end
+  end)
+end
+
+do --- TDUP
+  testgc("TDUP", function()
+    for _ = 1, 10000 do
+      local _ = {1}
+    end
+  end)
+end
+
+do --- FNEW
+  testgc("FNEW", function()
+    for _ = 1, 10000 do
+      local function _() end
+    end
+  end)
+end
+
+do --- CAT
+  testgc("CAT", function()
+    for i = 1, 10000 do
+      local _ = "x" .. i
+    end
+  end)
+end
diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index b0e7f073..274425bf 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -19,5 +19,6 @@ tail_recursion.lua
 vararg_jit.lua
 gc.lua
 gc_debug.lua
+gc_step.lua
 goto.lua +goto
 meta
diff --git a/test/LuaJIT-tests/misc/gcstep.lua b/test/LuaJIT-tests/misc/gcstep.lua
deleted file mode 100644
index 533356b7..00000000
--- a/test/LuaJIT-tests/misc/gcstep.lua
+++ /dev/null
@@ -1,33 +0,0 @@
-
-local function testgc(what, func)
-  collectgarbage()
-  local oc = gcinfo()
-  func()
-  local nc = gcinfo()
-  assert(nc < oc*4, "GC step missing for "..what)
-end
-
-testgc("TNEW", function()
-  for i=1,10000 do
-    local t = {}
-  end
-end)
-
-testgc("TDUP", function()
-  for i=1,10000 do
-    local t = {1}
-  end
-end)
-
-testgc("FNEW", function()
-  for i=1,10000 do
-    local function f() end
-  end
-end)
-
-testgc("CAT", function()
-  for i=1,10000 do
-    local s = "x"..i
-  end
-end)
-
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 12/36] test: enable <misc/hook_active.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (10 preceding siblings ...)
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 11/36] test: enable <misc/gcstep.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-15 13:38   ` Sergey Bronnikov via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 13/36] test: enable <misc/hook_line.lua> " Sergey Kaplun via Tarantool-patches
                   ` (23 subsequent siblings)
  35 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <lang/>
directory, includes it in <index>, and names the subtests.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lang/hook_active.lua | 102 +++++++++++++++++++++++++
 test/LuaJIT-tests/lang/index           |   1 +
 test/LuaJIT-tests/misc/hook_active.lua |  95 -----------------------
 3 files changed, 103 insertions(+), 95 deletions(-)
 create mode 100644 test/LuaJIT-tests/lang/hook_active.lua
 delete mode 100644 test/LuaJIT-tests/misc/hook_active.lua

diff --git a/test/LuaJIT-tests/lang/hook_active.lua b/test/LuaJIT-tests/lang/hook_active.lua
new file mode 100644
index 00000000..c82670f5
--- /dev/null
+++ b/test/LuaJIT-tests/lang/hook_active.lua
@@ -0,0 +1,102 @@
+local ctest = require("libctest")
+
+local called = 0
+local function clearhook() debug.sethook(nil, "", 0) end
+
+do --- Return from pcall with active hook must prepend true. FF pcall.
+  called = 0
+  debug.sethook(function() called=called+1; assert(pcall(function() end) == true); clearhook() end, "", 1)
+  do local x = 1 end
+  assert(called == 1)
+end
+
+do --- Hook with special caught error must not unblock hooks. FF pcall.
+  called = 0
+  debug.sethook(function() called=called+1; pcall(nil); clearhook() end, "", 1)
+  do local x = 1 end
+  assert(called == 1)
+end
+
+do --- Hook with caught error must not unblock hooks. FF pcall.
+  called = 0
+  local function p2() error("") end
+  debug.sethook(function() called=called+1; pcall(p2); clearhook() end, "", 1)
+  do local x = 1 end
+  assert(called == 1)
+end
+
+do --- Hook with special caught error must not unblock hooks. C pcall.
+  called = 0
+  debug.sethook(function() called=called+1; ctest.pcall(nil); clearhook() end, "", 1)
+  do local x = 1 end
+  assert(called == 1)
+end
+
+do --- Hook with caught error must not unblock hooks. C pcall
+  called = 0
+  local function p2() error("") end
+  debug.sethook(function() called=called+1; ctest.pcall(p2); clearhook() end, "", 1)
+  do local x = 1 end
+  assert(called == 1)
+end
+
+do --- Regular pcall must not block hooks.
+  debug.sethook(function() called=called+1 end, "", 1)
+  pcall(function() end)
+  called = 0
+  do local x = 1 end
+  assert(called > 0)
+  pcall(function() error("") end)
+  called = 0
+  do local x = 1 end
+  assert(called > 0)
+  ctest.pcall(function() end)
+  called = 0
+  do local x = 1 end
+  assert(called > 0)
+  ctest.pcall(function() error("") end)
+  called = 0
+  do local x = 1 end
+  assert(called > 0)
+  clearhook()
+end
+
+do --- Hook with uncaught error must unblock hooks. FF pcall
+  called = 0
+  pcall(function()
+    debug.sethook(function()
+      local old = called
+      called = 1
+      if old == 0 then error("") end
+    end, "", 1)
+    do local x = 1 end
+  end)
+  assert(called == 1)
+  called = 2
+  do local x = 1 end
+  assert(called == 1, "hook not unblocked after uncaught error")
+  clearhook()
+  called = 2
+  do local x = 1 end
+  assert(called == 2)
+end
+
+do --- Hook with uncaught error must unblock hooks. C pcall
+  called = 0
+  ctest.pcall(function()
+    debug.sethook(function()
+      local old = called
+      called = 1
+      if old == 0 then error("") end
+    end, "", 1)
+    do local x = 1 end
+  end)
+  assert(called == 1)
+  called = 2
+  do local x = 1 end
+  assert(called == 1, "hook not unblocked after uncaught error")
+  clearhook()
+  called = 2
+  do local x = 1 end
+  assert(called == 2)
+end
diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 274425bf..8cecfa08 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -8,6 +8,7 @@ compare_nan.lua
 constant
 dualnum.lua
 for.lua
+hook_active.lua
 length.lua
 lightud.lua
 modulo.lua
diff --git a/test/LuaJIT-tests/misc/hook_active.lua b/test/LuaJIT-tests/misc/hook_active.lua
deleted file mode 100644
index 37dfc379..00000000
--- a/test/LuaJIT-tests/misc/hook_active.lua
+++ /dev/null
@@ -1,95 +0,0 @@
-local ctest = require("ctest")
-
-local called = 0
-local function clearhook() debug.sethook(nil, "", 0) end
-
--- Return from pcall with active hook must prepend true. FF pcall.
-called = 0
-debug.sethook(function() called=called+1; assert(pcall(function() end) == true); clearhook() end, "", 1)
-do local x = 1 end
-assert(called == 1)
-
--- Hook with special caught error must not unblock hooks. FF pcall.
-called = 0
-debug.sethook(function() called=called+1; pcall(nil); clearhook() end, "", 1)
-do local x = 1 end
-assert(called == 1)
-
--- Hook with caught error must not unblock hooks. FF pcall.
-called = 0
-local function p2() error("") end
-debug.sethook(function() called=called+1; pcall(p2); clearhook() end, "", 1)
-do local x = 1 end
-assert(called == 1)
-
--- Hook with special caught error must not unblock hooks. C pcall.
-called = 0
-debug.sethook(function() called=called+1; ctest.pcall(nil); clearhook() end, "", 1)
-do local x = 1 end
-assert(called == 1)
-
--- Hook with caught error must not unblock hooks. C pcall
-called = 0
-local function p2() error("") end
-debug.sethook(function() called=called+1; ctest.pcall(p2); clearhook() end, "", 1)
-do local x = 1 end
-assert(called == 1)
-
--- Regular pcall must not block hooks.
-debug.sethook(function() called=called+1 end, "", 1)
-pcall(function() end)
-called = 0
-do local x = 1 end
-assert(called > 0)
-pcall(function() error("") end)
-called = 0
-do local x = 1 end
-assert(called > 0)
-ctest.pcall(function() end)
-called = 0
-do local x = 1 end
-assert(called > 0)
-ctest.pcall(function() error("") end)
-called = 0
-do local x = 1 end
-assert(called > 0)
-clearhook()
-
--- Hook with uncaught error must unblock hooks. FF pcall
-called = 0
-pcall(function()
-  debug.sethook(function()
-    local old = called
-    called = 1
-    if old == 0 then error("") end
-  end, "", 1)
-  do local x = 1 end
-end)
-assert(called == 1)
-called = 2
-do local x = 1 end
-assert(called == 1, "hook not unblocked after uncaught error")
-clearhook()
-called = 2
-do local x = 1 end
-assert(called == 2)
-
--- Hook with uncaught error must unblock hooks. C pcall
-called = 0
-ctest.pcall(function()
-  debug.sethook(function()
-    local old = called
-    called = 1
-    if old == 0 then error("") end
-  end, "", 1)
-  do local x = 1 end
-end)
-assert(called == 1)
-called = 2
-do local x = 1 end
-assert(called == 1, "hook not unblocked after uncaught error")
-clearhook()
-called = 2
-do local x = 1 end
-assert(called == 2)
-
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 13/36] test: enable <misc/hook_line.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (11 preceding siblings ...)
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 12/36] test: enable <misc/hook_active.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-15 13:42   ` Sergey Bronnikov via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 14/36] test: enable <misc/hook_norecord.lua> " Sergey Kaplun via Tarantool-patches
                   ` (22 subsequent siblings)
  35 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <lang/>
directory, includes it in <index>, names the subtests, and adjusts the
linenumbers in the assertions to match LuaJIT behaviour and the new code
layout.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lang/hook_line.lua | 44 ++++++++++++++++++++++++++++
 test/LuaJIT-tests/lang/index         |  1 +
 test/LuaJIT-tests/misc/hook_line.lua | 41 --------------------------
 3 files changed, 45 insertions(+), 41 deletions(-)
 create mode 100644 test/LuaJIT-tests/lang/hook_line.lua
 delete mode 100644 test/LuaJIT-tests/misc/hook_line.lua

diff --git a/test/LuaJIT-tests/lang/hook_line.lua b/test/LuaJIT-tests/lang/hook_line.lua
new file mode 100644
index 00000000..bb89c4b8
--- /dev/null
+++ b/test/LuaJIT-tests/lang/hook_line.lua
@@ -0,0 +1,44 @@
+local lines = {}
+local function hook()
+  lines[#lines + 1] = debug.getinfo(2).currentline
+end
+
+local function dummy()
+end -- <-- line 7
+
+do --- Base test: cycles, function calls.
+  debug.sethook(hook, "l", 0)
+  -- <-- line 11
+  local x
+  dummy()
+  local y = 1
+  dummy() dummy()
+  local z = 2; local r = true
+  while y < 4 do y = y + 1 end
+  while z < 4 do
+    z = z + 1
+  end
+  -- <-- line 21
+  local v
+  debug.sethook(nil, "", 0)
+
+  assert(#lines > 0)
+  while lines[1] < 10 do table.remove(lines, 1) end
+  while lines[#lines] > 20 do table.remove(lines) end
+
+  local s = table.concat(lines, " ")
+  assert(s == "12 13 7 14 15 7 7 16 17 17 17 17 18 19 18 19 18" or
+         s == "12 13 7 14 15 7 15 7 16 17 17 17 17 18 19 18 19 18")
+end
+
+do --- Not visited the end of the function definition.
+  lines = {}
+  local function f()
+    if true then return end
+    local function x() end
+  end -- <-- line 39
+  debug.sethook(hook, "l", 0)
+  f()
+  debug.sethook(nil, "", 0)
+  for i = 1, #lines do assert(lines[i] ~= 39) end
+end
diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 8cecfa08..ae59bc56 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -9,6 +9,7 @@ constant
 dualnum.lua
 for.lua
 hook_active.lua
+hook_line.lua
 length.lua
 lightud.lua
 modulo.lua
diff --git a/test/LuaJIT-tests/misc/hook_line.lua b/test/LuaJIT-tests/misc/hook_line.lua
deleted file mode 100644
index 36f71080..00000000
--- a/test/LuaJIT-tests/misc/hook_line.lua
+++ /dev/null
@@ -1,41 +0,0 @@
-local lines = {}
-local function hook()
-  lines[#lines+1] = debug.getinfo(2).currentline
-end
-
-local function dummy()
-end -- <-- line 7
-
-debug.sethook(hook, "l", 0)
--- <-- line 10
-local x
-dummy()
-local y = 1
-dummy() dummy()
-local z = 2; local r = true
-while y < 4 do y = y + 1 end
-while z < 4 do
-  z = z + 1
-end
--- <-- line 20
-local v
-debug.sethook(nil, "", 0)
-
-assert(#lines > 0)
-while lines[1] < 10 do table.remove(lines, 1) end
-while lines[#lines] > 20 do table.remove(lines) end
-
-local s = table.concat(lines, " ")
-assert(s == "11 12 7 13 14 7 7 15 16 16 16 16 17 18 17 18 17" or
-       s == "11 12 7 13 14 7 14 7 15 16 16 16 16 17 18 17 18 17")
-
-lines = {}
-local function f()
-  if true then return end
-  local function x() end
-end -- <-- line 36
-debug.sethook(hook, "l", 0)
-f()
-debug.sethook(nil, "", 0)
-for i=1,#lines do assert(lines[i] ~= 36) end
-
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 14/36] test: enable <misc/hook_norecord.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (12 preceding siblings ...)
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 13/36] test: enable <misc/hook_line.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-15 13:56   ` Sergey Bronnikov via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 15/36] test: enable <misc/hook_record.lua> " Sergey Kaplun via Tarantool-patches
                   ` (21 subsequent siblings)
  35 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <trace/>
directory, includes it in <index>, and names the subtest.

The test is adjusted to be runable in the test suite by adding the
`jit.flush()` to avoid collisions of traces.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/misc/hook_norecord.lua  | 12 ------------
 test/LuaJIT-tests/trace/hook_norecord.lua | 12 ++++++++++++
 test/LuaJIT-tests/trace/index             |  1 +
 3 files changed, 13 insertions(+), 12 deletions(-)
 delete mode 100644 test/LuaJIT-tests/misc/hook_norecord.lua
 create mode 100644 test/LuaJIT-tests/trace/hook_norecord.lua

diff --git a/test/LuaJIT-tests/misc/hook_norecord.lua b/test/LuaJIT-tests/misc/hook_norecord.lua
deleted file mode 100644
index 8e7cba05..00000000
--- a/test/LuaJIT-tests/misc/hook_norecord.lua
+++ /dev/null
@@ -1,12 +0,0 @@
-
-if not jit or not jit.status or not jit.status() then return end
-
-local called = false
-local function f() local x = "wrong"; called = true end
-jit.off(f)
-debug.sethook(f, "", 5)
-for i=1,1000 do local a,b,c,d,e,f=1,2,3,4,5,6 end
-assert(called)
--- Check that no trace was generated.
-assert(require("jit.util").traceinfo(1) == nil)
-
diff --git a/test/LuaJIT-tests/trace/hook_norecord.lua b/test/LuaJIT-tests/trace/hook_norecord.lua
new file mode 100644
index 00000000..4c39bade
--- /dev/null
+++ b/test/LuaJIT-tests/trace/hook_norecord.lua
@@ -0,0 +1,12 @@
+do --- Abort trace recording on any hook call.
+  local called = false
+  local function f() local x = "wrong"; called = true end
+  jit.off(f)
+  jit.flush()
+  debug.sethook(f, "", 5)
+  for _ = 1, 1000 do local a, b, c, d, e, f = 1, 2, 3, 4, 5, 6 end
+  assert(called)
+  -- Check that no trace was generated.
+  assert(require("jit.util").traceinfo(1) == nil)
+  debug.sethook()
+end
diff --git a/test/LuaJIT-tests/trace/index b/test/LuaJIT-tests/trace/index
index 46c8f5d2..595a71d2 100644
--- a/test/LuaJIT-tests/trace/index
+++ b/test/LuaJIT-tests/trace/index
@@ -3,6 +3,7 @@ exit_growstack.lua
 exit_jfuncf.lua
 gc.lua
 gc64_slot_revival.lua
+hook_norecord.lua
 phi
 snap.lua
 stitch.lua
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 15/36] test: enable <misc/hook_record.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (13 preceding siblings ...)
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 14/36] test: enable <misc/hook_norecord.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-15 13:57   ` Sergey Bronnikov via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 16/36] test: enable <misc/hook_top.lua> " Sergey Kaplun via Tarantool-patches
                   ` (20 subsequent siblings)
  35 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <trace/>
directory, includes it in <index>, and names the subtest.

The test is adjusted to be runable in the test suite by adding the
`jit.flush()` to avoid collisions of traces. Also, the number of
iterations for the compiled loop inside the hook is increased to avoid
hotcount collisions.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/misc/hook_record.lua  | 8 --------
 test/LuaJIT-tests/trace/hook_record.lua | 7 +++++++
 test/LuaJIT-tests/trace/index           | 1 +
 3 files changed, 8 insertions(+), 8 deletions(-)
 delete mode 100644 test/LuaJIT-tests/misc/hook_record.lua
 create mode 100644 test/LuaJIT-tests/trace/hook_record.lua

diff --git a/test/LuaJIT-tests/misc/hook_record.lua b/test/LuaJIT-tests/misc/hook_record.lua
deleted file mode 100644
index 6f1646de..00000000
--- a/test/LuaJIT-tests/misc/hook_record.lua
+++ /dev/null
@@ -1,8 +0,0 @@
-
-if not jit or not jit.status or not jit.status() then return end
-
-debug.sethook(function() for i=1,100 do end end, "", 10)
-for i=1,10 do end
-debug.sethook()
-assert((require("jit.util").traceinfo(1)))
-
diff --git a/test/LuaJIT-tests/trace/hook_record.lua b/test/LuaJIT-tests/trace/hook_record.lua
new file mode 100644
index 00000000..684e1139
--- /dev/null
+++ b/test/LuaJIT-tests/trace/hook_record.lua
@@ -0,0 +1,7 @@
+do --- Recording traces inside the hook.
+  jit.flush()
+  debug.sethook(function() for _ = 1, 1000 do end end, "", 10)
+  for _ = 1, 10 do end
+  debug.sethook()
+  assert((require("jit.util").traceinfo(1)))
+end
diff --git a/test/LuaJIT-tests/trace/index b/test/LuaJIT-tests/trace/index
index 595a71d2..63af7870 100644
--- a/test/LuaJIT-tests/trace/index
+++ b/test/LuaJIT-tests/trace/index
@@ -4,6 +4,7 @@ exit_jfuncf.lua
 gc.lua
 gc64_slot_revival.lua
 hook_norecord.lua
+hook_record.lua
 phi
 snap.lua
 stitch.lua
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 16/36] test: enable <misc/hook_top.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (14 preceding siblings ...)
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 15/36] test: enable <misc/hook_record.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 17/36] test: enable <misc/jit_flush.lua> " Sergey Kaplun via Tarantool-patches
                   ` (19 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <lang/>
directory, includes it in <index>, and names the subtests.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lang/hook_top.lua | 59 +++++++++++++++++++++++++++++
 test/LuaJIT-tests/lang/index        |  1 +
 test/LuaJIT-tests/misc/hook_top.lua | 55 ---------------------------
 3 files changed, 60 insertions(+), 55 deletions(-)
 create mode 100644 test/LuaJIT-tests/lang/hook_top.lua
 delete mode 100644 test/LuaJIT-tests/misc/hook_top.lua

diff --git a/test/LuaJIT-tests/lang/hook_top.lua b/test/LuaJIT-tests/lang/hook_top.lua
new file mode 100644
index 00000000..4cab2559
--- /dev/null
+++ b/test/LuaJIT-tests/lang/hook_top.lua
@@ -0,0 +1,59 @@
+local t = {}
+for i = 1, 26 do t[i] = string.char(96 + i) end
+
+local function tcheck(t1, t2)
+  assert(#t1 == #t2)
+  for i = 1, #t1 do assert(t1[i] == t2[i]) end
+end
+
+local function foo1(...) -- VARG RETM
+  return ...
+end
+
+local function foo2(...) -- VARG UCLO RETM
+  local function dummy() end
+  return ...
+end
+
+local function foo3(...) -- VARG UCLO -> RETM
+  do return ... end
+  local function dummy() end
+end
+
+local function foo4() -- UCLO UCLO RET
+  do
+    local x
+    local function dummy() return x end
+  end
+end
+
+local function foo5(a)
+  assert(a == "bar")
+end
+
+do --- Run hook on each bytecode instruction.
+  local called = false
+  debug.sethook(function() local x = "wrong"; called = true end, "", 1)
+  tcheck(t, {foo1(unpack(t))}) -- CALLM TSETM
+  assert(called)
+  called = false
+  tcheck(t, {foo2(unpack(t))})
+  assert(called)
+  called = false
+  tcheck(t, {foo3(unpack(t))})
+  assert(called)
+  called = false
+  foo4()
+  assert(called)
+  debug.sethook(nil)
+end
+
+do --- Set local variable given to a function inside the hook.
+  debug.sethook(function()
+    local name, val = debug.getlocal(2, 1)
+    assert(name == "a" and val == nil)
+    debug.setlocal(2, 1, "bar")
+    debug.sethook(nil)
+  end, "c")
+  foo5()
+end
diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index ae59bc56..327b40fe 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -10,6 +10,7 @@ dualnum.lua
 for.lua
 hook_active.lua
 hook_line.lua
+hook_top.lua
 length.lua
 lightud.lua
 modulo.lua
diff --git a/test/LuaJIT-tests/misc/hook_top.lua b/test/LuaJIT-tests/misc/hook_top.lua
deleted file mode 100644
index f809fcea..00000000
--- a/test/LuaJIT-tests/misc/hook_top.lua
+++ /dev/null
@@ -1,55 +0,0 @@
-
-local t = {}
-for i=1,26 do t[i] = string.char(96+i) end
-
-local function tcheck(t1, t2)
-  assert(#t1 == #t2)
-  for i=1,#t1 do assert(t1[i] == t2[i]) end
-end
-
-local function foo1(...) -- VARG RETM
-  return ...
-end
-
-local function foo2(...) -- VARG UCLO RETM
-  local function dummy() end
-  return ...
-end
-
-local function foo3(...) -- VARG UCLO -> RETM
-  do return ... end
-  local function dummy() end
-end
-
-local function foo4() -- UCLO UCLO RET
-  do
-    local x
-    local function dummy() return x end
-  end
-end
-
-called = false
-debug.sethook(function() local x = "wrong"; called = true end, "", 1)
-tcheck(t, {foo1(unpack(t))}) -- CALLM TSETM
-assert(called)
-called = false
-tcheck(t, {foo2(unpack(t))})
-assert(called)
-called = false
-tcheck(t, {foo2(unpack(t))})
-assert(called)
-called = false
-foo4()
-assert(called)
-
-debug.sethook(function()
-  local name, val = debug.getlocal(2, 1)
-  assert(name == "a" and val == nil)
-  debug.setlocal(2, 1, "bar")
-  debug.sethook(nil)
-end, "c")
-local function foo5(a)
-  assert(a == "bar")
-end
-foo5()
-
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 17/36] test: enable <misc/jit_flush.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (15 preceding siblings ...)
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 16/36] test: enable <misc/hook_top.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:55 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 18/36] test: remove <misc/loop_unroll.lua> " Sergey Kaplun via Tarantool-patches
                   ` (18 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:55 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <trace/>
directory, includes it in <index>, and names subtests.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/misc/jit_flush.lua  | 50 --------------------
 test/LuaJIT-tests/trace/index         |  1 +
 test/LuaJIT-tests/trace/jit_flush.lua | 66 +++++++++++++++++++++++++++
 3 files changed, 67 insertions(+), 50 deletions(-)
 delete mode 100644 test/LuaJIT-tests/misc/jit_flush.lua
 create mode 100644 test/LuaJIT-tests/trace/jit_flush.lua

diff --git a/test/LuaJIT-tests/misc/jit_flush.lua b/test/LuaJIT-tests/misc/jit_flush.lua
deleted file mode 100644
index ead1e4e9..00000000
--- a/test/LuaJIT-tests/misc/jit_flush.lua
+++ /dev/null
@@ -1,50 +0,0 @@
-
-if not jit or not jit.status or not jit.status() then return end
-
-for i=1,100 do
-  if i==50 then jit.flush(2) end
-  for j=1,100 do end
-  for j=1,100 do end
-end
-
-jit.flush()
-
-local function f() for i=1,100 do end end
-for i=1,100 do local x = gcinfo(); f() end
-
-jit.flush()
-
-local function fib(n)
-  if n < 2 then return 1 end
-  return fib(n-2) + fib(n-1)
-end
-
-fib(11)
-
-jit.flush()
-
-local names = {}
-for i=1,100 do names[i] = i end
-
-function f()
-  for k,v in ipairs(names) do end
-end
-
-f()
-
-for i=1,2 do
-  f()
-  f()
-  jit.flush()
-end
-
-jit.flush()
-
-jit.flush(1) -- ignored
-jit.flush(2) -- ignored
-for i=1,1e7 do end -- causes trace #1
-
-jit.flush(2) -- ignored
-jit.flush(1) -- ok
-jit.flush(1) -- crashes
-
diff --git a/test/LuaJIT-tests/trace/index b/test/LuaJIT-tests/trace/index
index 63af7870..3ab095a7 100644
--- a/test/LuaJIT-tests/trace/index
+++ b/test/LuaJIT-tests/trace/index
@@ -5,6 +5,7 @@ gc.lua
 gc64_slot_revival.lua
 hook_norecord.lua
 hook_record.lua
+jit_flush.lua
 phi
 snap.lua
 stitch.lua
diff --git a/test/LuaJIT-tests/trace/jit_flush.lua b/test/LuaJIT-tests/trace/jit_flush.lua
new file mode 100644
index 00000000..a995921e
--- /dev/null
+++ b/test/LuaJIT-tests/trace/jit_flush.lua
@@ -0,0 +1,66 @@
+do --- Flushing a trace that is a link for another trace.
+  -- TRACE 3 stop -> 2
+  jit.flush()
+  for i = 1, 100 do
+    if i == 50 then jit.flush(2) end
+    for _ = 1, 100 do end
+    for _ = 1, 100 do end
+  end
+
+  jit.flush()
+end
+
+do --- Flushing stitched trace.
+  jit.flush()
+  local function f() for _ = 1, 100 do end end
+  for _ = 1, 100 do local x = gcinfo(); f() end
+
+  jit.flush()
+end
+
+do --- Flushing trace with up-recursion.
+  jit.flush()
+
+  local function fib(n)
+    if n < 2 then return 1 end
+    return fib(n - 2) + fib(n - 1)
+  end
+
+  fib(11)
+
+  jit.flush()
+end
+
+do --- Flush in the loop.
+  jit.flush()
+
+  local names = {}
+  for i = 1, 100 do names[i] = i end
+
+  local function f()
+    for k, v in ipairs(names) do end
+  end
+
+  f()
+
+  for _ = 1, 2 do
+    f()
+    f()
+    jit.flush()
+  end
+
+  jit.flush()
+end
+
+
+do --- Flushes of not existed traces.
+  jit.flush()
+
+  jit.flush(1) -- ignored
+  jit.flush(2) -- ignored
+  for _ = 1, 1e7 do end -- causes trace #1
+
+  jit.flush(2) -- ignored
+  jit.flush(1) -- ok
+  jit.flush(1) -- crashes
+end
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 18/36] test: remove <misc/loop_unroll.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (16 preceding siblings ...)
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 17/36] test: enable <misc/jit_flush.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 19/36] test: enable <misc/parse_comp.lua> " Sergey Kaplun via Tarantool-patches
                   ` (17 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch removes the aforementioned test since it is part of the
<opt/loop/unroll.lua> test.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/misc/loop_unroll.lua | 35 --------------------------
 1 file changed, 35 deletions(-)
 delete mode 100644 test/LuaJIT-tests/misc/loop_unroll.lua

diff --git a/test/LuaJIT-tests/misc/loop_unroll.lua b/test/LuaJIT-tests/misc/loop_unroll.lua
deleted file mode 100644
index 1700fac9..00000000
--- a/test/LuaJIT-tests/misc/loop_unroll.lua
+++ /dev/null
@@ -1,35 +0,0 @@
-
--- type instability on loop unroll -> record unroll
-do
-  local flip = true
-  for i=1,100 do flip = not flip end
-  assert(flip == true)
-end
-
-do
-  local t = {}
-  local a, b, c = 1, "", t
-  for i=1,100 do a,b,c=b,c,a end
-  assert(c == 1 and a == "" and b == t)
-end
-
--- FAILFOLD on loop unroll -> LJ_TRERR_GFAIL -> record unroll
-do
-  local t = { 1, 2 }
-  local k = 2
-  local x = 0
-  for i=1,200 do
-    x = x + t[k]
-    k = k == 1 and 2 or 1
-  end
-  assert(x == 300 and k == 2)
-end
-
--- Unroll if inner loop aborts.
-local j = 0
-for i = 1,100 do
-  repeat
-    j = j+1
-  until true
-end
-
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 19/36] test: enable <misc/parse_comp.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (17 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 18/36] test: remove <misc/loop_unroll.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 20/36] test: enable <misc/parse_esc.lua> " Sergey Kaplun via Tarantool-patches
                   ` (16 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <lang/>
directory, includes it in <index>, and names the subtests.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lang/index          |  1 +
 test/LuaJIT-tests/lang/parse_comp.lua | 12 ++++++++++++
 test/LuaJIT-tests/misc/parse_comp.lua | 13 -------------
 3 files changed, 13 insertions(+), 13 deletions(-)
 create mode 100644 test/LuaJIT-tests/lang/parse_comp.lua
 delete mode 100644 test/LuaJIT-tests/misc/parse_comp.lua

diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 327b40fe..371a5768 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -17,6 +17,7 @@ modulo.lua
 concat.lua
 self.lua
 table.lua
+parse_comp.lua
 upvalue
 tail_recursion.lua
 vararg_jit.lua
diff --git a/test/LuaJIT-tests/lang/parse_comp.lua b/test/LuaJIT-tests/lang/parse_comp.lua
new file mode 100644
index 00000000..ee6a74de
--- /dev/null
+++ b/test/LuaJIT-tests/lang/parse_comp.lua
@@ -0,0 +1,12 @@
+do --- Parse inline comparisions expressions, base.
+  local f = {{n = 5}}
+  local a = f[1].n
+  assert(1 < a)
+  assert(1 < (f[1].n))
+  assert(1 < f[1].n)
+end
+
+do --- Parse inline comparisions expressions with not.
+  local tt = { a = 1 }
+  assert(not(0 >= tt.a))
+end
diff --git a/test/LuaJIT-tests/misc/parse_comp.lua b/test/LuaJIT-tests/misc/parse_comp.lua
deleted file mode 100644
index 5e1948da..00000000
--- a/test/LuaJIT-tests/misc/parse_comp.lua
+++ /dev/null
@@ -1,13 +0,0 @@
-
-do
-  local f = {{n=5}}
-  local a = f[1].n
-  assert(1 < a)
-  assert(1 < (f[1].n))
-  assert(1 < f[1].n)
-end
-
-do
-  tt = { a = 1 }
-  assert(not(0 >= tt.a))
-end
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 20/36] test: enable <misc/parse_esc.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (18 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 19/36] test: enable <misc/parse_comp.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 21/36] test: enable <misc/parse_misc.lua> " Sergey Kaplun via Tarantool-patches
                   ` (15 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <lang/>
directory, includes it in <index>, and names the subtest.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lang/index         |  1 +
 test/LuaJIT-tests/lang/parse_esc.lua | 10 ++++++++++
 test/LuaJIT-tests/misc/parse_esc.lua |  7 -------
 3 files changed, 11 insertions(+), 7 deletions(-)
 create mode 100644 test/LuaJIT-tests/lang/parse_esc.lua
 delete mode 100644 test/LuaJIT-tests/misc/parse_esc.lua

diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 371a5768..0d1175a8 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -18,6 +18,7 @@ concat.lua
 self.lua
 table.lua
 parse_comp.lua
+parse_esc.lua
 upvalue
 tail_recursion.lua
 vararg_jit.lua
diff --git a/test/LuaJIT-tests/lang/parse_esc.lua b/test/LuaJIT-tests/lang/parse_esc.lua
new file mode 100644
index 00000000..c14d347a
--- /dev/null
+++ b/test/LuaJIT-tests/lang/parse_esc.lua
@@ -0,0 +1,10 @@
+do --- Base parsing of escape sequences.
+  assert("\79\126" == "O~")
+  assert("\x4f\x7e" == "O~")
+  assert(loadstring[[return "\xxx"]] == nil)
+  assert(loadstring[[return "\xxx"]] == nil)
+
+  assert(assert(loadstring[[return "abc   \z
+
+     def"]])() == "abc   def")
+end
diff --git a/test/LuaJIT-tests/misc/parse_esc.lua b/test/LuaJIT-tests/misc/parse_esc.lua
deleted file mode 100644
index 4bcce0e8..00000000
--- a/test/LuaJIT-tests/misc/parse_esc.lua
+++ /dev/null
@@ -1,7 +0,0 @@
-assert("\79\126" == "O~")
-assert("\x4f\x7e" == "O~")
-assert(loadstring[[return "\xxx"]] == nil)
-assert(loadstring[[return "\xxx"]] == nil)
-assert(assert(loadstring[[return "abc   \z
-
-   def"]])() == "abc   def")
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 21/36] test: enable <misc/parse_misc.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (19 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 20/36] test: enable <misc/parse_esc.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 22/36] test: enable <misc/phi_conv.lua> " Sergey Kaplun via Tarantool-patches
                   ` (14 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <lang/>
directory, includes it in <index>, names the subtests, and adds checks
for the Lua version.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lang/index          |  1 +
 test/LuaJIT-tests/lang/parse_misc.lua | 31 +++++++++++++++++++++++++++
 test/LuaJIT-tests/misc/parse_misc.lua | 31 ---------------------------
 3 files changed, 32 insertions(+), 31 deletions(-)
 create mode 100644 test/LuaJIT-tests/lang/parse_misc.lua
 delete mode 100644 test/LuaJIT-tests/misc/parse_misc.lua

diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 0d1175a8..726c8d16 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -19,6 +19,7 @@ self.lua
 table.lua
 parse_comp.lua
 parse_esc.lua
+parse_misc.lua
 upvalue
 tail_recursion.lua
 vararg_jit.lua
diff --git a/test/LuaJIT-tests/lang/parse_misc.lua b/test/LuaJIT-tests/lang/parse_misc.lua
new file mode 100644
index 00000000..c95758a3
--- /dev/null
+++ b/test/LuaJIT-tests/lang/parse_misc.lua
@@ -0,0 +1,31 @@
+do --- Ambiguous syntax: function call vs. new statement. +lua==5.2
+  assert(assert(loadstring([[
+    local function f() return 99 end
+    return f
+    ()
+  ]]))() == 99)
+end
+
+do --- Ambiguous syntax: function call vs. new statement. +lua<5.2
+  assert(loadstring([[
+    local function f() return 99 end
+    return f
+    ()
+  ]]) == nil)
+end
+
+do --- UTF-8 identifiers.
+  assert(loadstring([[
+  local ä = 1
+  local aäa = 2
+  local äöü·€晶 = 3
+
+  assert(ä == 1)
+  assert(aäa == 2)
+  assert(äöü·€晶 == 3)
+
+  assert(#"ä" == 2)
+  assert(#"aäa" == 4)
+  assert(#"äöü·€晶" == 14)
+  ]]))()
+end
diff --git a/test/LuaJIT-tests/misc/parse_misc.lua b/test/LuaJIT-tests/misc/parse_misc.lua
deleted file mode 100644
index 8031ec17..00000000
--- a/test/LuaJIT-tests/misc/parse_misc.lua
+++ /dev/null
@@ -1,31 +0,0 @@
-
--- Ambiguous syntax: function call vs. new statement.
-if os.getenv("LUA52") then
-  assert(assert(loadstring([[
-local function f() return 99 end
-return f
-()
-]]))() == 99)
-else
-  assert(loadstring([[
-local function f() return 99 end
-return f
-()
-]]) == nil)
-end
-
--- UTF-8 identifiers.
-assert(loadstring([[
-local ä = 1
-local aäa = 2
-local äöü·€晶 = 3
-
-assert(ä == 1)
-assert(aäa == 2)
-assert(äöü·€晶 == 3)
-
-assert(#"ä" == 2)
-assert(#"aäa" == 4)
-assert(#"äöü·€晶" == 14)
-]]))()
-
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 22/36] test: enable <misc/phi_conv.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (20 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 21/36] test: enable <misc/parse_misc.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 23/36] test: enable <misc/recurse_deep.lua> " Sergey Kaplun via Tarantool-patches
                   ` (13 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the
<trace/phi/> directory, includes it in <index>, and names the subtests.

Part of tarantool/tarantool#9398
---
 .../{misc/phi_conv.lua => trace/phi/conv.lua} | 35 ++++++++++---------
 test/LuaJIT-tests/trace/phi/index             |  1 +
 2 files changed, 20 insertions(+), 16 deletions(-)
 rename test/LuaJIT-tests/{misc/phi_conv.lua => trace/phi/conv.lua} (67%)

diff --git a/test/LuaJIT-tests/misc/phi_conv.lua b/test/LuaJIT-tests/trace/phi/conv.lua
similarity index 67%
rename from test/LuaJIT-tests/misc/phi_conv.lua
rename to test/LuaJIT-tests/trace/phi/conv.lua
index 8d7bea5f..7f46d445 100644
--- a/test/LuaJIT-tests/misc/phi_conv.lua
+++ b/test/LuaJIT-tests/trace/phi/conv.lua
@@ -1,18 +1,5 @@
-
 local bit = require("bit")
 
-local Rm = {}
-for i=0,16 do Rm[i] = 0 end
-
-for k=1,10 do
-  local seed = 1
-  for i=16,0,-1 do
-    seed = bit.band(seed*9069, 0x7fffffff)
-    Rm[i] = seed
-  end
-  assert(seed == 1952688301)
-end
-
 local retindex = 0
 local retdata = { 3, 1, 1, 1, 0, 3, 1, 0, 0, 2, 0, 2, 0, 0, 3, 1, 1, 1, 1 }
 
@@ -42,12 +29,28 @@ local function decodeCode()
 end
 
 local function test()
-  for i = 1, 6 do
+  for _ = 1, 6 do
     decodeCode()
   end
 end
 
-if jit and jit.status and jit.status() then jit.opt.start("hotloop=1") end
+do --- PHI for CONV num.int before ASTORE.
+  local Rm = {}
+  for i = 0, 16 do Rm[i] = 0 end
 
-test()
+  for _ = 1,10 do
+    local seed = 1
+    for i = 16, 0, -1 do
+      seed = bit.band(seed*9069, 0x7fffffff)
+      Rm[i] = seed
+    end
+    assert(seed == 1952688301)
+  end
+end
+
+do --- PHI for CONV num.int of lookup.
+  jit.opt.start("hotloop=1")
+  test()
+  jit.opt.start("hotloop=56")
+end
 
diff --git a/test/LuaJIT-tests/trace/phi/index b/test/LuaJIT-tests/trace/phi/index
index 74a07333..a72d37a0 100644
--- a/test/LuaJIT-tests/trace/phi/index
+++ b/test/LuaJIT-tests/trace/phi/index
@@ -1,3 +1,4 @@
 copyspill.lua
+conv.lua
 ref.lua
 rotate.lua
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 23/36] test: enable <misc/recurse_deep.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (21 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 22/36] test: enable <misc/phi_conv.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 24/36] test: remove <misc/recurse_tail.lua> " Sergey Kaplun via Tarantool-patches
                   ` (12 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <lang/>
directory (with slightly renaming to be consistent with other names),
includes it in <index>, and names the subtests.

Part of tarantool/tarantool#9398
---
 .../{misc/recurse_deep.lua => lang/deep_recursion.lua}    | 8 +++-----
 test/LuaJIT-tests/lang/index                              | 1 +
 2 files changed, 4 insertions(+), 5 deletions(-)
 rename test/LuaJIT-tests/{misc/recurse_deep.lua => lang/deep_recursion.lua} (84%)

diff --git a/test/LuaJIT-tests/misc/recurse_deep.lua b/test/LuaJIT-tests/lang/deep_recursion.lua
similarity index 84%
rename from test/LuaJIT-tests/misc/recurse_deep.lua
rename to test/LuaJIT-tests/lang/deep_recursion.lua
index 9b9af295..732dd529 100644
--- a/test/LuaJIT-tests/misc/recurse_deep.lua
+++ b/test/LuaJIT-tests/lang/deep_recursion.lua
@@ -1,5 +1,4 @@
-
-do
+do --- Recursion sum.
   local function sum(n)
     if n == 1 then return 1 end
     return n + sum(n-1)
@@ -7,7 +6,7 @@ do
   assert(sum(200) == 20100)
 end
 
-do
+do --- Recursion wiht pcall.
   local pcall = pcall
   local tr1
   local x = 0
@@ -19,11 +18,10 @@ do
   assert(tr1(200) == true and x == 200)
 end
 
-do
+do --- Recursion fibonacci.
   local function fib(n)
     if n < 2 then return 1 end
     return fib(n-2) + fib(n-1)
   end
   assert(fib(15) == 987)
 end
-
diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 726c8d16..5c9e7ea4 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -6,6 +6,7 @@ catch_wrap.lua
 compare.lua
 compare_nan.lua
 constant
+deep_recursion.lua
 dualnum.lua
 for.lua
 hook_active.lua
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 24/36] test: remove <misc/recurse_tail.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (22 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 23/36] test: enable <misc/recurse_deep.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 25/36] test: enable <misc/stack_gc.lua> " Sergey Kaplun via Tarantool-patches
                   ` (11 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch removes the aforementioned test since it is part of the
<lang/tail_recursion.lua> test.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/misc/recurse_tail.lua | 22 ----------------------
 1 file changed, 22 deletions(-)
 delete mode 100644 test/LuaJIT-tests/misc/recurse_tail.lua

diff --git a/test/LuaJIT-tests/misc/recurse_tail.lua b/test/LuaJIT-tests/misc/recurse_tail.lua
deleted file mode 100644
index ef764432..00000000
--- a/test/LuaJIT-tests/misc/recurse_tail.lua
+++ /dev/null
@@ -1,22 +0,0 @@
-
-do
-  local tr1
-  function tr1(n)
-    if n <= 0 then return 0 end
-    return tr1(n-1)
-  end
-  assert(tr1(200) == 0)
-end
-
-do
-  local tr1, tr2
-  function tr1(n)
-    if n <= 0 then return 0 end
-    return tr2(n-1)
-  end
-  function tr2(n)
-    return tr1(n)
-  end
-  assert(tr2(200) == 0)
-end
-
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 25/36] test: enable <misc/stack_gc.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (23 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 24/36] test: remove <misc/recurse_tail.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 26/36] test: enable <misc/stack_purge.lua> " Sergey Kaplun via Tarantool-patches
                   ` (10 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <lang/>
directory (with slightly renaming to be consistent with other names),
includes it in <index>, and names the subtests.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/{misc/stack_gc.lua => lang/gc_stack.lua} | 6 ++----
 test/LuaJIT-tests/lang/index                               | 1 +
 2 files changed, 3 insertions(+), 4 deletions(-)
 rename test/LuaJIT-tests/{misc/stack_gc.lua => lang/gc_stack.lua} (76%)

diff --git a/test/LuaJIT-tests/misc/stack_gc.lua b/test/LuaJIT-tests/lang/gc_stack.lua
similarity index 76%
rename from test/LuaJIT-tests/misc/stack_gc.lua
rename to test/LuaJIT-tests/lang/gc_stack.lua
index 656a06a0..8aee57e3 100644
--- a/test/LuaJIT-tests/misc/stack_gc.lua
+++ b/test/LuaJIT-tests/lang/gc_stack.lua
@@ -1,6 +1,5 @@
-
-do
-  local t = setmetatable({}, { __index=function(t, k)
+do --- Marking sparse stack.
+  local t = setmetatable({}, { __index = function(t, k)
     k = k - 1
     if k == 0 then
       collectgarbage() -- Mark stack, including holes.
@@ -12,4 +11,3 @@ do
   end})
   local x = t[50]
 end
-
diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 5c9e7ea4..b262c555 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -26,6 +26,7 @@ tail_recursion.lua
 vararg_jit.lua
 gc.lua
 gc_debug.lua
+gc_stack.lua
 gc_step.lua
 goto.lua +goto
 meta
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 26/36] test: enable <misc/stack_purge.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (24 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 25/36] test: enable <misc/stack_gc.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 27/36] test: enable <misc/stackov.lua> " Sergey Kaplun via Tarantool-patches
                   ` (9 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <trace/>
directory, includes it in <index>, and names the subtest.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/trace/index                     |  1 +
 test/LuaJIT-tests/{misc => trace}/stack_purge.lua | 14 +++++++-------
 2 files changed, 8 insertions(+), 7 deletions(-)
 rename test/LuaJIT-tests/{misc => trace}/stack_purge.lua (74%)

diff --git a/test/LuaJIT-tests/trace/index b/test/LuaJIT-tests/trace/index
index 3ab095a7..4826f429 100644
--- a/test/LuaJIT-tests/trace/index
+++ b/test/LuaJIT-tests/trace/index
@@ -8,4 +8,5 @@ hook_record.lua
 jit_flush.lua
 phi
 snap.lua
+stack_purge.lua
 stitch.lua
diff --git a/test/LuaJIT-tests/misc/stack_purge.lua b/test/LuaJIT-tests/trace/stack_purge.lua
similarity index 74%
rename from test/LuaJIT-tests/misc/stack_purge.lua
rename to test/LuaJIT-tests/trace/stack_purge.lua
index bfaee0f3..e4108b20 100644
--- a/test/LuaJIT-tests/misc/stack_purge.lua
+++ b/test/LuaJIT-tests/trace/stack_purge.lua
@@ -1,4 +1,3 @@
-
 -- Must preserve the modified function slot in the RET snapshot.
 local function a()
   local _,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_
@@ -12,14 +11,15 @@ local function b()
 end
 
 local function c()
-  for j=1,10 do
-    for i=1,50 do b() b() b() end
+  for _ = 1, 10 do
+    for _ = 1, 50 do b() b() b() end
     collectgarbage()
     local t = {}
-    for i=1,50 do t = {t} end
+    for _ = 1, 50 do t = {t} end
   end
 end
 
-jit.off(c)
-c()
-
+do --- Don't purge the function to return from SNAP.
+  jit.off(c)
+  c()
+end
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 27/36] test: enable <misc/stackov.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (25 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 26/36] test: enable <misc/stack_purge.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 28/36] test: enable <misc/stackovc.lua> " Sergey Kaplun via Tarantool-patches
                   ` (8 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <lang/>
directory, includes it in <index>, names the subtests, and adds testing
of the error message for all non-tail call cases.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lang/index       |  1 +
 test/LuaJIT-tests/lang/stackov.lua | 48 ++++++++++++++++++++++++++++++
 test/LuaJIT-tests/misc/stackov.lua | 40 -------------------------
 3 files changed, 49 insertions(+), 40 deletions(-)
 create mode 100644 test/LuaJIT-tests/lang/stackov.lua
 delete mode 100644 test/LuaJIT-tests/misc/stackov.lua

diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index b262c555..fa6db3c3 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -17,6 +17,7 @@ lightud.lua
 modulo.lua
 concat.lua
 self.lua
+stackov.lua
 table.lua
 parse_comp.lua
 parse_esc.lua
diff --git a/test/LuaJIT-tests/lang/stackov.lua b/test/LuaJIT-tests/lang/stackov.lua
new file mode 100644
index 00000000..21ae40b6
--- /dev/null
+++ b/test/LuaJIT-tests/lang/stackov.lua
@@ -0,0 +1,48 @@
+local function f()
+  f()
+end
+
+local function g(i)
+  g(i)
+end
+
+local function vtail(...)
+  return vtail(1, ...)
+end
+
+local function vcall(...)
+  vcall(1, ...)
+end
+
+local function test_error_msg(func, s)
+  local first = string.match(s, "[^\n]+")
+  local line = debug.getinfo(func, "S").linedefined + 1
+  assert(string.match(first, ":" .. line .. ": stack overflow$"))
+
+  local n = 1
+  for _ in string.gmatch(s, "\n") do n = n + 1 end
+  assert(n == 1 + 1 + 11 + 1 + 10)
+end
+
+do --- Base test.
+  local err, s = xpcall(f, debug.traceback)
+  assert(err == false)
+  test_error_msg(f, s)
+end
+
+do --- Stack overflow with non-empty arg list.
+  local err, s = xpcall(g, debug.traceback, 1)
+  assert(err == false)
+  test_error_msg(g, s)
+end
+
+do --- Vararg tail call with non-empty arg list. +slow
+  local err, s = xpcall(vtail, debug.traceback, 1)
+  assert(err == false)
+end
+
+do --- Vararg non-tail call.
+  local err, s = xpcall(vcall, debug.traceback, 1)
+  assert(err == false)
+  test_error_msg(vcall, s)
+end
diff --git a/test/LuaJIT-tests/misc/stackov.lua b/test/LuaJIT-tests/misc/stackov.lua
deleted file mode 100644
index ef105af6..00000000
--- a/test/LuaJIT-tests/misc/stackov.lua
+++ /dev/null
@@ -1,40 +0,0 @@
-
-local function f()
-  f()
-end
-
-local err, s = xpcall(f, debug.traceback)
-assert(err == false)
-
-local first = string.match(s, "[^\n]+")
-local line = debug.getinfo(f, "S").linedefined+1
-assert(string.match(first, ":"..line..": stack overflow$"))
-
-local n = 1
-for _ in string.gmatch(s, "\n") do n = n + 1 end
-assert(n == 1+1+11+1+10)
-
-local function g(i)
-  g(i)
-end
-
-local err, s = xpcall(g, debug.traceback, 1)
-assert(err == false)
-
---[[
--- too slow
-local function vtail(...)
-  return vtail(1, ...)
-end
-
-local err, s = xpcall(vtail, debug.traceback, 1)
-assert(err == false)
---]]
-
-local function vcall(...)
-  vcall(1, ...)
-end
-
-local err, s = xpcall(vcall, debug.traceback, 1)
-assert(err == false)
-
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 28/36] test: enable <misc/stackovc.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (26 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 27/36] test: enable <misc/stackov.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 29/36] test: enable <misc/tcall_base.lua> " Sergey Kaplun via Tarantool-patches
                   ` (7 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <lang/>
directory (with slightly renaming to be consistent with other names),
includes it in <index>, and names the subtest.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lang/index         |  1 +
 test/LuaJIT-tests/lang/stackov_c.lua | 12 ++++++++++++
 test/LuaJIT-tests/misc/stackovc.lua  |  4 ----
 3 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 test/LuaJIT-tests/lang/stackov_c.lua
 delete mode 100644 test/LuaJIT-tests/misc/stackovc.lua

diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index fa6db3c3..8da748d0 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -18,6 +18,7 @@ modulo.lua
 concat.lua
 self.lua
 stackov.lua
+stackov_c.lua
 table.lua
 parse_comp.lua
 parse_esc.lua
diff --git a/test/LuaJIT-tests/lang/stackov_c.lua b/test/LuaJIT-tests/lang/stackov_c.lua
new file mode 100644
index 00000000..cea1a09e
--- /dev/null
+++ b/test/LuaJIT-tests/lang/stackov_c.lua
@@ -0,0 +1,12 @@
+do --- Too many results to unpack.
+  local j = 1e4
+  local co = coroutine.create(function()
+    local t = {}
+    for i = 1, j do
+      t[i] = i
+    end
+    return unpack(t)
+  end)
+  local ok, err = coroutine.resume(co)
+  assert(not ok and string.find(err, "unpack"))
+end
diff --git a/test/LuaJIT-tests/misc/stackovc.lua b/test/LuaJIT-tests/misc/stackovc.lua
deleted file mode 100644
index c00bcbd8..00000000
--- a/test/LuaJIT-tests/misc/stackovc.lua
+++ /dev/null
@@ -1,4 +0,0 @@
-local j = 1e4
-local co = coroutine.create(function() t = {} for i = 1, j do t[i] = i end return unpack(t) end)
-local ok, err = coroutine.resume(co)
-assert(not ok and string.find(err, "unpack"))
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 29/36] test: enable <misc/tcall_base.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (27 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 28/36] test: enable <misc/stackovc.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 30/36] test: enable <misc/tcall_loop.lua> " Sergey Kaplun via Tarantool-patches
                   ` (6 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <trace/>
directory, includes it in <index>, and names the subtest.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/trace/index                    |  1 +
 test/LuaJIT-tests/{misc => trace}/tcall_base.lua | 12 ++++++------
 2 files changed, 7 insertions(+), 6 deletions(-)
 rename test/LuaJIT-tests/{misc => trace}/tcall_base.lua (62%)

diff --git a/test/LuaJIT-tests/trace/index b/test/LuaJIT-tests/trace/index
index 4826f429..9de3b478 100644
--- a/test/LuaJIT-tests/trace/index
+++ b/test/LuaJIT-tests/trace/index
@@ -10,3 +10,4 @@ phi
 snap.lua
 stack_purge.lua
 stitch.lua
+tcall_base.lua
diff --git a/test/LuaJIT-tests/misc/tcall_base.lua b/test/LuaJIT-tests/trace/tcall_base.lua
similarity index 62%
rename from test/LuaJIT-tests/misc/tcall_base.lua
rename to test/LuaJIT-tests/trace/tcall_base.lua
index c6c4ae1a..b048db19 100644
--- a/test/LuaJIT-tests/misc/tcall_base.lua
+++ b/test/LuaJIT-tests/trace/tcall_base.lua
@@ -1,4 +1,3 @@
-
 local r = 0
 local function g()
   r = r + 1
@@ -6,7 +5,7 @@ local function g()
 end
 
 local function f()
-  for j=1,20 do
+  for j = 1, 20 do
     if j > 19 then
       return g() -- Tailcall at base.
       -- Let this link to the already compiled loop in g().
@@ -14,7 +13,8 @@ local function f()
   end
 end
 
-g() -- Compile this loop first.
-for i=1,50 do f() end
-assert(r == 51)
-
+do --- Recording tailcall at base.
+  g() -- Compile this loop first.
+  for _ = 1, 50 do f() end
+  assert(r == 51)
+end
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 30/36] test: enable <misc/tcall_loop.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (28 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 29/36] test: enable <misc/tcall_base.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 31/36] test: enable <misc/tonumber_scan.lua> " Sergey Kaplun via Tarantool-patches
                   ` (5 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <trace/>
directory, includes it in <index>, and names the subtest.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/misc/tcall_loop.lua  |  8 --------
 test/LuaJIT-tests/trace/index          |  1 +
 test/LuaJIT-tests/trace/tcall_loop.lua | 10 ++++++++++
 3 files changed, 11 insertions(+), 8 deletions(-)
 delete mode 100644 test/LuaJIT-tests/misc/tcall_loop.lua
 create mode 100644 test/LuaJIT-tests/trace/tcall_loop.lua

diff --git a/test/LuaJIT-tests/misc/tcall_loop.lua b/test/LuaJIT-tests/misc/tcall_loop.lua
deleted file mode 100644
index d3c6f1a6..00000000
--- a/test/LuaJIT-tests/misc/tcall_loop.lua
+++ /dev/null
@@ -1,8 +0,0 @@
-local function f(i)
-  if i > 0 then return f(i-1) end
-  return 1
-end
-
-local x = 0
-for i=1,100 do x = x + f(1000) end
-assert(x == 100)
diff --git a/test/LuaJIT-tests/trace/index b/test/LuaJIT-tests/trace/index
index 9de3b478..1b8fb8f4 100644
--- a/test/LuaJIT-tests/trace/index
+++ b/test/LuaJIT-tests/trace/index
@@ -11,3 +11,4 @@ snap.lua
 stack_purge.lua
 stitch.lua
 tcall_base.lua
+tcall_loop.lua
diff --git a/test/LuaJIT-tests/trace/tcall_loop.lua b/test/LuaJIT-tests/trace/tcall_loop.lua
new file mode 100644
index 00000000..7d872644
--- /dev/null
+++ b/test/LuaJIT-tests/trace/tcall_loop.lua
@@ -0,0 +1,10 @@
+local function f(i)
+  if i > 0 then return f(i - 1) end
+  return 1
+end
+
+do --- Recording tailcall with the loop for the tail recursion.
+  local x = 0
+  for _ = 1, 100 do x = x + f(1000) end
+  assert(x == 100)
+end
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 31/36] test: enable <misc/tonumber_scan.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (29 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 30/36] test: enable <misc/tcall_loop.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 32/36] test: remove <misc/uclo.lua> " Sergey Kaplun via Tarantool-patches
                   ` (4 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the
<lib/base> directory, includes it in <index>, and names the subtest.

Also, the NaN checks are skipped for parsing via `strtod()`, since
LuaJIT uses canonicalized NaNs, which are equal to -NaN
(0xfff8000000000000).

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lib/base/index              |  1 +
 .../{misc => lib/base}/tonumber_scan.lua      | 58 ++++++++++++-------
 2 files changed, 37 insertions(+), 22 deletions(-)
 rename test/LuaJIT-tests/{misc => lib/base}/tonumber_scan.lua (93%)

diff --git a/test/LuaJIT-tests/lib/base/index b/test/LuaJIT-tests/lib/base/index
index 942c53c0..bef5dcb4 100644
--- a/test/LuaJIT-tests/lib/base/index
+++ b/test/LuaJIT-tests/lib/base/index
@@ -8,4 +8,5 @@ pairs.lua
 pcall_jit.lua
 select.lua
 tonumber_tostring.lua
+tonumber_scan.lua +ffi
 xpcall_jit.lua +compat5.2
diff --git a/test/LuaJIT-tests/misc/tonumber_scan.lua b/test/LuaJIT-tests/lib/base/tonumber_scan.lua
similarity index 93%
rename from test/LuaJIT-tests/misc/tonumber_scan.lua
rename to test/LuaJIT-tests/lib/base/tonumber_scan.lua
index 78e1ca3e..e2dcd4d0 100644
--- a/test/LuaJIT-tests/misc/tonumber_scan.lua
+++ b/test/LuaJIT-tests/lib/base/tonumber_scan.lua
@@ -150,31 +150,45 @@ local function tohex64(x)
   return "0x"..bit.tohex(tonumber(x/2LL^32))..bit.tohex(tonumber(x%2LL^32)).."ULL"
 end
 
-local conv = tonumber
+local e = ffi.new("char *[1]")
+local u = ffi.new("union { double d; uint64_t x; }")
 
-if arg and arg[1] == "strtod" then
-  local e = ffi.new("char *[1]")
-  function conv(s)
-    local d = ffi.C.strtod(s, e)
-    return (e[0][0] == 0 and #s ~= 0) and d or nil
+local function test_conv(conv, skip_nan)
+  for i = 1, #t, 2 do
+    local y, s = t[i], t[i + 1]
+    if s:lower():match('nan') and skip_nan then
+      -- LuaJIT uses canonicalized NaNs.
+      -- -NaN = 0xfff8000000000000.
+      -- Hence, `strtod()` yields a different value here.
+      goto continue
+    end
+    local d = conv(s)
+    local ok
+    if d == nil then
+      ok = (y == false)
+    else
+      u.d = d
+      ok = (y == u.x)
+    end
+    if not ok then
+      error(string.format(
+        "FAIL: '%s'\n\tGOT: %s\n\tOK:  %s",
+        s,
+        d and tohex64(u.x) or "nil",
+        y and tohex64(y) or "nil", "\n\n"
+      ))
+    end
+    ::continue::
   end
 end
 
-local u = ffi.new("union { double d; uint64_t x; }")
-
-for i=1,#t,2 do
-  local y, s = t[i], t[i+1]
-  local d = conv(s)
-  local ok
-  if d == nil then
-    ok = (y == false)
-  else
-    u.d = d
-    ok = (y == u.x)
-  end
-  if not ok then
-    io.write('FAIL: "', s, '"\n GOT: ', d and tohex64(u.x) or "nil", "   OK: ", y and tohex64(y) or "nil", "\n\n")
---      print("  "..tohex64(u.x)..", \""..s.."\",")
-  end
+do --- tonumber parsing
+  test_conv(tonumber)
 end
 
+do --- strtod parsing
+  test_conv(function(s)
+    local d = ffi.C.strtod(s, e)
+    return (e[0][0] == 0 and #s ~= 0) and d or nil
+  end, true)
+end
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 32/36] test: remove <misc/uclo.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (30 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 31/36] test: enable <misc/tonumber_scan.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 33/36] test: enable <misc/unordered_jit.lua> " Sergey Kaplun via Tarantool-patches
                   ` (3 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch removes the aforementioned test since it is part of the
<lang/upvalue/closure.lua> test.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/misc/uclo.lua | 91 ---------------------------------
 1 file changed, 91 deletions(-)
 delete mode 100644 test/LuaJIT-tests/misc/uclo.lua

diff --git a/test/LuaJIT-tests/misc/uclo.lua b/test/LuaJIT-tests/misc/uclo.lua
deleted file mode 100644
index bd9bd242..00000000
--- a/test/LuaJIT-tests/misc/uclo.lua
+++ /dev/null
@@ -1,91 +0,0 @@
-
-local function test_for()
-  local z1, z2
-  for i=1,10 do
-    local function f() return i end
-    if z1 then z2 = f else z1 = f end
-  end
-  assert(z1() == 1)
-  assert(z2() == 10)
-end
-
-local function test_while()
-  local z1, z2
-  local i = 1
-  while i <= 10 do
-    local j = i
-    local function f() return j end
-    if z1 then z2 = f else z1 = f end
-    i = i + 1
-  end
-  assert(z1() == 1)
-  assert(z2() == 10)
-end
-
-local function test_repeat()
-  local z1, z2
-  local i = 1
-  repeat
-    local j = i
-    local function f() return j end
-    if z1 then z2 = f else z1 = f end
-    i = i + 1
-  until i > 10
-  assert(z1() == 1)
-  assert(z2() == 10)
-end
-
-local function test_func()
-  local function ff(x)
-    return function() return x end
-  end
-  local z1, z2
-  for i=1,10 do
-    local f = ff(i)
-    if z1 then z2 = f else z1 = f end
-  end
-  assert(z1() == 1)
-  assert(z2() == 10)
-end
-
-test_for()
-test_while()
-test_repeat()
-test_func()
-
-do
-  local function f1(a)
-    if a > 0 then
-      local b = f1(a - 1)
-      return function()
-	if type(b) == "function" then
-	  return a + b()
-	end
-	return a + b
-      end
-    end
-    return a
-  end
-
-  local function f2(a)
-    return f1(a)()
-  end
-
-  for i = 1, 41 do
-    local r = f2(4) + f2(4)
-  end
-end
-
--- Don't mark upvalue as immutable if written to after prototype definition.
-do
-  local x = 1
-  local function f()
-    local y = 0
-    for i=1,100 do y=y+x end
-    return y
-  end
-  assert(f() == 100)
-  x = 2
-  assert(f() == 200)
-end
-
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 33/36] test: enable <misc/unordered_jit.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (31 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 32/36] test: remove <misc/uclo.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 34/36] test: enable <misc/wbarrier.lua> " Sergey Kaplun via Tarantool-patches
                   ` (2 subsequent siblings)
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <trace/>
directory, includes it in <index>, and names the subtests.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/misc/unordered_jit.lua  |  96 ---------
 test/LuaJIT-tests/trace/index             |   1 +
 test/LuaJIT-tests/trace/unordered_jit.lua | 240 ++++++++++++++++++++++
 3 files changed, 241 insertions(+), 96 deletions(-)
 delete mode 100644 test/LuaJIT-tests/misc/unordered_jit.lua
 create mode 100644 test/LuaJIT-tests/trace/unordered_jit.lua

diff --git a/test/LuaJIT-tests/misc/unordered_jit.lua b/test/LuaJIT-tests/misc/unordered_jit.lua
deleted file mode 100644
index 5ff1a1ba..00000000
--- a/test/LuaJIT-tests/misc/unordered_jit.lua
+++ /dev/null
@@ -1,96 +0,0 @@
-
-local nan = 0/0
-local t = {}
-for i=1,100 do t[i] = i+0.5 end
-for i=101,200 do t[i] = nan end
-
-do
-  local z = 0
-  for i=1,200 do if t[i] > 1000 then z=i end end
-  assert(z == 0)
-end
-
-do
-  local z = 0
-  for i=1,200 do if not (t[i] < 1000) then z=i end end
-  assert(z == 200)
-end
-
-do
-  local z = 0
-  for i=1,200 do if t[i] <= 1000 then z=i end end
-  assert(z == 100)
-end
-
-do
-  local z = 0
-  for i=1,200 do if not (t[i] >= 1000) then z=i end end
-  assert(z == 200)
-end
-
-do
-  local z = 0
-  for i=1,200 do if t[i] > 0 then z=i end end
-  assert(z == 100)
-end
-
-do
-  local z = 0
-  for i=1,200 do if not (t[i] < 0) then z=i end end
-  assert(z == 200)
-end
-
-do
-  local z = 0
-  for i=1,200 do if t[i] <= 0 then z=i end end
-  assert(z == 0)
-end
-
-do
-  local z = 0
-  for i=1,200 do if not (t[i] >= 0) then z=i end end
-  assert(z == 200)
-end
-
-do local z; for i=1,100 do z = 0/0 end; assert(z ~= z) end
-
-do local z; for i=1,100 do z = nan == nan end; assert(z == false) end
-do local z; for i=1,100 do z = nan == 1 end; assert(z == false) end
-do local z; for i=1,100 do z = 1 == nan end; assert(z == false) end
-
-do local z; for i=1,100 do z = nan ~= nan end; assert(z == true) end
-do local z; for i=1,100 do z = nan ~= 1 end; assert(z == true) end
-do local z; for i=1,100 do z = 1 ~= nan end; assert(z == true) end
-
-do local z; for i=1,100 do z = nan < nan end; assert(z == false) end
-do local z; for i=1,100 do z = nan < 1 end; assert(z == false) end
-do local z; for i=1,100 do z = 1 < nan end; assert(z == false) end
-
-do local z; for i=1,100 do z = not (nan < nan) end; assert(z == true) end
-do local z; for i=1,100 do z = not (nan < 1) end; assert(z == true) end
-do local z; for i=1,100 do z = not (1 < nan) end; assert(z == true) end
-
-do local z; for i=1,100 do z = nan > nan end; assert(z == false) end
-do local z; for i=1,100 do z = nan > 1 end; assert(z == false) end
-do local z; for i=1,100 do z = 1 > nan end; assert(z == false) end
-
-do local z; for i=1,100 do z = not (nan > nan) end; assert(z == true) end
-do local z; for i=1,100 do z = not (nan > 1) end; assert(z == true) end
-do local z; for i=1,100 do z = not (1 > nan) end; assert(z == true) end
-
-do local z; for i=1,100 do z = nan <= nan end; assert(z == false) end
-do local z; for i=1,100 do z = nan <= 1 end; assert(z == false) end
-do local z; for i=1,100 do z = 1 <= nan end; assert(z == false) end
-
-do local z; for i=1,100 do z = not (nan <= nan) end; assert(z == true) end
-do local z; for i=1,100 do z = not (nan <= 1) end; assert(z == true) end
-do local z; for i=1,100 do z = not (1 <= nan) end; assert(z == true) end
-
-do local z; for i=1,100 do z = nan >= nan end; assert(z == false) end
-do local z; for i=1,100 do z = nan >= 1 end; assert(z == false) end
-do local z; for i=1,100 do z = 1 >= nan end; assert(z == false) end
-
-do local z; for i=1,100 do z = not (nan >= nan) end; assert(z == true) end
-do local z; for i=1,100 do z = not (nan >= 1) end; assert(z == true) end
-do local z; for i=1,100 do z = not (1 >= nan) end; assert(z == true) end
-
diff --git a/test/LuaJIT-tests/trace/index b/test/LuaJIT-tests/trace/index
index 1b8fb8f4..c7fbbe57 100644
--- a/test/LuaJIT-tests/trace/index
+++ b/test/LuaJIT-tests/trace/index
@@ -12,3 +12,4 @@ stack_purge.lua
 stitch.lua
 tcall_base.lua
 tcall_loop.lua
+unordered_jit.lua
diff --git a/test/LuaJIT-tests/trace/unordered_jit.lua b/test/LuaJIT-tests/trace/unordered_jit.lua
new file mode 100644
index 00000000..0aa7bde3
--- /dev/null
+++ b/test/LuaJIT-tests/trace/unordered_jit.lua
@@ -0,0 +1,240 @@
+-- All cases below use constants on the trace.
+local nan = 0/0
+local t = {}
+for i = 1, 100 do t[i] = i + 0.5 end
+for i = 101, 200 do t[i] = nan end
+
+do --- Branch is never taken, NaN > 1000.
+  local z = 0
+  for i = 1, 200 do if t[i] > 1000 then z = i end end
+  assert(z == 0)
+end
+
+do --- Branch begins to be taken on the trace, not (NaN < 1000).
+  local z = 0
+  for i = 1, 200 do if not (t[i] < 1000) then z = i end end
+  assert(z == 200)
+end
+
+do --- Branch ends to be taken on the trace, NaN <= 1000.
+  local z = 0
+  for i = 1, 200 do if t[i] <= 1000 then z = i end end
+  assert(z == 100)
+end
+
+do --- Branch is always taken, not (NaN >= 1000).
+  local z = 0
+  for i = 1, 200 do if not (t[i] >= 1000) then z = i end end
+  assert(z == 200)
+end
+
+do --- Branch ends to be taken on the trace, NaN > 0.
+  local z = 0
+  for i = 1, 200 do if t[i] > 0 then z = i end end
+  assert(z == 100)
+end
+
+do --- Branch is always taken, not (NaN < 0).
+  local z = 0
+  for i = 1, 200 do if not (t[i] < 0) then z = i end end
+  assert(z == 200)
+end
+
+do --- Branch is never taken, NaN <= 0.
+  local z = 0
+  for i = 1, 200 do if t[i] <= 0 then z = i end end
+  assert(z == 0)
+end
+
+do --- Branch begins to be taken on the trace, not (NaN >= 0).
+  local z = 0
+  for i = 1, 200 do if not (t[i] >= 0) then z = i end end
+  assert(z == 200)
+end
+
+do --- NaN assign on trace.
+  local z
+  for _ = 1, 100 do z = 0/0 end
+  assert(z ~= z)
+end
+
+do --- Nan == NaN.
+  local z
+  for _ = 1, 100 do z = nan == nan end
+  assert(z == false)
+end
+
+do --- NaN == 1.
+  local z
+  for _ = 1, 100 do z = nan == 1 end
+  assert(z == false)
+end
+
+do --- 1 == NaN.
+  local z
+  local z
+  for _ = 1, 100 do z = 1 == nan end
+  assert(z == false)
+end
+
+do --- NaN ~= NaN.
+  local z
+  for _ = 1, 100 do z = nan ~= nan end
+  assert(z == true)
+end
+
+do --- NaN ~= 1.
+  local z
+  for _ = 1, 100 do z = nan ~= 1 end
+  assert(z == true)
+end
+
+do --- 1 ~= NaN.
+  local z
+  for _ = 1, 100 do z = 1 ~= nan end
+  assert(z == true)
+end
+
+do --- NaN < NaN.
+  local z
+  for _ = 1, 100 do z = nan < nan end
+  assert(z == false)
+end
+
+do --- NaN < 1.
+  local z
+  for _ = 1, 100 do z = nan < 1 end
+  assert(z == false)
+end
+
+do --- 1 < NaN.
+  local z
+  for _ = 1, 100 do z = 1 < nan end
+  assert(z == false)
+end
+
+do --- not (NaN < NaN).
+  local z
+  for _ = 1, 100 do z = not (nan < nan) end
+  assert(z == true)
+end
+
+do --- not (NaN < 1).
+  local z
+  for _ = 1, 100 do z = not (nan < 1) end
+  assert(z == true)
+end
+
+do --- not (1 < NaN).
+  local z
+  for _ = 1, 100 do z = not (1 < nan) end
+  assert(z == true)
+end
+
+do --- NaN > NaN.
+  local z
+  for _ = 1, 100 do z = nan > nan end
+  assert(z == false)
+end
+
+do --- NaN > 1.
+  local z
+  for _ = 1, 100 do z = nan > 1 end
+  assert(z == false)
+end
+
+do --- 1 > NaN.
+  local z
+  for _ = 1, 100 do z = 1 > nan end
+  assert(z == false)
+end
+
+do --- not (NaN > NaN).
+  local z
+  for _ = 1, 100 do z = not (nan > nan) end
+  assert(z == true)
+end
+
+do --- not (NaN > 1).
+  local z
+  for _ = 1, 100 do z = not (nan > 1) end
+  assert(z == true)
+end
+
+do --- not (1 > NaN).
+  local z
+  for _ = 1, 100 do z = not (1 > nan) end
+  assert(z == true)
+end
+
+do --- NaN <= NaN.
+  local z
+  for _ = 1, 100 do z = nan <= nan end
+  assert(z == false)
+end
+
+do --- NaN <= 1.
+  local z
+  for _ = 1, 100 do z = nan <= 1 end
+  assert(z == false)
+end
+
+do --- 1 <= NaN.
+  local z
+  for _ = 1, 100 do z = 1 <= nan end
+  assert(z == false)
+end
+
+do --- not (NaN <= NaN).
+  local z
+  for _ = 1, 100 do z = not (nan <= nan) end
+  assert(z == true)
+end
+
+do --- not (NaN <= 1).
+  local z
+  for _ = 1, 100 do z = not (nan <= 1) end
+  assert(z == true)
+end
+
+do --- not (1 <= NaN).
+  local z
+  for _ = 1, 100 do z = not (1 <= nan) end
+  assert(z == true)
+end
+
+do --- NaN >= NaN.
+  local z
+  for _ = 1, 100 do z = nan >= nan end
+  assert(z == false)
+end
+
+do --- NaN >= 1.
+  local z
+  for _ = 1, 100 do z = nan >= 1 end
+  assert(z == false)
+end
+
+do --- 1 >= NaN.
+  local z
+  for _ = 1, 100 do z = 1 >= nan end
+  assert(z == false)
+end
+
+do --- not (NaN >= NaN).
+  local z
+  for _ = 1, 100 do z = not (nan >= nan) end
+  assert(z == true)
+end
+
+do --- not (NaN >= 1).
+  local z
+  for _ = 1, 100 do z = not (nan >= 1) end
+  assert(z == true)
+end
+
+do --- not (1 >= NaN).
+  local z
+  for _ = 1, 100 do z = not (1 >= nan) end
+  assert(z == true)
+end
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 34/36] test: enable <misc/wbarrier.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (32 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 33/36] test: enable <misc/unordered_jit.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 35/36] test: enable <misc/wbarrier_jit.lua> " Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 36/36] test: enable <misc/wbarrier_obar.lua> " Sergey Kaplun via Tarantool-patches
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <lang/>
directory, includes it in <index>, and names the subtest.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/lang/index        |  1 +
 test/LuaJIT-tests/lang/wbarrier.lua | 11 +++++++++++
 test/LuaJIT-tests/misc/wbarrier.lua |  7 -------
 3 files changed, 12 insertions(+), 7 deletions(-)
 create mode 100644 test/LuaJIT-tests/lang/wbarrier.lua
 delete mode 100644 test/LuaJIT-tests/misc/wbarrier.lua

diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 8da748d0..ab4dc45d 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -32,3 +32,4 @@ gc_stack.lua
 gc_step.lua
 goto.lua +goto
 meta
+wbarrier.lua
diff --git a/test/LuaJIT-tests/lang/wbarrier.lua b/test/LuaJIT-tests/lang/wbarrier.lua
new file mode 100644
index 00000000..3bee865e
--- /dev/null
+++ b/test/LuaJIT-tests/lang/wbarrier.lua
@@ -0,0 +1,11 @@
+do --- Check write barrier when insert strings.
+  local t = {}
+
+  for i = 1, 20000 do
+    t[i] = tostring(i)
+  end
+
+  for i = 1, #t do
+    assert(t[i] == tostring(i))
+  end
+end
diff --git a/test/LuaJIT-tests/misc/wbarrier.lua b/test/LuaJIT-tests/misc/wbarrier.lua
deleted file mode 100644
index 5536625a..00000000
--- a/test/LuaJIT-tests/misc/wbarrier.lua
+++ /dev/null
@@ -1,7 +0,0 @@
-local t={}
-for i=1,20000 do
-  t[i] = tostring(i)
-end
-for i=1,#t do
-  assert(t[i] == tostring(i))
-end
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 35/36] test: enable <misc/wbarrier_jit.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (33 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 34/36] test: enable <misc/wbarrier.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 36/36] test: enable <misc/wbarrier_obar.lua> " Sergey Kaplun via Tarantool-patches
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test from the <misc> to the <trace/>
directory, includes it in <index>, and names the subtests.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/misc/wbarrier_jit.lua | 18 ------------------
 test/LuaJIT-tests/trace/index           |  1 +
 test/LuaJIT-tests/trace/wbarrier.lua    | 16 ++++++++++++++++
 3 files changed, 17 insertions(+), 18 deletions(-)
 delete mode 100644 test/LuaJIT-tests/misc/wbarrier_jit.lua
 create mode 100644 test/LuaJIT-tests/trace/wbarrier.lua

diff --git a/test/LuaJIT-tests/misc/wbarrier_jit.lua b/test/LuaJIT-tests/misc/wbarrier_jit.lua
deleted file mode 100644
index 2c8dd7fb..00000000
--- a/test/LuaJIT-tests/misc/wbarrier_jit.lua
+++ /dev/null
@@ -1,18 +0,0 @@
-
-do
-  local t = {[0]={}}
-  for i=1,1e5 do t[i] = {t[i-1]} end
-  for i=1,1e5 do assert(t[i][1] == t[i-1]) end
-end
-
-do
-  local f
-  do
-    local x = 0
-    function f()
-      for i=1,1e5 do x = {i} end
-    end
-  end
-  f()
-end
-
diff --git a/test/LuaJIT-tests/trace/index b/test/LuaJIT-tests/trace/index
index c7fbbe57..5e1c4c2e 100644
--- a/test/LuaJIT-tests/trace/index
+++ b/test/LuaJIT-tests/trace/index
@@ -13,3 +13,4 @@ stitch.lua
 tcall_base.lua
 tcall_loop.lua
 unordered_jit.lua
+wbarrier.lua
diff --git a/test/LuaJIT-tests/trace/wbarrier.lua b/test/LuaJIT-tests/trace/wbarrier.lua
new file mode 100644
index 00000000..625c0ff2
--- /dev/null
+++ b/test/LuaJIT-tests/trace/wbarrier.lua
@@ -0,0 +1,16 @@
+do --- TBAR for HSTORE.
+  local t = {[0]={}}
+  for i = 1, 1e5 do t[i] = {t[i - 1]} end
+  for i = 1, 1e5 do assert(t[i][1] == t[i - 1]) end
+end
+
+do --- OBAR for USTORE.
+  local f
+  do
+    local x = 0
+    function f()
+      for i = 1, 1e5 do x = {i} end
+    end
+  end
+  f()
+end
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Tarantool-patches] [PATCH luajit 36/36] test: enable <misc/wbarrier_obar.lua> LuaJIT test
  2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
                   ` (34 preceding siblings ...)
  2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 35/36] test: enable <misc/wbarrier_jit.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-14 13:56 ` Sergey Kaplun via Tarantool-patches
  35 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-14 13:56 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

This patch moves the aforementioned test to the <trace/wbarrier.lua>
test, with refactoring to restore the JIT engine and GC settings after
the test.

Part of tarantool/tarantool#9398
---
 test/LuaJIT-tests/misc/wbarrier_obar.lua | 22 -------------
 test/LuaJIT-tests/trace/wbarrier.lua     | 41 ++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 22 deletions(-)
 delete mode 100644 test/LuaJIT-tests/misc/wbarrier_obar.lua

diff --git a/test/LuaJIT-tests/misc/wbarrier_obar.lua b/test/LuaJIT-tests/misc/wbarrier_obar.lua
deleted file mode 100644
index 258db215..00000000
--- 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 625c0ff2..9c9c50af 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
-- 
2.45.2


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 01/36] test: don't run JIT-based LuaJIT tests without JIT
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 01/36] test: don't run JIT-based LuaJIT tests without JIT Sergey Kaplun via Tarantool-patches
@ 2024-08-15 12:47   ` Sergey Bronnikov via Tarantool-patches
  2024-08-19  8:47     ` Sergey Kaplun via Tarantool-patches
  0 siblings, 1 reply; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 12:47 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 2394 bytes --]

Hi, Sergey

thanks for the patch, LGTM.

See a minor comment below.


Sergey

On 14.08.2024 16:55, Sergey Kaplun wrote:
> Before this patch +jit flag is given to the LuaJIT test suite
> unconditionally even when LuaJIT is built as a pure interpreter.
>
> This patch fixes the behaviour by setting the flag only when
> `LUAJIT_DISABLE_JIT` option is not set.
>
> Needed for tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/CMakeLists.txt | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt
> index 9fbe9bf5..019762e0 100644
> --- a/test/LuaJIT-tests/CMakeLists.txt
> +++ b/test/LuaJIT-tests/CMakeLists.txt
> @@ -42,11 +42,15 @@ if(LUAJIT_USE_ASAN)
>     endif()
>   endif()
>   
> +if(NOT LUAJIT_DISABLE_JIT)
> +  list(APPEND LUAJIT_TEST_TAGS_EXTRA +jit)
> +endif()
> +
>   if(LUAJIT_NO_UNWIND)
>     # Test <catch_cpp.lua> verifies the interoperability with C++
>     # ABI exceptions, so it requires external unwinding enabled.
>     # Hence, skip them otherwise.
> -  set(LUAJIT_TEST_TAGS_EXTRA +internal_unwinder)
> +  list(APPEND LUAJIT_TEST_TAGS_EXTRA +internal_unwinder)
>   endif()
>   
>   if(CMAKE_C_FLAGS MATCHES "-march=skylake-avx512")
> @@ -55,7 +59,7 @@ if(CMAKE_C_FLAGS MATCHES "-march=skylake-avx512")
>     # built with the enabled AVX512 instruction set, see
>     #https://github.com/tarantool/tarantool/issues/6787.
>     # Hence, skip this when "skylake-avx512" is passed.
> -  set(LUAJIT_TEST_TAGS_EXTRA +avx512)
> +  list(APPEND LUAJIT_TEST_TAGS_EXTRA +avx512)
>   endif()
>   
>   set(TEST_SUITE_NAME "LuaJIT-tests")
> @@ -73,7 +77,7 @@ add_test_suite_target(LuaJIT-tests
>   set(test_title "test/${TEST_SUITE_NAME}")
>   add_test(NAME "${test_title}"
>     COMMAND ${LUAJIT_TEST_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/test.lua
> -                                 +slow +ffi +bit +jit ${LUAJIT_TEST_TAGS_EXTRA}
> +                                 +slow +ffi +bit ${LUAJIT_TEST_TAGS_EXTRA}

LUAJIT_TEST_TAGS_EXTRA is a list and to convert CMake list to a 
whitespace-separated strings

a list should be put in double quotes.

However, I've run tests with options for avx512 and -DLUAJIT_NO_UNWIND=ON

and passing test flags works fine without double quotes.

>     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>   )
>   set_tests_properties("${test_title}" PROPERTIES

[-- Attachment #2: Type: text/html, Size: 3163 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 02/36] test: enable <misc/alias_alloc.lua> LuaJIT test
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 02/36] test: enable <misc/alias_alloc.lua> LuaJIT test Sergey Kaplun via Tarantool-patches
@ 2024-08-15 12:51   ` Sergey Bronnikov via Tarantool-patches
  2024-08-15 13:31     ` Sergey Kaplun via Tarantool-patches
  0 siblings, 1 reply; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 12:51 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 3397 bytes --]

Hi, Sergey

Thanks for the patch! See my comments below.

On 14.08.2024 16:55, Sergey Kaplun wrote:
> This patch moves the <alias_alloc.lua> test from the <misc> to the
> created <opt/mem> directory, includes it in <index>, and names subtests.
>
> Testing optimizations in <lj_opt_mem.c> requires CSE, DCE, FOLD, and FWD
> optimizations enabled. Hence, the corresponding flags are used for the
> <mem> directory in <index>.

It is still unclear for me *why* a reason of this change.

Also patch contains formatting changes, I would say about it in commit 
message

as we usually do it.

>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/opt/index                   |  1 +
>   .../{misc => opt/mem}/alias_alloc.lua         | 30 +++++++++----------
>   test/LuaJIT-tests/opt/mem/index               |  1 +
>   3 files changed, 16 insertions(+), 16 deletions(-)
>   rename test/LuaJIT-tests/{misc => opt/mem}/alias_alloc.lua (53%)
>   create mode 100644 test/LuaJIT-tests/opt/mem/index
>
> diff --git a/test/LuaJIT-tests/opt/index b/test/LuaJIT-tests/opt/index
> index 94d50aec..8c43b56e 100644
> --- a/test/LuaJIT-tests/opt/index
> +++ b/test/LuaJIT-tests/opt/index
> @@ -3,4 +3,5 @@ fold +fold
>   fwd +fwd
>   fuse.lua +fuse
>   loop +loop
> +mem +cse +dse +fold +fwd
>   sink +sink
> diff --git a/test/LuaJIT-tests/misc/alias_alloc.lua b/test/LuaJIT-tests/opt/mem/alias_alloc.lua
> similarity index 53%
> rename from test/LuaJIT-tests/misc/alias_alloc.lua
> rename to test/LuaJIT-tests/opt/mem/alias_alloc.lua
> index 02fe618d..a9627b55 100644
> --- a/test/LuaJIT-tests/misc/alias_alloc.lua
> +++ b/test/LuaJIT-tests/opt/mem/alias_alloc.lua
> @@ -1,8 +1,7 @@
> -
> -do
> +do --- ALOAD forwarding, same table.
>     local t = {1}
>     local x
> -  for i=1,100 do
> +  for i = 1, 100 do
>       local v = {i}
>       t[1] = v[1]
>       x = v[1]
> @@ -10,45 +9,44 @@ do
>     assert(x == 100 and t[1] == 100)
>   end
>   
> -do
> +do --- ALOAD forwarding, different tables.
>     local t = {1}
>     local x,y
> -  for i=1,100 do
> +  for i = 1, 100 do
>       local v = {i}
> -    local w = {i+1}
> +    local w = {i + 1}
>       x = v[1]
>       y = w[1]
>     end
>     assert(x == 100 and y == 101)
>   end
>   
> -do
> +do --- FLOAD forwarding.
>     local mt = {}
>     local t = setmetatable({}, mt)
>     local x
> -  for i=1,100 do
> +  for _ = 1, 100 do
>       local v = {}
>       setmetatable(v, getmetatable(t))
>       assert(getmetatable(v) == mt)
>     end
>   end
>   
> --- See also sink_alloc.lua
> -do
> -  local x,k={1,2},{3,4}
> -  for i=1,100 do x = {x[1]+k[1], x[2]+k[2]} end
> +-- See also <opt/sink/alloc.lua>.
> +do --- Forwarding the constant-on-trace table in the complex add.
> +  local x, k = {1, 2}, {3, 4}
> +  for _ = 1, 100 do x = {x[1] + k[1], x[2] + k[2]} end
>     assert(x[1] == 301)
>     assert(x[2] == 402)
>   end
>   
> --- FLOAD for tab.asize/tab.array crossing NEWREF.
> -do
> +
> +do --- FLOAD forwarding for tab.asize/tab.array crossing NEWREF.
>     local t = {1}
> -  for i=1,100 do
> +  for _ = 1, 100 do
>       local v = {}
>       local w = {}
>       v[1] = t[1]
>       w[1] = t[1]
>     end
>   end
> -
> diff --git a/test/LuaJIT-tests/opt/mem/index b/test/LuaJIT-tests/opt/mem/index
> new file mode 100644
> index 00000000..0b1856ed
> --- /dev/null
> +++ b/test/LuaJIT-tests/opt/mem/index
> @@ -0,0 +1 @@
> +alias_alloc.lua

[-- Attachment #2: Type: text/html, Size: 3911 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 03/36] test: refactor <lang/coroutine.lua> LuaJIT test
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 03/36] test: refactor <lang/coroutine.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-15 13:00   ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 13:00 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 3178 bytes --]

Hi, Sergey!

Thanks for the patch! Please see my comments.

On 14.08.2024 16:55, Sergey Kaplun wrote:
> This patch refactors the <lang/coroutine.lua> test by adding a simple
> check for the content of a `debug.traceback()` result. Also, the test is
> moved to the <lib/coroutine/> directory.

The category for the test is debatable.

In fact, the test target is a function from `debug` module,

not coroutines.

>
> Also, it removes the <misc/coro_traceback.lua> since it is the same test
> that wasn't cleaned up during the refactoring in the original
> repository.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lang/coroutine.lua          |  8 --------
>   test/LuaJIT-tests/lang/index                  |  1 -
>   test/LuaJIT-tests/lib/coroutine/index         |  1 +
>   test/LuaJIT-tests/lib/coroutine/traceback.lua | 14 ++++++++++++++
>   test/LuaJIT-tests/misc/coro_traceback.lua     |  8 --------
>   5 files changed, 15 insertions(+), 17 deletions(-)
>   delete mode 100644 test/LuaJIT-tests/lang/coroutine.lua
>   create mode 100644 test/LuaJIT-tests/lib/coroutine/traceback.lua
>   delete mode 100644 test/LuaJIT-tests/misc/coro_traceback.lua
>
> diff --git a/test/LuaJIT-tests/lang/coroutine.lua b/test/LuaJIT-tests/lang/coroutine.lua
> deleted file mode 100644
> index 405135c9..00000000
> --- a/test/LuaJIT-tests/lang/coroutine.lua
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -do --- traceback
> -  local co = coroutine.create(function()
> -    local x = nil
> -    local y = x.x
> -  end)
> -  assert(coroutine.resume(co) == false)
> -  debug.traceback(co)
> -end
> diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
> index 4ff7a297..803f32d8 100644
> --- a/test/LuaJIT-tests/lang/index
> +++ b/test/LuaJIT-tests/lang/index
> @@ -14,7 +14,6 @@ concat.lua
>   self.lua
>   table.lua
>   upvalue
> -coroutine.lua
>   tail_recursion.lua
>   vararg_jit.lua
>   gc.lua
> diff --git a/test/LuaJIT-tests/lib/coroutine/index b/test/LuaJIT-tests/lib/coroutine/index
> index 9c5c17ec..c4dc6cf1 100644
> --- a/test/LuaJIT-tests/lib/coroutine/index
> +++ b/test/LuaJIT-tests/lib/coroutine/index
> @@ -1 +1,2 @@
> +traceback.lua
>   yield.lua
> diff --git a/test/LuaJIT-tests/lib/coroutine/traceback.lua b/test/LuaJIT-tests/lib/coroutine/traceback.lua
> new file mode 100644
> index 00000000..2b900ef1
> --- /dev/null
> +++ b/test/LuaJIT-tests/lib/coroutine/traceback.lua
> @@ -0,0 +1,14 @@
> +do --- traceback
> +  local function badfunc()
> +    local x = nil
> +    local y = x.x
> +  end
> +
> +  local co = coroutine.create(badfunc)
> +  assert(coroutine.resume(co) == false)
> +
> +  local traceback = debug.traceback(co)
> +  local line = debug.getinfo(badfunc).linedefined
> +
> +  assert(traceback:match('traceback:.*:' .. line))
> +end
> diff --git a/test/LuaJIT-tests/misc/coro_traceback.lua b/test/LuaJIT-tests/misc/coro_traceback.lua
> deleted file mode 100644
> index 2676d2c6..00000000
> --- a/test/LuaJIT-tests/misc/coro_traceback.lua
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -
> -local co = coroutine.create(function()
> -  local x = nil
> -  local y = x.x
> -end)
> -assert(coroutine.resume(co) == false)
> -debug.traceback(co)
> -

[-- Attachment #2: Type: text/html, Size: 4077 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 04/36] test: remove <misc/coro_yield.lua> LuaJIT test
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 04/36] test: remove <misc/coro_yield.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-15 13:05   ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 13:05 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 359 bytes --]

Hi, Sergey!

thanks for the patch! LGTM

On 14.08.2024 16:55, Sergey Kaplun wrote:
> This patch removes the aforementioned test since it is the same test as
I would say that these tests are identical :)
> <lib/coroutine/yield.lua> that wasn't cleaned up during the refactoring
> in the original repository.
>
> Part of tarantool/tarantool#9398
> ---
<snipped>

[-- Attachment #2: Type: text/html, Size: 1055 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 05/36] test: enable <misc/debug_gc.lua> LuaJIT test
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 05/36] test: enable <misc/debug_gc.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-15 13:09   ` Sergey Bronnikov via Tarantool-patches
  2024-08-15 13:25     ` Sergey Kaplun via Tarantool-patches
  0 siblings, 1 reply; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 13:09 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 3151 bytes --]

Hi, Sergey!

thanks for the patch!

On 14.08.2024 16:55, Sergey Kaplun wrote:
> This patch moves the aforementioned test from the <misc> to the <lang/>
It is not clear why do you move it to another suite/dir.
> directory (with slightly renaming to be consistent with other names),
> includes it in <index>, and names the subtest.
>
> Also, it changes the number of iterations to trigger the GC since the
> number of objects is different when running the test as a part of the
> LuaJIT test suite.

the patch contains minor changes related to formatting.

please describe it in commit message.


> Part of tarantool/tarantool#9398
> ---
>   .../{misc/debug_gc.lua => lang/gc_debug.lua}  | 31 ++++++++++++-------
>   test/LuaJIT-tests/lang/index                  |  1 +
>   2 files changed, 20 insertions(+), 12 deletions(-)
>   rename test/LuaJIT-tests/{misc/debug_gc.lua => lang/gc_debug.lua} (63%)
>
> diff --git a/test/LuaJIT-tests/misc/debug_gc.lua b/test/LuaJIT-tests/lang/gc_debug.lua
> similarity index 63%
> rename from test/LuaJIT-tests/misc/debug_gc.lua
> rename to test/LuaJIT-tests/lang/gc_debug.lua
> index 30fb2b99..bb30adc1 100644
> --- a/test/LuaJIT-tests/misc/debug_gc.lua
> +++ b/test/LuaJIT-tests/lang/gc_debug.lua
> @@ -1,12 +1,7 @@
> -
> --- Do not run this test unless the JIT compiler is turned off.
> -if jit and jit.status and jit.status() then return end
> -
>   local caught, caught_line, caught_mm
>   
>   local function gcmeta()
>     if caught ~= "end" then
> ---    print(debug.traceback())
>       -- This may point to the wrong instruction if in a JIT trace.
>       -- But there's no guarantee if, when or where any GC steps occur.
>       local dbg = debug.getinfo(2)
> @@ -22,7 +17,7 @@ local function testgc(mm, f)
>     local u = newproxy(true)
>     getmetatable(u).__gc = gcmeta
>     u = nil
> -  for i=1,100000 do
> +  for i = 1, 1e7 do
>       f(i)
>       -- This check may be hoisted. __gc is not supposed to have side-effects.
>       if caught then break end
> @@ -38,10 +33,22 @@ local function testgc(mm, f)
>     end
>   end
>   
> -local x
> -testgc("__gc", function(i) x = {} end)
> -testgc("__gc", function(i) x = {1} end)
> -testgc("__gc", function(i) x = function() end end)
> -testgc("__concat", function(i) x = i.."" end)
> +do --- Test __gc metamethod info
> +  -- Do not run this test unless the JIT compiler is turned off.
> +  local jit_need_restore = false
> +  if jit and jit.status and jit.status() then
> +    jit_need_restore = true
> +    jit.off()
> +  end
> +
> +  local x
> +  testgc("__gc", function(i) x = {} end)
> +  testgc("__gc", function(i) x = {1} end)
> +  testgc("__gc", function(i) x = function() end end)
> +  testgc("__concat", function(i) x = i.."" end)
>   
> -caught = "end"
> +  caught = "end"
> +  if jit_need_restore then
> +     jit.on()
> +  end
> +end
> diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
> index 803f32d8..4d9feafd 100644
> --- a/test/LuaJIT-tests/lang/index
> +++ b/test/LuaJIT-tests/lang/index
> @@ -17,5 +17,6 @@ upvalue
>   tail_recursion.lua
>   vararg_jit.lua
>   gc.lua
> +gc_debug.lua
>   goto.lua +goto
>   meta

[-- Attachment #2: Type: text/html, Size: 3905 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 06/36] test: enable <misc/dualnum.lua> LuaJIT test
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 06/36] test: enable <misc/dualnum.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-15 13:11   ` Sergey Bronnikov via Tarantool-patches
  2024-08-15 13:19     ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 1 reply; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 13:11 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 2419 bytes --]

Hi, Sergey

thanks for the patch!

see my comments below

On 14.08.2024 16:55, Sergey Kaplun wrote:
> This patch moves the aforementioned test from the <misc> to the <lang/>
> directory, includes it in <index>, and names subtests.

Add a reason for this and couple of words about updated formatting in 
the test.


> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/{misc => lang}/dualnum.lua | 24 +++++++++-----------
>   test/LuaJIT-tests/lang/index                 |  1 +
>   2 files changed, 12 insertions(+), 13 deletions(-)
>   rename test/LuaJIT-tests/{misc => lang}/dualnum.lua (57%)
>
> diff --git a/test/LuaJIT-tests/misc/dualnum.lua b/test/LuaJIT-tests/lang/dualnum.lua
> similarity index 57%
> rename from test/LuaJIT-tests/misc/dualnum.lua
> rename to test/LuaJIT-tests/lang/dualnum.lua
> index 5f1288c8..688920eb 100644
> --- a/test/LuaJIT-tests/misc/dualnum.lua
> +++ b/test/LuaJIT-tests/lang/dualnum.lua
> @@ -1,34 +1,32 @@
> +-- Test LuaJIT Dualnum mode behaviour.
>   
> --- Positive overflow
> -do
> +do --- Positive overflow.
>     local x = 0
> -  for i=2147483446,2147483647,2 do x = x + 1 end
> +  for _ = 2147483446, 2147483647, 2 do x = x + 1 end
>     assert(x == 101)
>   end
>   
> --- Negative overflow
> -do
> +do --- Negative overflow.
>     local x = 0
> -  for i=-2147483447,-2147483648,-2 do x = x + 1 end
> +  for _ = -2147483447, -2147483648, -2 do x = x + 1 end
>     assert(x == 101)
>   end
>   
> --- SLOAD with number to integer conversion.
> -do
> +do --- SLOAD with number to integer conversion.
>     local k = 1
>     local a, b, c = 1/k, 20/k, 1/k
> -  for i=1,20 do
> -    for j=a,b,c do end
> +  for i = 1, 20 do
> +    for j = a, b, c do end
>     end
>   end
>   
> -do
> +do --- min/max correctness.
>     local function fmin(a, b)
> -    for i=1,100 do a = math.min(a, b) end
> +    for _ = 1, 100 do a = math.min(a, b) end
>       return a
>     end
>     local function fmax(a, b)
> -    for i=1,100 do a = math.max(a, b) end
> +    for _ = 1, 100 do a = math.max(a, b) end
>       return a
>     end
>     assert(fmin(1, 3) == 1)
> diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
> index 4d9feafd..b0e7f073 100644
> --- a/test/LuaJIT-tests/lang/index
> +++ b/test/LuaJIT-tests/lang/index
> @@ -6,6 +6,7 @@ catch_wrap.lua
>   compare.lua
>   compare_nan.lua
>   constant
> +dualnum.lua
>   for.lua
>   length.lua
>   lightud.lua

[-- Attachment #2: Type: text/html, Size: 2989 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 06/36] test: enable <misc/dualnum.lua> LuaJIT test
  2024-08-15 13:11   ` Sergey Bronnikov via Tarantool-patches
@ 2024-08-15 13:19     ` Sergey Bronnikov via Tarantool-patches
  2024-08-15 13:22       ` Sergey Kaplun via Tarantool-patches
  0 siblings, 1 reply; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 13:19 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 2738 bytes --]

dualnum is an optional LuaJIT feature (LJ_DUALNUM), why we don't have a 
separate flag for

the test that will disable test when feature is not available?



On 15.08.2024 16:11, Sergey Bronnikov via Tarantool-patches wrote:
>
> Hi, Sergey
>
> thanks for the patch!
>
> see my comments below
>
> On 14.08.2024 16:55, Sergey Kaplun wrote:
>> This patch moves the aforementioned test from the <misc> to the <lang/>
>> directory, includes it in <index>, and names subtests.
>
> Add a reason for this and couple of words about updated formatting in 
> the test.
>
>
>> Part of tarantool/tarantool#9398
>> ---
>>   test/LuaJIT-tests/{misc => lang}/dualnum.lua | 24 +++++++++-----------
>>   test/LuaJIT-tests/lang/index                 |  1 +
>>   2 files changed, 12 insertions(+), 13 deletions(-)
>>   rename test/LuaJIT-tests/{misc => lang}/dualnum.lua (57%)
>>
>> diff --git a/test/LuaJIT-tests/misc/dualnum.lua b/test/LuaJIT-tests/lang/dualnum.lua
>> similarity index 57%
>> rename from test/LuaJIT-tests/misc/dualnum.lua
>> rename to test/LuaJIT-tests/lang/dualnum.lua
>> index 5f1288c8..688920eb 100644
>> --- a/test/LuaJIT-tests/misc/dualnum.lua
>> +++ b/test/LuaJIT-tests/lang/dualnum.lua
>> @@ -1,34 +1,32 @@
>> +-- Test LuaJIT Dualnum mode behaviour.
>>   
>> --- Positive overflow
>> -do
>> +do --- Positive overflow.
>>     local x = 0
>> -  for i=2147483446,2147483647,2 do x = x + 1 end
>> +  for _ = 2147483446, 2147483647, 2 do x = x + 1 end
>>     assert(x == 101)
>>   end
>>   
>> --- Negative overflow
>> -do
>> +do --- Negative overflow.
>>     local x = 0
>> -  for i=-2147483447,-2147483648,-2 do x = x + 1 end
>> +  for _ = -2147483447, -2147483648, -2 do x = x + 1 end
>>     assert(x == 101)
>>   end
>>   
>> --- SLOAD with number to integer conversion.
>> -do
>> +do --- SLOAD with number to integer conversion.
>>     local k = 1
>>     local a, b, c = 1/k, 20/k, 1/k
>> -  for i=1,20 do
>> -    for j=a,b,c do end
>> +  for i = 1, 20 do
>> +    for j = a, b, c do end
>>     end
>>   end
>>   
>> -do
>> +do --- min/max correctness.
>>     local function fmin(a, b)
>> -    for i=1,100 do a = math.min(a, b) end
>> +    for _ = 1, 100 do a = math.min(a, b) end
>>       return a
>>     end
>>     local function fmax(a, b)
>> -    for i=1,100 do a = math.max(a, b) end
>> +    for _ = 1, 100 do a = math.max(a, b) end
>>       return a
>>     end
>>     assert(fmin(1, 3) == 1)
>> diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
>> index 4d9feafd..b0e7f073 100644
>> --- a/test/LuaJIT-tests/lang/index
>> +++ b/test/LuaJIT-tests/lang/index
>> @@ -6,6 +6,7 @@ catch_wrap.lua
>>   compare.lua
>>   compare_nan.lua
>>   constant
>> +dualnum.lua
>>   for.lua
>>   length.lua
>>   lightud.lua

[-- Attachment #2: Type: text/html, Size: 3571 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 07/36] test: remove <misc/fori_coerce.lua> LuaJIT test
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 07/36] test: remove <misc/fori_coerce.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-15 13:20   ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 13:20 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 95 bytes --]

Hi, Sergey!

thanks for the patch! LGTM

On 14.08.2024 16:55, Sergey Kaplun wrote:


<snipped>

[-- Attachment #2: Type: text/html, Size: 450 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 08/36] test: remove <misc/fori_dir.lua> LuaJIT test
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 08/36] test: remove <misc/fori_dir.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-15 13:21   ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 13:21 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 818 bytes --]

Hi, Sergey!

thanks for the patch! LGTM

On 14.08.2024 16:55, Sergey Kaplun wrote:
> This patch removes the aforementioned test since it is part of the
> <lang/for.lua> test.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/misc/for_dir.lua | 13 -------------
>   1 file changed, 13 deletions(-)
>   delete mode 100644 test/LuaJIT-tests/misc/for_dir.lua
>
> diff --git a/test/LuaJIT-tests/misc/for_dir.lua b/test/LuaJIT-tests/misc/for_dir.lua
> deleted file mode 100644
> index 4dd38dee..00000000
> --- a/test/LuaJIT-tests/misc/for_dir.lua
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -
> -local a,b,c = 10,1,-1
> -for i=1,20 do
> -  if c == -1 then
> -    a,b,c = 1,10,1
> -  else
> -    a,b,c = 10,1,-1
> -  end
> -  local x = 0
> -  for i=a,b,c do for j=1,10 do end x=x+1 end
> -  assert(x == 10)
> -end
> -

[-- Attachment #2: Type: text/html, Size: 1262 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 06/36] test: enable <misc/dualnum.lua> LuaJIT test
  2024-08-15 13:19     ` Sergey Bronnikov via Tarantool-patches
@ 2024-08-15 13:22       ` Sergey Kaplun via Tarantool-patches
  0 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-15 13:22 UTC (permalink / raw)
  To: Sergey Bronnikov; +Cc: tarantool-patches

Sergey,

On 15.08.24, Sergey Bronnikov wrote:
> dualnum is an optional LuaJIT feature (LJ_DUALNUM), why we don't have a 
> separate flag for
> 
> the test that will disable test when feature is not available?
> 

Since the language semantics should be correct regardless of whether
this flag is enabled or not.

> 

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 09/36] test: remove <misc/gc_rechain.lua> LuaJIT test
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 09/36] test: remove <misc/gc_rechain.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-15 13:22   ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 13:22 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 971 bytes --]

Hi, Sergey

thanks for the patch! LGTM

On 14.08.2024 16:55, Sergey Kaplun wrote:
> This patch removes the aforementioned test since it is part of the
> <lang/gc.lua> test.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/misc/gc_rechain.lua | 32 ---------------------------
>   1 file changed, 32 deletions(-)
>   delete mode 100644 test/LuaJIT-tests/misc/gc_rechain.lua
>
> diff --git a/test/LuaJIT-tests/misc/gc_rechain.lua b/test/LuaJIT-tests/misc/gc_rechain.lua
> deleted file mode 100644
> index 285f4086..00000000
> --- a/test/LuaJIT-tests/misc/gc_rechain.lua
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -
> -do
> -  local k
> -
> -  collectgarbage()
> -
> -  local t = {}
> -  t.ac = 1
> -
> -  t.nn = 1
> -  t.mm = 1
> -  t.nn = nil
> -  t.mm = nil
> -
> -  k = "a".."i"
> -  t[k] = 2
> -
> -  t.ad = 3
> -
> -  t[k] = nil
> -  k = nil
> -
> -  collectgarbage()
> -
> -  k = "a".."f"
> -  t[k] = 4
> -
> -  t.ak = 5
> -
> -  assert(t[k] == 4)
> -end
> -

[-- Attachment #2: Type: text/html, Size: 1377 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 10/36] test: enable <misc/gc_trace.lua> LuaJIT test
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 10/36] test: enable <misc/gc_trace.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-15 13:24   ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 13:24 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 2333 bytes --]

Hi, Sergey

thanks for the patch!

On 14.08.2024 16:55, Sergey Kaplun wrote:
> This patch moves the aforementioned test from the <misc> to the <trace/>
> directory, includes it in <index>, and names subtests.
Please describe a reason.
>
> The first test is adjusted to be runable in the test suite.
>
> Part of tarantool/tarantool#9398
> ---
>   .../{misc/gc_trace.lua => trace/gc.lua}       | 27 +++++++++----------
>   test/LuaJIT-tests/trace/index                 |  1 +
>   2 files changed, 14 insertions(+), 14 deletions(-)
>   rename test/LuaJIT-tests/{misc/gc_trace.lua => trace/gc.lua} (60%)
>
> diff --git a/test/LuaJIT-tests/misc/gc_trace.lua b/test/LuaJIT-tests/trace/gc.lua
> similarity index 60%
> rename from test/LuaJIT-tests/misc/gc_trace.lua
> rename to test/LuaJIT-tests/trace/gc.lua
> index bc38ce0c..4d984ed6 100644
> --- a/test/LuaJIT-tests/misc/gc_trace.lua
> +++ b/test/LuaJIT-tests/trace/gc.lua
> @@ -1,18 +1,18 @@
> +local jutil = require("jit.util")
>   
> -if not jit or not jit.status or not jit.status() then return end
> -
> -collectgarbage()
> -for j=1,100 do
> -  loadstring("for i=1,100 do end")()
> +do --- Collect dead traces.
> +  jit.flush()
> +  collectgarbage()
> +  for _ = 1, 100 do
> +    loadstring("for _ = 1, 100 do end")()
> +  end
> +  collectgarbage()
> +  assert(jutil.traceinfo(1) == nil)
> +  assert(jutil.traceinfo(2) == nil)
> +  assert(jutil.traceinfo(3) == nil)
>   end
> -local jutil = require("jit.util")
> -assert(jutil.traceinfo(90) == nil)
> -collectgarbage()
> -assert(jutil.traceinfo(1) == nil)
> -assert(jutil.traceinfo(2) == nil)
> -assert(jutil.traceinfo(3) == nil)
>   
> -do
> +do --- Check KGC marking.
>     local f
>     local function reccb(tr)
>       if f == nil then
> @@ -24,7 +24,7 @@ do
>       end
>     end
>     jit.attach(reccb, "record")
> -  for i=1,200 do
> +  for i = 1, 200 do
>       if i % 5 == 0 then
>         f = function() end
>       elseif f then
> @@ -34,4 +34,3 @@ do
>     end
>     jit.attach(reccb)
>   end
> -
> diff --git a/test/LuaJIT-tests/trace/index b/test/LuaJIT-tests/trace/index
> index ea7a22e0..46c8f5d2 100644
> --- a/test/LuaJIT-tests/trace/index
> +++ b/test/LuaJIT-tests/trace/index
> @@ -1,6 +1,7 @@
>   exit_frame.lua
>   exit_growstack.lua
>   exit_jfuncf.lua
> +gc.lua
>   gc64_slot_revival.lua
>   phi
>   snap.lua

[-- Attachment #2: Type: text/html, Size: 2870 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 05/36] test: enable <misc/debug_gc.lua> LuaJIT test
  2024-08-15 13:09   ` Sergey Bronnikov via Tarantool-patches
@ 2024-08-15 13:25     ` Sergey Kaplun via Tarantool-patches
  0 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-15 13:25 UTC (permalink / raw)
  To: Sergey Bronnikov; +Cc: tarantool-patches

Sergey,

On 15.08.24, Sergey Bronnikov wrote:
> Hi, Sergey!
> 
> thanks for the patch!
> 
> On 14.08.2024 16:55, Sergey Kaplun wrote:
> > This patch moves the aforementioned test from the <misc> to the <lang/>
> It is not clear why do you move it to another suite/dir.

What is your proposal here?
The test is part of this suite and has general semantics related to
the language behaviour.

> > directory (with slightly renaming to be consistent with other names),
> > includes it in <index>, and names the subtest.
> >
> > Also, it changes the number of iterations to trigger the GC since the
> > number of objects is different when running the test as a part of the
> > LuaJIT test suite.

<snipped>

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 02/36] test: enable <misc/alias_alloc.lua> LuaJIT test
  2024-08-15 12:51   ` Sergey Bronnikov via Tarantool-patches
@ 2024-08-15 13:31     ` Sergey Kaplun via Tarantool-patches
  2024-08-30  7:25       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 1 reply; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-15 13:31 UTC (permalink / raw)
  To: Sergey Bronnikov; +Cc: tarantool-patches

Sergey,

On 15.08.24, Sergey Bronnikov wrote:
> Hi, Sergey
> 
> Thanks for the patch! See my comments below.
> 
> On 14.08.2024 16:55, Sergey Kaplun wrote:
> > This patch moves the <alias_alloc.lua> test from the <misc> to the
> > created <opt/mem> directory, includes it in <index>, and names subtests.
> >
> > Testing optimizations in <lj_opt_mem.c> requires CSE, DCE, FOLD, and FWD
> > optimizations enabled. Hence, the corresponding flags are used for the
> > <mem> directory in <index>.
> 
> It is still unclear for me *why* a reason of this change.

The tests for other optimizations also require the necessary flags, see
<index>. Also, I don't understand what *change* you mean -- it is
enabling of test, not changing its functionality.

> 

<snipped>

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 11/36] test: enable <misc/gcstep.lua> LuaJIT test
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 11/36] test: enable <misc/gcstep.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-15 13:34   ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 13:34 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 2818 bytes --]

Hi, Sergey

thanks for the patch

On 14.08.2024 16:55, Sergey Kaplun wrote:
> This patch moves the aforementioned test from the <misc> to the <lang/>
> directory (with slightly renaming to be consistent with other names),
> includes it in <index>, and names the subtests.

please describe a reason of moving and say in commit message

that patch also added comments and changed formatting.

>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lang/gc_step.lua | 39 ++++++++++++++++++++++++++++++
>   test/LuaJIT-tests/lang/index       |  1 +
>   test/LuaJIT-tests/misc/gcstep.lua  | 33 -------------------------
>   3 files changed, 40 insertions(+), 33 deletions(-)
>   create mode 100644 test/LuaJIT-tests/lang/gc_step.lua
>   delete mode 100644 test/LuaJIT-tests/misc/gcstep.lua
>
> diff --git a/test/LuaJIT-tests/lang/gc_step.lua b/test/LuaJIT-tests/lang/gc_step.lua
> new file mode 100644
> index 00000000..756d7a61
> --- /dev/null
> +++ b/test/LuaJIT-tests/lang/gc_step.lua
> @@ -0,0 +1,39 @@
> +local function testgc(what, func)
> +  collectgarbage()
> +  local oc = gcinfo()
> +  func()
> +  local nc = gcinfo()
> +  assert(nc < oc * 4, "GC step missing for " .. what)
> +end
> +
> +do --- TNEW
> +  testgc("TNEW", function()
> +    for _ = 1, 10000 do
> +      local _ = {}
> +    end
> +  end)
> +end
> +
> +do --- TDUP
> +  testgc("TDUP", function()
> +    for _ = 1, 10000 do
> +      local _ = {1}
> +    end
> +  end)
> +end
> +
> +do --- FNEW
> +  testgc("FNEW", function()
> +    for _ = 1, 10000 do
> +      local function _() end
> +    end
> +  end)
> +end
> +
> +do --- CAT
> +  testgc("CAT", function()
> +    for i = 1, 10000 do
> +      local _ = "x" .. i
> +    end
> +  end)
> +end
> diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
> index b0e7f073..274425bf 100644
> --- a/test/LuaJIT-tests/lang/index
> +++ b/test/LuaJIT-tests/lang/index
> @@ -19,5 +19,6 @@ tail_recursion.lua
>   vararg_jit.lua
>   gc.lua
>   gc_debug.lua
> +gc_step.lua
>   goto.lua +goto
>   meta
> diff --git a/test/LuaJIT-tests/misc/gcstep.lua b/test/LuaJIT-tests/misc/gcstep.lua
> deleted file mode 100644
> index 533356b7..00000000
> --- a/test/LuaJIT-tests/misc/gcstep.lua
> +++ /dev/null
> @@ -1,33 +0,0 @@
> -
> -local function testgc(what, func)
> -  collectgarbage()
> -  local oc = gcinfo()
> -  func()
> -  local nc = gcinfo()
> -  assert(nc < oc*4, "GC step missing for "..what)
> -end
> -
> -testgc("TNEW", function()
> -  for i=1,10000 do
> -    local t = {}
> -  end
> -end)
> -
> -testgc("TDUP", function()
> -  for i=1,10000 do
> -    local t = {1}
> -  end
> -end)
> -
> -testgc("FNEW", function()
> -  for i=1,10000 do
> -    local function f() end
> -  end
> -end)
> -
> -testgc("CAT", function()
> -  for i=1,10000 do
> -    local s = "x"..i
> -  end
> -end)
> -

[-- Attachment #2: Type: text/html, Size: 3324 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 12/36] test: enable <misc/hook_active.lua> LuaJIT test
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 12/36] test: enable <misc/hook_active.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-15 13:38   ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 13:38 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 7245 bytes --]

Hi, Sergey

thanks for the patch! Please see my comments below.


On 14.08.2024 16:55, Sergey Kaplun wrote:
> This patch moves the aforementioned test from the <misc> to the <lang/>
> directory, includes it in <index>, and names the subtests.
+ changed formatting
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lang/hook_active.lua | 102 +++++++++++++++++++++++++
>   test/LuaJIT-tests/lang/index           |   1 +
>   test/LuaJIT-tests/misc/hook_active.lua |  95 -----------------------
>   3 files changed, 103 insertions(+), 95 deletions(-)
>   create mode 100644 test/LuaJIT-tests/lang/hook_active.lua
>   delete mode 100644 test/LuaJIT-tests/misc/hook_active.lua
>
> diff --git a/test/LuaJIT-tests/lang/hook_active.lua b/test/LuaJIT-tests/lang/hook_active.lua
> new file mode 100644
> index 00000000..c82670f5
> --- /dev/null
> +++ b/test/LuaJIT-tests/lang/hook_active.lua
> @@ -0,0 +1,102 @@
> +local ctest = require("libctest")
> +
> +local called = 0
> +local function clearhook() debug.sethook(nil, "", 0) end
> +
> +do --- Return from pcall with active hook must prepend true. FF pcall.
> +  called = 0
> +  debug.sethook(function() called=called+1; assert(pcall(function() end) == true); clearhook() end, "", 1)
add more spaces
> +  do local x = 1 end
> +  assert(called == 1)
> +end
> +
> +do --- Hook with special caught error must not unblock hooks. FF pcall.
> +  called = 0
> +  debug.sethook(function() called=called+1; pcall(nil); clearhook() end, "", 1)
add more spaces
> +  do local x = 1 end
> +  assert(called == 1)
> +end
> +
> +do --- Hook with caught error must not unblock hooks. FF pcall.
> +  called = 0
> +  local function p2() error("") end
> +  debug.sethook(function() called=called+1; pcall(p2); clearhook() end, "", 1)
add more spaces here and below
> +  do local x = 1 end
> +  assert(called == 1)
> +end
> +
> +do --- Hook with special caught error must not unblock hooks. C pcall.
> +  called = 0
> +  debug.sethook(function() called=called+1; ctest.pcall(nil); clearhook() end, "", 1)
add more spaces
> +  do local x = 1 end
> +  assert(called == 1)
> +end
> +
> +do --- Hook with caught error must not unblock hooks. C pcall
missed dot at the end
> +  called = 0
> +  local function p2() error("") end
> +  debug.sethook(function() called=called+1; ctest.pcall(p2); clearhook() end, "", 1)
> +  do local x = 1 end
> +  assert(called == 1)
> +end
> +
> +do --- Regular pcall must not block hooks.
> +  debug.sethook(function() called=called+1 end, "", 1)
add more spaces
> +  pcall(function() end)
> +  called = 0
> +  do local x = 1 end
> +  assert(called > 0)
> +  pcall(function() error("") end)
> +  called = 0
> +  do local x = 1 end
> +  assert(called > 0)
> +  ctest.pcall(function() end)
> +  called = 0
> +  do local x = 1 end
> +  assert(called > 0)
> +  ctest.pcall(function() error("") end)
> +  called = 0
> +  do local x = 1 end
> +  assert(called > 0)
> +  clearhook()
> +end
> +
> +do --- Hook with uncaught error must unblock hooks. FF pcall
missed dot at the end
> +  called = 0
> +  pcall(function()
> +    debug.sethook(function()
> +      local old = called
> +      called = 1
> +      if old == 0 then error("") end
> +    end, "", 1)
> +    do local x = 1 end
> +  end)
> +  assert(called == 1)
> +  called = 2
> +  do local x = 1 end
> +  assert(called == 1, "hook not unblocked after uncaught error")
> +  clearhook()
> +  called = 2
> +  do local x = 1 end
> +  assert(called == 2)
> +end
> +
> +do --- Hook with uncaught error must unblock hooks. C pcall
missed dot at the end
> +  called = 0
> +  ctest.pcall(function()
> +    debug.sethook(function()
> +      local old = called
> +      called = 1
> +      if old == 0 then error("") end
> +    end, "", 1)
> +    do local x = 1 end
> +  end)
> +  assert(called == 1)
> +  called = 2
> +  do local x = 1 end
> +  assert(called == 1, "hook not unblocked after uncaught error")
> +  clearhook()
> +  called = 2
> +  do local x = 1 end
> +  assert(called == 2)
> +end
> diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
> index 274425bf..8cecfa08 100644
> --- a/test/LuaJIT-tests/lang/index
> +++ b/test/LuaJIT-tests/lang/index
> @@ -8,6 +8,7 @@ compare_nan.lua
>   constant
>   dualnum.lua
>   for.lua
> +hook_active.lua
>   length.lua
>   lightud.lua
>   modulo.lua
> diff --git a/test/LuaJIT-tests/misc/hook_active.lua b/test/LuaJIT-tests/misc/hook_active.lua
> deleted file mode 100644
> index 37dfc379..00000000
> --- a/test/LuaJIT-tests/misc/hook_active.lua
> +++ /dev/null
> @@ -1,95 +0,0 @@
> -local ctest = require("ctest")
> -
> -local called = 0
> -local function clearhook() debug.sethook(nil, "", 0) end
> -
> --- Return from pcall with active hook must prepend true. FF pcall.
> -called = 0
> -debug.sethook(function() called=called+1; assert(pcall(function() end) == true); clearhook() end, "", 1)
> -do local x = 1 end
> -assert(called == 1)
> -
> --- Hook with special caught error must not unblock hooks. FF pcall.
> -called = 0
> -debug.sethook(function() called=called+1; pcall(nil); clearhook() end, "", 1)
> -do local x = 1 end
> -assert(called == 1)
> -
> --- Hook with caught error must not unblock hooks. FF pcall.
> -called = 0
> -local function p2() error("") end
> -debug.sethook(function() called=called+1; pcall(p2); clearhook() end, "", 1)
> -do local x = 1 end
> -assert(called == 1)
> -
> --- Hook with special caught error must not unblock hooks. C pcall.
> -called = 0
> -debug.sethook(function() called=called+1; ctest.pcall(nil); clearhook() end, "", 1)
> -do local x = 1 end
> -assert(called == 1)
> -
> --- Hook with caught error must not unblock hooks. C pcall
> -called = 0
> -local function p2() error("") end
> -debug.sethook(function() called=called+1; ctest.pcall(p2); clearhook() end, "", 1)
> -do local x = 1 end
> -assert(called == 1)
> -
> --- Regular pcall must not block hooks.
> -debug.sethook(function() called=called+1 end, "", 1)
> -pcall(function() end)
> -called = 0
> -do local x = 1 end
> -assert(called > 0)
> -pcall(function() error("") end)
> -called = 0
> -do local x = 1 end
> -assert(called > 0)
> -ctest.pcall(function() end)
> -called = 0
> -do local x = 1 end
> -assert(called > 0)
> -ctest.pcall(function() error("") end)
> -called = 0
> -do local x = 1 end
> -assert(called > 0)
> -clearhook()
> -
> --- Hook with uncaught error must unblock hooks. FF pcall
> -called = 0
> -pcall(function()
> -  debug.sethook(function()
> -    local old = called
> -    called = 1
> -    if old == 0 then error("") end
> -  end, "", 1)
> -  do local x = 1 end
> -end)
> -assert(called == 1)
> -called = 2
> -do local x = 1 end
> -assert(called == 1, "hook not unblocked after uncaught error")
> -clearhook()
> -called = 2
> -do local x = 1 end
> -assert(called == 2)
> -
> --- Hook with uncaught error must unblock hooks. C pcall
> -called = 0
> -ctest.pcall(function()
> -  debug.sethook(function()
> -    local old = called
> -    called = 1
> -    if old == 0 then error("") end
> -  end, "", 1)
> -  do local x = 1 end
> -end)
> -assert(called == 1)
> -called = 2
> -do local x = 1 end
> -assert(called == 1, "hook not unblocked after uncaught error")
> -clearhook()
> -called = 2
> -do local x = 1 end
> -assert(called == 2)
> -

[-- Attachment #2: Type: text/html, Size: 9029 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 13/36] test: enable <misc/hook_line.lua> LuaJIT test
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 13/36] test: enable <misc/hook_line.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-15 13:42   ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 13:42 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 3909 bytes --]

Hi, Sergey

thanks for the patch! see my comments below.


On 14.08.2024 16:55, Sergey Kaplun wrote:
> This patch moves the aforementioned test from the <misc> to the <lang/>
why <lang> and not a "debug" suite?
> directory, includes it in <index>, names the subtests, and adjusts the
> linenumbers in the assertions to match LuaJIT behaviour and the new code
Split "linenumbers" to two words, or wrap with backticks (I suspect you 
mean a field in getinfo).
> layout.

+ formatting changes


>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lang/hook_line.lua | 44 ++++++++++++++++++++++++++++
>   test/LuaJIT-tests/lang/index         |  1 +
>   test/LuaJIT-tests/misc/hook_line.lua | 41 --------------------------
>   3 files changed, 45 insertions(+), 41 deletions(-)
>   create mode 100644 test/LuaJIT-tests/lang/hook_line.lua
>   delete mode 100644 test/LuaJIT-tests/misc/hook_line.lua
>
> diff --git a/test/LuaJIT-tests/lang/hook_line.lua b/test/LuaJIT-tests/lang/hook_line.lua
> new file mode 100644
> index 00000000..bb89c4b8
> --- /dev/null
> +++ b/test/LuaJIT-tests/lang/hook_line.lua
> @@ -0,0 +1,44 @@
> +local lines = {}
> +local function hook()
> +  lines[#lines + 1] = debug.getinfo(2).currentline
> +end
> +
> +local function dummy()
> +end -- <-- line 7
> +
> +do --- Base test: cycles, function calls.
> +  debug.sethook(hook, "l", 0)
> +  -- <-- line 11
> +  local x
> +  dummy()
> +  local y = 1
> +  dummy() dummy()
> +  local z = 2; local r = true
> +  while y < 4 do y = y + 1 end
> +  while z < 4 do
> +    z = z + 1
> +  end
> +  -- <-- line 21
> +  local v
> +  debug.sethook(nil, "", 0)
> +
> +  assert(#lines > 0)
> +  while lines[1] < 10 do table.remove(lines, 1) end
> +  while lines[#lines] > 20 do table.remove(lines) end
> +
> +  local s = table.concat(lines, " ")
> +  assert(s == "12 13 7 14 15 7 7 16 17 17 17 17 18 19 18 19 18" or
> +         s == "12 13 7 14 15 7 15 7 16 17 17 17 17 18 19 18 19 18")
> +end
> +
> +do --- Not visited the end of the function definition.
> +  lines = {}
> +  local function f()
> +    if true then return end
> +    local function x() end
> +  end -- <-- line 39

test depends on a number of lines in the file, please add a note about 
it at the beginning of the file


> +  debug.sethook(hook, "l", 0)
> +  f()
> +  debug.sethook(nil, "", 0)
> +  for i = 1, #lines do assert(lines[i] ~= 39) end
> +end
> diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
> index 8cecfa08..ae59bc56 100644
> --- a/test/LuaJIT-tests/lang/index
> +++ b/test/LuaJIT-tests/lang/index
> @@ -9,6 +9,7 @@ constant
>   dualnum.lua
>   for.lua
>   hook_active.lua
> +hook_line.lua
>   length.lua
>   lightud.lua
>   modulo.lua
> diff --git a/test/LuaJIT-tests/misc/hook_line.lua b/test/LuaJIT-tests/misc/hook_line.lua
> deleted file mode 100644
> index 36f71080..00000000
> --- a/test/LuaJIT-tests/misc/hook_line.lua
> +++ /dev/null
> @@ -1,41 +0,0 @@
> -local lines = {}
> -local function hook()
> -  lines[#lines+1] = debug.getinfo(2).currentline
> -end
> -
> -local function dummy()
> -end -- <-- line 7
> -
> -debug.sethook(hook, "l", 0)
> --- <-- line 10
> -local x
> -dummy()
> -local y = 1
> -dummy() dummy()
> -local z = 2; local r = true
> -while y < 4 do y = y + 1 end
> -while z < 4 do
> -  z = z + 1
> -end
> --- <-- line 20
> -local v
> -debug.sethook(nil, "", 0)
> -
> -assert(#lines > 0)
> -while lines[1] < 10 do table.remove(lines, 1) end
> -while lines[#lines] > 20 do table.remove(lines) end
> -
> -local s = table.concat(lines, " ")
> -assert(s == "11 12 7 13 14 7 7 15 16 16 16 16 17 18 17 18 17" or
> -       s == "11 12 7 13 14 7 14 7 15 16 16 16 16 17 18 17 18 17")
> -
> -lines = {}
> -local function f()
> -  if true then return end
> -  local function x() end
> -end -- <-- line 36
> -debug.sethook(hook, "l", 0)
> -f()
> -debug.sethook(nil, "", 0)
> -for i=1,#lines do assert(lines[i] ~= 36) end
> -

[-- Attachment #2: Type: text/html, Size: 5055 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 14/36] test: enable <misc/hook_norecord.lua> LuaJIT test
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 14/36] test: enable <misc/hook_norecord.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-15 13:56   ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 13:56 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 2336 bytes --]

Hi, Sergey

thanks for the patch! LGTM


On 14.08.2024 16:55, Sergey Kaplun wrote:
> This patch moves the aforementioned test from the <misc> to the <trace/>
> directory, includes it in <index>, and names the subtest.
>
> The test is adjusted to be runable in the test suite by adding the
> `jit.flush()` to avoid collisions of traces.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/misc/hook_norecord.lua  | 12 ------------
>   test/LuaJIT-tests/trace/hook_norecord.lua | 12 ++++++++++++
>   test/LuaJIT-tests/trace/index             |  1 +
>   3 files changed, 13 insertions(+), 12 deletions(-)
>   delete mode 100644 test/LuaJIT-tests/misc/hook_norecord.lua
>   create mode 100644 test/LuaJIT-tests/trace/hook_norecord.lua
>
> diff --git a/test/LuaJIT-tests/misc/hook_norecord.lua b/test/LuaJIT-tests/misc/hook_norecord.lua
> deleted file mode 100644
> index 8e7cba05..00000000
> --- a/test/LuaJIT-tests/misc/hook_norecord.lua
> +++ /dev/null
> @@ -1,12 +0,0 @@
> -
> -if not jit or not jit.status or not jit.status() then return end
> -
> -local called = false
> -local function f() local x = "wrong"; called = true end
> -jit.off(f)
> -debug.sethook(f, "", 5)
> -for i=1,1000 do local a,b,c,d,e,f=1,2,3,4,5,6 end
> -assert(called)
> --- Check that no trace was generated.
> -assert(require("jit.util").traceinfo(1) == nil)
> -
> diff --git a/test/LuaJIT-tests/trace/hook_norecord.lua b/test/LuaJIT-tests/trace/hook_norecord.lua
> new file mode 100644
> index 00000000..4c39bade
> --- /dev/null
> +++ b/test/LuaJIT-tests/trace/hook_norecord.lua
> @@ -0,0 +1,12 @@
> +do --- Abort trace recording on any hook call.
> +  local called = false
> +  local function f() local x = "wrong"; called = true end
> +  jit.off(f)
> +  jit.flush()
> +  debug.sethook(f, "", 5)
> +  for _ = 1, 1000 do local a, b, c, d, e, f = 1, 2, 3, 4, 5, 6 end
> +  assert(called)
> +  -- Check that no trace was generated.
> +  assert(require("jit.util").traceinfo(1) == nil)
> +  debug.sethook()
> +end
> diff --git a/test/LuaJIT-tests/trace/index b/test/LuaJIT-tests/trace/index
> index 46c8f5d2..595a71d2 100644
> --- a/test/LuaJIT-tests/trace/index
> +++ b/test/LuaJIT-tests/trace/index
> @@ -3,6 +3,7 @@ exit_growstack.lua
>   exit_jfuncf.lua
>   gc.lua
>   gc64_slot_revival.lua
> +hook_norecord.lua
>   phi
>   snap.lua
>   stitch.lua

[-- Attachment #2: Type: text/html, Size: 2725 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 15/36] test: enable <misc/hook_record.lua> LuaJIT test
  2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 15/36] test: enable <misc/hook_record.lua> " Sergey Kaplun via Tarantool-patches
@ 2024-08-15 13:57   ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-15 13:57 UTC (permalink / raw)
  To: Sergey Kaplun, Maxim Kokryashkin; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 2101 bytes --]

Hi, Sergey!

Thanks for the patch!

On 14.08.2024 16:55, Sergey Kaplun wrote:
> This patch moves the aforementioned test from the <misc> to the <trace/>
> directory, includes it in <index>, and names the subtest.
+formatting changes
>
> The test is adjusted to be runable in the test suite by adding the
> `jit.flush()` to avoid collisions of traces. Also, the number of
> iterations for the compiled loop inside the hook is increased to avoid
> hotcount collisions.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/misc/hook_record.lua  | 8 --------
>   test/LuaJIT-tests/trace/hook_record.lua | 7 +++++++
>   test/LuaJIT-tests/trace/index           | 1 +
>   3 files changed, 8 insertions(+), 8 deletions(-)
>   delete mode 100644 test/LuaJIT-tests/misc/hook_record.lua
>   create mode 100644 test/LuaJIT-tests/trace/hook_record.lua
>
> diff --git a/test/LuaJIT-tests/misc/hook_record.lua b/test/LuaJIT-tests/misc/hook_record.lua
> deleted file mode 100644
> index 6f1646de..00000000
> --- a/test/LuaJIT-tests/misc/hook_record.lua
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -
> -if not jit or not jit.status or not jit.status() then return end
> -
> -debug.sethook(function() for i=1,100 do end end, "", 10)
> -for i=1,10 do end
> -debug.sethook()
> -assert((require("jit.util").traceinfo(1)))
> -
> diff --git a/test/LuaJIT-tests/trace/hook_record.lua b/test/LuaJIT-tests/trace/hook_record.lua
> new file mode 100644
> index 00000000..684e1139
> --- /dev/null
> +++ b/test/LuaJIT-tests/trace/hook_record.lua
> @@ -0,0 +1,7 @@
> +do --- Recording traces inside the hook.
> +  jit.flush()
> +  debug.sethook(function() for _ = 1, 1000 do end end, "", 10)
> +  for _ = 1, 10 do end
> +  debug.sethook()
> +  assert((require("jit.util").traceinfo(1)))
> +end
> diff --git a/test/LuaJIT-tests/trace/index b/test/LuaJIT-tests/trace/index
> index 595a71d2..63af7870 100644
> --- a/test/LuaJIT-tests/trace/index
> +++ b/test/LuaJIT-tests/trace/index
> @@ -4,6 +4,7 @@ exit_jfuncf.lua
>   gc.lua
>   gc64_slot_revival.lua
>   hook_norecord.lua
> +hook_record.lua
>   phi
>   snap.lua
>   stitch.lua

[-- Attachment #2: Type: text/html, Size: 2685 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 01/36] test: don't run JIT-based LuaJIT tests without JIT
  2024-08-15 12:47   ` Sergey Bronnikov via Tarantool-patches
@ 2024-08-19  8:47     ` Sergey Kaplun via Tarantool-patches
  0 siblings, 0 replies; 58+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2024-08-19  8:47 UTC (permalink / raw)
  To: Sergey Bronnikov; +Cc: tarantool-patches

Hi, Sergey!
Thanks for the review!

On 15.08.24, Sergey Bronnikov wrote:
> Hi, Sergey
> 
> thanks for the patch, LGTM.
> 
> See a minor comment below.
> 
> 
> Sergey
> 
> On 14.08.2024 16:55, Sergey Kaplun wrote:

<snipped>

> >     COMMAND ${LUAJIT_TEST_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/test.lua
> > -                                 +slow +ffi +bit +jit ${LUAJIT_TEST_TAGS_EXTRA}
> > +                                 +slow +ffi +bit ${LUAJIT_TEST_TAGS_EXTRA}
> 
> LUAJIT_TEST_TAGS_EXTRA is a list and to convert CMake list to a 
> whitespace-separated strings
> 
> a list should be put in double quotes.
> 
> However, I've run tests with options for avx512 and -DLUAJIT_NO_UNWIND=ON
> 
> and passing test flags works fine without double quotes.

With double quotes, these flags would be treated as "+jit +avx512"
instead of separate flags +jit +avx512, so I leave it as is.

> 
> >     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
> >   )
> >   set_tests_properties("${test_title}" PROPERTIES

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit 02/36] test: enable <misc/alias_alloc.lua> LuaJIT test
  2024-08-15 13:31     ` Sergey Kaplun via Tarantool-patches
@ 2024-08-30  7:25       ` Sergey Bronnikov via Tarantool-patches
  0 siblings, 0 replies; 58+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2024-08-30  7:25 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 890 bytes --]

Hi, Sergey,

On 15.08.2024 16:31, Sergey Kaplun wrote:
> Sergey,
>
> On 15.08.24, Sergey Bronnikov wrote:
>> Hi, Sergey
>>
>> Thanks for the patch! See my comments below.
>>
>> On 14.08.2024 16:55, Sergey Kaplun wrote:
>>> This patch moves the <alias_alloc.lua> test from the <misc> to the
>>> created <opt/mem> directory, includes it in <index>, and names subtests.
>>>
>>> Testing optimizations in <lj_opt_mem.c> requires CSE, DCE, FOLD, and FWD
>>> optimizations enabled. Hence, the corresponding flags are used for the
>>> <mem> directory in <index>.
>> It is still unclear for me *why* a reason of this change.
The main idea behind the patch is "getting rid of <misc> suite".
> The tests for other optimizations also require the necessary flags, see
> <index>. Also, I don't understand what *change* you mean -- it is
> enabling of test, not changing its functionality.
>
> <snipped>
>

[-- Attachment #2: Type: text/html, Size: 1876 bytes --]

^ permalink raw reply	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2024-08-30  7:25 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-14 13:55 [Tarantool-patches] [PATCH luajit 00/36] Rearrange LuaJIT misc tests Sergey Kaplun via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 01/36] test: don't run JIT-based LuaJIT tests without JIT Sergey Kaplun via Tarantool-patches
2024-08-15 12:47   ` Sergey Bronnikov via Tarantool-patches
2024-08-19  8:47     ` Sergey Kaplun via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 02/36] test: enable <misc/alias_alloc.lua> LuaJIT test Sergey Kaplun via Tarantool-patches
2024-08-15 12:51   ` Sergey Bronnikov via Tarantool-patches
2024-08-15 13:31     ` Sergey Kaplun via Tarantool-patches
2024-08-30  7:25       ` Sergey Bronnikov via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 03/36] test: refactor <lang/coroutine.lua> " Sergey Kaplun via Tarantool-patches
2024-08-15 13:00   ` Sergey Bronnikov via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 04/36] test: remove <misc/coro_yield.lua> " Sergey Kaplun via Tarantool-patches
2024-08-15 13:05   ` Sergey Bronnikov via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 05/36] test: enable <misc/debug_gc.lua> " Sergey Kaplun via Tarantool-patches
2024-08-15 13:09   ` Sergey Bronnikov via Tarantool-patches
2024-08-15 13:25     ` Sergey Kaplun via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 06/36] test: enable <misc/dualnum.lua> " Sergey Kaplun via Tarantool-patches
2024-08-15 13:11   ` Sergey Bronnikov via Tarantool-patches
2024-08-15 13:19     ` Sergey Bronnikov via Tarantool-patches
2024-08-15 13:22       ` Sergey Kaplun via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 07/36] test: remove <misc/fori_coerce.lua> " Sergey Kaplun via Tarantool-patches
2024-08-15 13:20   ` Sergey Bronnikov via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 08/36] test: remove <misc/fori_dir.lua> " Sergey Kaplun via Tarantool-patches
2024-08-15 13:21   ` Sergey Bronnikov via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 09/36] test: remove <misc/gc_rechain.lua> " Sergey Kaplun via Tarantool-patches
2024-08-15 13:22   ` Sergey Bronnikov via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 10/36] test: enable <misc/gc_trace.lua> " Sergey Kaplun via Tarantool-patches
2024-08-15 13:24   ` Sergey Bronnikov via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 11/36] test: enable <misc/gcstep.lua> " Sergey Kaplun via Tarantool-patches
2024-08-15 13:34   ` Sergey Bronnikov via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 12/36] test: enable <misc/hook_active.lua> " Sergey Kaplun via Tarantool-patches
2024-08-15 13:38   ` Sergey Bronnikov via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 13/36] test: enable <misc/hook_line.lua> " Sergey Kaplun via Tarantool-patches
2024-08-15 13:42   ` Sergey Bronnikov via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 14/36] test: enable <misc/hook_norecord.lua> " Sergey Kaplun via Tarantool-patches
2024-08-15 13:56   ` Sergey Bronnikov via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 15/36] test: enable <misc/hook_record.lua> " Sergey Kaplun via Tarantool-patches
2024-08-15 13:57   ` Sergey Bronnikov via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 16/36] test: enable <misc/hook_top.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:55 ` [Tarantool-patches] [PATCH luajit 17/36] test: enable <misc/jit_flush.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 18/36] test: remove <misc/loop_unroll.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 19/36] test: enable <misc/parse_comp.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 20/36] test: enable <misc/parse_esc.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 21/36] test: enable <misc/parse_misc.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 22/36] test: enable <misc/phi_conv.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 23/36] test: enable <misc/recurse_deep.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 24/36] test: remove <misc/recurse_tail.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 25/36] test: enable <misc/stack_gc.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 26/36] test: enable <misc/stack_purge.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 27/36] test: enable <misc/stackov.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 28/36] test: enable <misc/stackovc.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 29/36] test: enable <misc/tcall_base.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 30/36] test: enable <misc/tcall_loop.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 31/36] test: enable <misc/tonumber_scan.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 32/36] test: remove <misc/uclo.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 33/36] test: enable <misc/unordered_jit.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 34/36] test: enable <misc/wbarrier.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 35/36] test: enable <misc/wbarrier_jit.lua> " Sergey Kaplun via Tarantool-patches
2024-08-14 13:56 ` [Tarantool-patches] [PATCH luajit 36/36] test: enable <misc/wbarrier_obar.lua> " Sergey Kaplun via Tarantool-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox