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 15B4B6C4149; Wed, 8 Nov 2023 22:29:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 15B4B6C4149 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1699471755; bh=0Xi12IZhHl2XleNr7rdNi37dKmZKlsTvUXqOQbsyJMQ=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=jA+m1xWuquNRqRA33xlnsEQ7pX2LJdEDdXwesrdwLMRAsoEdf+ja+HB7wKE6CTnQ4 8nYPzeIIrzzK5rCzKIq7SAPk4zKRnrGvM5FtTW3bBh83zKb9O1vf8gA+fFiDjhqouI 2ekRqwoJTVKMg2KKCdXO33e5K21MAoZeL9MF5jfg= Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [95.163.41.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 3F9401BE9A1 for ; Wed, 8 Nov 2023 22:29:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3F9401BE9A1 Received: by smtp55.i.mail.ru with esmtpa (envelope-from ) id 1r0oEj-004kvd-14; Wed, 08 Nov 2023 22:29:13 +0300 Message-ID: <0595e223-203f-4665-b47f-09d6f2a7bf82@tarantool.org> Date: Wed, 8 Nov 2023 22:29:11 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: <20231025131428.4124-1-skaplun@tarantool.org> In-Reply-To: <20231025131428.4124-1-skaplun@tarantool.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9C2A6B03AB739174C8B8ADBDCDAD54AB847BB7A66D7B1BE8200894C459B0CD1B95638EC5ADFA2AC65D519F96286A3D78A8E5CD5AC48CB5B8D00FA531A9826DDA8 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7FBCED7D376B82B5EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637543EE1E955FF04C98638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D847DEDE695E8F542B6065338CC17B60D4117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCECADA55FE5B58BB7A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751FF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947CE753FA5741D1AD0203F1AB874ED890284AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C3D425CE5E6A05270FBA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CF27ED053E960B195E1DD303D21008E298D5E8D9A59859A8B6957A4DEDD2346B4275ECD9A6C639B01B78DA827A17800CE713870684F8701956731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A54B816A353528964A1E5D298AC6312C76C6EC20BF4CFA3F44F87CCE6106E1FC07E67D4AC08A07B9B0CE135D2742255B35CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFC729328B2EB093D39C2F3B10D3D6C23F1DFCA3D21D85891D29F9893EBB138404B2CCF8B0FF448A892B33B16BC67043E026DA21FEEBBC82D886058162953382EFE48CAC7CA610320002C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojGx6zOZpnTNAplVri/E+xEQ== X-Mailru-Sender: C4F68CFF4024C8867DFDF7C7F2588458FA0CE8E7A3E3B59B4956D456365170BFBB0807D5F86E48B6282EC151BADDC1D3523A6D01B4765B2DFB59E2DDD9FE06B14FA522850F29BC30B0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [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 Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! Thanks for the patch! LGTM On 10/25/23 16:14, Sergey Kaplun wrote: > 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)