<HTML><BODY><div>Hi, Sergey!</div><div>Thanks for the patch!</div><div>LGTM</div><div> </div><div data-signature-widget="container"><div data-signature-widget="content"><div>--<br>Best regards,</div><div>Maxim Kokryashkin</div></div></div><div> </div><div> </div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">Среда, 25 октября 2023, 16:18 +03:00 от Sergey Kaplun <skaplun@tarantool.org>:<br> <div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_16982399381637748140_BODY">From: Mike Pall <mike><br><br>(cherry-picked from commit 44bd7437a27e0d19bcf878c20ad27a673f17f40b)<br><br>When dumping IRs via `jit.dump()`, the incorrect value of `IR_CONV` mode<br>shift (`IRCONV_CSH`) is used. This patch fixes the value.<br><br>Sergey Kaplun:<br>* added the description and the test for the problem<br><br>Part of tarantool/tarantool#9145<br>---<br><br>Branch: <a href="https://github.com/tarantool/luajit/tree/skaplun/fix-ir-conv" target="_blank">https://github.com/tarantool/luajit/tree/skaplun/fix-ir-conv</a><br>Tarantool PR: <a href="https://github.com/tarantool/tarantool/pull/9307" target="_blank">https://github.com/tarantool/tarantool/pull/9307</a><br>Issue: <a href="https://github.com/tarantool/tarantool/issues/9145" target="_blank">https://github.com/tarantool/tarantool/issues/9145</a><br><br> src/jit/dump.lua | 2 +-<br> .../fix-jit-dump-ir-conv.test.lua | 68 +++++++++++++++++++<br> 2 files changed, 69 insertions(+), 1 deletion(-)<br> create mode 100644 test/tarantool-tests/fix-jit-dump-ir-conv.test.lua<br><br>diff --git a/src/jit/dump.lua b/src/jit/dump.lua<br>index 27b5c2ae..84fe0044 100644<br>--- a/src/jit/dump.lua<br>+++ b/src/jit/dump.lua<br>@@ -277,7 +277,7 @@ local litname = {<br>     local s = irtype[band(mode, 31)]<br>     s = irtype[band(shr(mode, 5), 31)].."."..s<br>     if band(mode, 0x800) ~= 0 then s = s.." sext" end<br>- local c = shr(mode, 14)<br>+ local c = shr(mode, 12)<br>     if c == 2 then s = s.." index" elseif c == 3 then s = s.." check" end<br>     t[mode] = s<br>     return s<br>diff --git a/test/tarantool-tests/fix-jit-dump-ir-conv.test.lua b/test/tarantool-tests/fix-jit-dump-ir-conv.test.lua<br>new file mode 100644<br>index 00000000..ed03210a<br>--- /dev/null<br>+++ b/test/tarantool-tests/fix-jit-dump-ir-conv.test.lua<br>@@ -0,0 +1,68 @@<br>+local tap = require('tap')<br>+local test = tap.test('fix-jit-dump-ir-conv'):skipcond({<br>+ ['Test requires JIT enabled'] = not jit.status(),<br>+ ['Disabled on *BSD due to #4819'] = jit.os == 'BSD',<br>+})<br>+<br>+test:plan(2)<br>+<br>+-- Test file to demonstrate LuaJIT incorrect `jit.dump()` output<br>+-- for `IR_CONV`.<br>+<br>+local jparse = require('utils').jit.parse<br>+<br>+-- XXX: Avoid any traces compilation due to hotcount collisions<br>+-- for predictable results.<br>+jit.off()<br>+jit.flush()<br>+<br>+jit.opt.start('hotloop=1')<br>+<br>+jit.on()<br>+jparse.start('i')<br>+<br>+-- luacheck: ignore<br>+local tab = {}<br>+local idx = 1<br>+for _ = 1, 4 do<br>+ -- `int IR_CONV int.num index`.<br>+ tab[idx] = idx<br>+end<br>+<br>+local traces = jparse.finish()<br>+<br>+-- Skip tests for DUALNUM mode since it has no conversions (for<br>+-- the same cases).<br>+local IS_DUALNUM = not traces[1]:has_ir('num SLOAD')<br>+<br>+test:ok(IS_DUALNUM or traces[1]:has_ir('CONV.*int.num index'),<br>+ 'correct dump for index')<br>+<br>+local function trace(step)<br>+ -- `int IR_CONV int.num check` for `step` conversion.<br>+ for _ = 1, 4, step do<br>+ end<br>+end<br>+<br>+-- XXX: Reset hotcounters and traces.<br>+jit.flush()<br>+jit.opt.start('hotloop=1')<br>+<br>+jparse.start('i')<br>+-- Compile the inner trace first.<br>+trace(1)<br>+-- Compile the big trace with the first trace inlined.<br>+-- Needs narrowing optimization enabled.<br>+-- XXX: Reset hotcounters and call the function 3 times to<br>+-- compile. Needed to avoid hotcount collisions.<br>+jit.opt.start('hotloop=1')<br>+trace(1)<br>+trace(1)<br>+trace(1)<br>+<br>+traces = jparse.finish()<br>+<br>+test:ok(IS_DUALNUM or traces[2]:has_ir('CONV.*int.num check'),<br>+ 'correct dump for check')<br>+<br>+test:done(true)<br>--<br>2.42.0</div></div></div></div></blockquote><div> </div></BODY></HTML>