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 079F04F314A; Tue, 4 Jul 2023 14:50:30 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 079F04F314A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1688471430; bh=ohYYAdfR4x1G33o80XHI58++WI9tgKNnSryV+IxCKfs=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=xBIE/Exe6Xoa+7drBUnDyLu3n3sCK2Yv9UPxUYionNp6HWvQgOhmY316j8JzgIabl 93L2Ia/+woN8wq6sG4fNuE3ma81lkk/7SHHo10d0MS4H7men6Y1GJZypqa2EkA62RN I1IL6KR7pGqulsa/8B/Hv24uEqzRzAOTGW/+Q4gQ= Received: from smtp37.i.mail.ru (smtp37.i.mail.ru [95.163.41.78]) (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 CE6F14F314A for ; Tue, 4 Jul 2023 14:50:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CE6F14F314A Received: by smtp37.i.mail.ru with esmtpa (envelope-from ) id 1qGeY7-000owD-St; Tue, 04 Jul 2023 14:50:28 +0300 Date: Tue, 4 Jul 2023 11:41:38 +0000 To: Sergey Kaplun Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD986A068CB942B50D553E6247E0DC52B79BA8A07393C3583E2182A05F538085040658A9251EC0D98236809A24F58CD0DD791DC4B245EA867FFAC7338845154CCF4 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7FEAC828D2BF6EC3CEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B1AF1CB5CD5D34E98638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8DE1472315BF4B0D3A2CF209C5ACFC08E117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520C65AC60A1F0286FEC26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EED76C6ED7039589DE03CEA74F0D118906D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE367F1C1C3ABB44F3AAD7EC71F1DB88427C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637BC468E7E89D8C5D6EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A53604BB4D368D3DE7B742151BEAA7A4AD82EAFCBCFDB7A4BCF87CCE6106E1FC07E67D4AC08A07B9B0CE135D2742255B35CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFA27686C49E0E57FBC3EDAC4EDC6646B9DAB7BF09EEB1B80EE73C3921AC122A3CFA91ADFD12D7A65B09C04BAA40F94CC3B3DF79342B9A1C14E393433EB220033AA74DFFEFA5DC0E7F02C26D483E81D6BEECAEF3E2CCC1ED8C383653B6C8D9AE0FD16FCAA6493B703A X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojtu6fghEd2rVlMcWeT5TZWQ== X-Mailru-Sender: 2FEBA92C8E508479FE7B9A1DF348D531E0BE37304DB47DB3F3F6FBB996C97A614BC96AF660C6751F2326FE6F2A341ACE0FB9F97486540B4CD9E8847AB8CFED4D9ABF8A61C016C2CFB0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 2/2] Fix use-def analysis for vararg functions. 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: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Sergey, Thanks for the patch! LGTM, considering the fixes made to resolve the comments left by Max. I also applied the changes we discussed offline. On 09.06.23, Sergey Kaplun via Tarantool-patches wrote: > From: Mike Pall > > Reported by Shmuel Zeigerman. > > (cherry-picked from commit 0e53a314d7910898e1ea5ba90385d43e8a6c5e57) > > Use-def analysis for BC_FUNCV may consider slots greater than amount of > non-vararg parameters as dead slots due to early return for BC_RET Side note: mentioned BC_JMP here too. > emitted before usage of BC_VARG. This patch restricts the maxslot to be > analyzed in such case with amount of parameters for the prototype of the > current function being recorded. > > Sergey Kaplun: > * added the description and the test for the problem > > Part of tarantool/tarantool#8516 > Relates to tarantool/tarantool#8718 > --- > src/lj_snap.c | 6 +++-- > .../lj-704-bc-varg-use-def.test.lua | 27 ++++++++++++++++++- > 2 files changed, 30 insertions(+), 3 deletions(-) > > diff --git a/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua b/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua > index c3ba65dd..38606686 100644 > --- a/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua > +++ b/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua > @@ -6,7 +6,7 @@ local test = tap.test('lj-704-bc-varg-use-def'):skipcond({ > ['Test requires JIT enabled'] = not jit.status(), > }) > > -test:plan(1) > +test:plan(2) > > -- XXX: we don't really need to store this builtins, but this is > -- reduces `jitdump()` output for reader significantly. > @@ -62,4 +62,29 @@ wrap(ON_TRACE_VALUE) > > test:ok(result ~= 0, 'use-def analysis for BC_VARG') > > +-- Now check the same case, but with BC_RET before the BC_VARG, > +-- so use-def analysis will take early return case. > +-- See `snap_usedef()` in for details. > +-- The test checks that slots greater than `numparams` are not > +-- purged. > +local function varg_ret_bc(...) > + -- XXX: This branch contains BC_RET. See the comment above. > + -- luacheck: ignore > + if false then else end > + local slot = ({...})[1] > + return fmod(ARG_ON_RECORDING, slot) > +end > + > +local function wrap_ret_bc(arg) > + _, result = pcall(varg_ret_bc, arg) > +end > + > +-- Record trace with the 0 result. > +wrap_ret_bc(ARG_ON_RECORDING) > +wrap_ret_bc(ARG_ON_RECORDING) > +-- Record trace with the non-zero result. > +wrap_ret_bc(ON_TRACE_VALUE) > + > +test:ok(result ~= 0, 'use-def analysis for FUNCV with return before BC_VARG') Side note: Applied the changes we've discussed. The diff is below: ================================================================================ diff --git a/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua b/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua index 36fa450a..e6a0973b 100644 --- a/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua +++ b/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua @@ -62,17 +62,17 @@ wrap(ON_TRACE_VALUE) test:ok(result ~= 0, 'use-def analysis for BC_VARG') --- Now check the same case, but with BC_RET before the BC_VARG, +-- Now check the same case, but with BC_JMP before the BC_VARG, -- so use-def analysis will take early return case for BCMlit. -- See `snap_usedef()` in for details. -- The test checks that slots greater than `numparams` are not -- purged. local function varg_ret_bc(...) - -- XXX: This branch contains BC_RET. See the comment above. + -- XXX: This branch contains BC_JMP. See the comment above. -- luacheck: ignore if false then else end local slot = ({...})[1] - -- Forcify stitch and usage of vararg slot. Any NIY is OK here. + -- Forcify stitch and usage of vararg slot. Any NYI is OK here. return fmod(ARG_ON_RECORDING, slot) end @@ -88,6 +88,6 @@ wrap_ret_bc(ARG_ON_RECORDING) -- Record trace with the non-zero result. wrap_ret_bc(ON_TRACE_VALUE) -test:ok(result ~= 0, 'use-def analysis for FUNCV with return before BC_VARG') +test:ok(result ~= 0, 'use-def analysis for FUNCV with jump before BC_VARG') os.exit(test:check() and 0 or 1) ================================================================================ > + > os.exit(test:check() and 0 or 1) > -- > 2.34.1 > -- Best regards, IM