Hi, Igor!
Thanks for the patch!
LGTM, except for the two nits below.
 
Четверг, 1 декабря 2022, 23:42 +03:00 от Igor Munkin <imun@tarantool.org>:
 
JIT engine setup in tarantool-tests/lj-430-maxirconst.test.lua is too
tight for the build with LUAJIT_ENABLE_CHECKHOOK option enabled.
Originally test limits <maxirconst> value with 3 for the default IRRef
constants set: nil, true, false. However, with LUAJIT_ENABLE_CHECKHOOK
enabled there are three more auxiliary IRRef constants for the internal
purposes. Hence, the test is reimplemented the following way:
* The first trace for the empty function is recorded
* The number of IRRef constants is obtained via <jit.util.traceinfo>
* <maxirconst> parameter is set to this value
* The second trace for the function with a single local variable,
  initialized with a constant, fails to record

As a result there is no need to explicitly respect any configuration.

Relates to tarantool/tarantool#7762

Signed-off-by: Igor Munkin <imun@tarantool.org>
---
 .../lj-430-maxirconst.test.lua | 23 +++++++++++--------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/test/tarantool-tests/lj-430-maxirconst.test.lua b/test/tarantool-tests/lj-430-maxirconst.test.lua
index cd3587a8..eaa0cd1b 100644
--- a/test/tarantool-tests/lj-430-maxirconst.test.lua
+++ b/test/tarantool-tests/lj-430-maxirconst.test.lua
@@ -1,8 +1,3 @@
--- XXX: avoid any other traces compilation due to hotcount
--- collisions for predictable results.
-jit.off()
-jit.flush()
-
 -- Disabled on *BSD due to #4819.
 require('utils').skipcond(jit.os == 'BSD', 'Disabled due to #4819')
 
@@ -12,10 +7,6 @@ local traceinfo = require('jit.util').traceinfo
 local test = tap.test('lj-430-maxirconst')
 test:plan(2)
 
--- XXX: trace always has at least 3 IR constants: for nil, false
--- and true.
-jit.opt.start('hotloop=1', 'maxirconst=3')
-
 -- This function has only 3 IR constant.
 local function irconst3()
 end
@@ -25,6 +16,12 @@ local function irconst4()
   local _ = 42
 end
 
+-- XXX: Avoid any other traces compilation due to hotcount
+-- collisions for predictable results.
+jit.off()
+jit.flush()
+jit.opt.start('hotloop=1')
+
 assert(not traceinfo(1), 'no traces compiled after flush')
 jit.on()
 irconst3()
@@ -32,6 +29,14 @@ irconst3()
 jit.off()
 test:ok(traceinfo(1), 'new trace created')
 
+-- XXX: Trace 1 always has at least 3 IR constants: for nil, false
+-- and true. In case when LUAJIT_ENABLE_CHECKHOOK is set to ON,
Typo: s/In case when/If/
+-- three more constants are emitted to the trace.
+-- Tight up <maxirconst> and try to record the next trace with one
Typo: s/Tight up/Tighten up/
+-- more constant to be emitted.
+jit.opt.start(('maxirconst=%d'):format(traceinfo(1).nk))
+
+assert(not traceinfo(2), 'only one trace is created to this moment')
 jit.on()
 irconst4()
 irconst4()
--
2.34.0
--
Best regards,
Maxim Kokryashkin