From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id D13BF6AF5D4; Wed, 25 Oct 2023 16:19:00 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D13BF6AF5D4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1698239941; bh=zXcfPRV0/zwhsXzbEjTOCWMmWwRipmZkU5ygg4Q5zlk=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=QUH5HkC6inXKutKd1WX0BDfgtDK8wshkrtagvdq0VoykwAq4Ver4hAqM2fy2FqypB 8vUx/WTj1HmELrtv7M3DlDN0Qlpv/WQwiQoKSB2zO86wGSqz/1+g+YuSfJ4oFnW8w8 rPKaCHqmi2F6muCVHiEFmPomNBV3RvoQNqO8qX6U= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 3AF2A6AF5D4 for ; Wed, 25 Oct 2023 16:18:59 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3AF2A6AF5D4 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1qvdmk-0007sQ-4l; Wed, 25 Oct 2023 16:18:58 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Wed, 25 Oct 2023 16:14:28 +0300 Message-ID: <20231025131428.4124-1-skaplun@tarantool.org> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9315D6E1B1B5C3D6D0D2A7EF9CEBBEFF06750956A1DCE3C9900894C459B0CD1B9C19E9C60CF9460CCE19115D3C46B6628160E60A29CC0B26EACA8F312C2F0F594 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE70EEC24FFE855BCBBC2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE7E4A9B39A8BCE3A99EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BE5CCB53A13BC8DBA16D60F3EB0751731852CAE1EB2247879CC7F00164DA146DAFE8445B8C89999728AA50765F79006377C70927E34808485389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC886A7C529F68B8E5CF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE33AC447995A7AD182315B90ADEC130413A03B725D353964B2FFDA4F57982C5F435872C767BF85DA227C277FBC8AE2E8BF8ED170A0960FA5675ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A5EE5F6DEDD0FC2561139E2F97F262AAF7D1183A95BB7D6BF1F87CCE6106E1FC07E67D4AC08A07B9B0E753FA5741D1AD029C5DF10A05D560A950611B66E3DA6D700B0A020F03D25A0997E3FB2386030E77 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF77DD89D51EBB7742D3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF0BBBD717BD8FB44FBF2F2E3667129A7495712C47ABEA12B1BF15E0608240E980A54F2CFF063EE8C0A789783558ABFE9C9E116FA1359B3B798CD237303CF6187EA74DFFEFA5DC0E7F02C26D483E81D6BE5EF9655DD6DEA7D65774BB76CC95456EEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXioYAZ1G5Isp2XU8nyBRTtf X-DA7885C5: DDD3FEB7B88471A8ABAA3A5E4DB1768064891E93C094ACD55BEF54C2D9C455F1262E2D401490A4A0DB037EFA58388B346E8BC1A9835FDE71 X-Mailru-Sender: 689FA8AB762F73930F533AC2B33E986B791DC5D19991DE510A00F9A622A7ABAD0FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit] Fix jit.dump() output for IR_CONV. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" From: Mike Pall (cherry-picked from commit 44bd7437a27e0d19bcf878c20ad27a673f17f40b) When dumping IRs via `jit.dump()`, the incorrect value of `IR_CONV` mode shift (`IRCONV_CSH`) is used. This patch fixes the value. Sergey Kaplun: * added the description and the test for the problem Part of tarantool/tarantool#9145 --- Branch: https://github.com/tarantool/luajit/tree/skaplun/fix-ir-conv Tarantool PR: https://github.com/tarantool/tarantool/pull/9307 Issue: https://github.com/tarantool/tarantool/issues/9145 src/jit/dump.lua | 2 +- .../fix-jit-dump-ir-conv.test.lua | 68 +++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 test/tarantool-tests/fix-jit-dump-ir-conv.test.lua diff --git a/src/jit/dump.lua b/src/jit/dump.lua index 27b5c2ae..84fe0044 100644 --- a/src/jit/dump.lua +++ b/src/jit/dump.lua @@ -277,7 +277,7 @@ local litname = { local s = irtype[band(mode, 31)] s = irtype[band(shr(mode, 5), 31)].."."..s if band(mode, 0x800) ~= 0 then s = s.." sext" end - local c = shr(mode, 14) + local c = shr(mode, 12) if c == 2 then s = s.." index" elseif c == 3 then s = s.." check" end t[mode] = s return s diff --git a/test/tarantool-tests/fix-jit-dump-ir-conv.test.lua b/test/tarantool-tests/fix-jit-dump-ir-conv.test.lua new file mode 100644 index 00000000..ed03210a --- /dev/null +++ b/test/tarantool-tests/fix-jit-dump-ir-conv.test.lua @@ -0,0 +1,68 @@ +local tap = require('tap') +local test = tap.test('fix-jit-dump-ir-conv'):skipcond({ + ['Test requires JIT enabled'] = not jit.status(), + ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', +}) + +test:plan(2) + +-- Test file to demonstrate LuaJIT incorrect `jit.dump()` output +-- for `IR_CONV`. + +local jparse = require('utils').jit.parse + +-- XXX: Avoid any traces compilation due to hotcount collisions +-- for predictable results. +jit.off() +jit.flush() + +jit.opt.start('hotloop=1') + +jit.on() +jparse.start('i') + +-- luacheck: ignore +local tab = {} +local idx = 1 +for _ = 1, 4 do + -- `int IR_CONV int.num index`. + tab[idx] = idx +end + +local traces = jparse.finish() + +-- Skip tests for DUALNUM mode since it has no conversions (for +-- the same cases). +local IS_DUALNUM = not traces[1]:has_ir('num SLOAD') + +test:ok(IS_DUALNUM or traces[1]:has_ir('CONV.*int.num index'), + 'correct dump for index') + +local function trace(step) + -- `int IR_CONV int.num check` for `step` conversion. + for _ = 1, 4, step do + end +end + +-- XXX: Reset hotcounters and traces. +jit.flush() +jit.opt.start('hotloop=1') + +jparse.start('i') +-- Compile the inner trace first. +trace(1) +-- Compile the big trace with the first trace inlined. +-- Needs narrowing optimization enabled. +-- XXX: Reset hotcounters and call the function 3 times to +-- compile. Needed to avoid hotcount collisions. +jit.opt.start('hotloop=1') +trace(1) +trace(1) +trace(1) + +traces = jparse.finish() + +test:ok(IS_DUALNUM or traces[2]:has_ir('CONV.*int.num check'), + 'correct dump for check') + +test:done(true) -- 2.42.0