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 E5A9F6B63EC; Mon, 13 Nov 2023 10:42:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E5A9F6B63EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1699861348; bh=dZqHYyM4b4hZbpIcOa2donG/cEbHuO61iCLFdzvOd34=; 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=ftrifUI7piIvgoVo5KRBE7xdb0KXXMX4FlbxpOVrMGvvT7d5LqaBPMpQDXTBaLFjI TLPMrOGI30IIJuvfT48OLzxdMIqirFhkLuimHwqldFO8QdxpA+3zjN24kAf1/FvXv/ bp3wjYHzcfKBPwPI9lCRqjnlimkWtttTiOW11JLY= Received: from smtp49.i.mail.ru (smtp49.i.mail.ru [95.163.41.91]) (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 C016C6B63EC for ; Mon, 13 Nov 2023 10:42:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C016C6B63EC Received: by smtp49.i.mail.ru with esmtpa (envelope-from ) id 1r2RaT-00GiF1-0j; Mon, 13 Nov 2023 10:42:25 +0300 Date: Mon, 13 Nov 2023 10:37:51 +0300 To: Maxim Kokryashkin Message-ID: References: <20231109122628.19853-1-skaplun@tarantool.org> <5yynouo6jw5w27gtvrjqddg52in6wam6aqdcvptay4ivpq36bf@ng2qvitlre4f> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5yynouo6jw5w27gtvrjqddg52in6wam6aqdcvptay4ivpq36bf@ng2qvitlre4f> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9C2A6B03AB739174C41E32B7F3924B75BC7EF419B257543A400894C459B0CD1B9172AF72CC626465810B19E8CA559ACF3F36F8A1D28080EB9FC108E89ABB85EB9 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE795530B80AF2ADB7BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006372D9C4B6214E2BA508638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8AD59DAC335EF511EFA707F138D76C080117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE437C869540D2AB0F9935A1E27F592749D8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE3ABB3490C75E89280C0837EA9F3D19764C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CD2DCF9CF1F528DBC2E808ACE2090B5E1725E5C173C3A84C317B107DEF921CE79089D37D7C0E48F6C8AA50765F7900637AEEE038640289DEEEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A58072BF19DF0EB7CEA3F51EF58E40D19744F832A2B2FFB660F87CCE6106E1FC07E67D4AC08A07B9B065B78C30F681404DCB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF236A7A28D011D2F5F8F0392ECEFF24F15A67660D1A0A3DDAE367ACC72A43AAA3B268D298D11CBB1A72E3BA27337121358349D6D4A3EC71B46EB3B7049B937E84E48CAC7CA610320002C26D483E81D6BE5EF9655DD6DEA7D65774BB76CC95456EEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojg8Y/IM6oQGKev7j/jB2GIg== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A769593559D5FFDAB35A485E71EC258E5A727AD558DE3329E344DEDBA653FF35249392D99EB8CC7091A70E183A470755BFD208F19895AA18418972D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Fix HREFK forwarding vs. table.clear(). 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" Hi, Maxim! Thanks for the review! Fixed your comments inline and force-pushed the branch. See the iterative patch below. On 10.11.23, Maxim Kokryashkin wrote: > Hi, Sergey! > Thanks for the patch! > Please consider my comments below. > > > > > diff --git a/test/tarantool-tests/lj-792-hrefk-table-clear.test.lua b/test/tarantool-tests/lj-792-hrefk-table-clear.test.lua > > new file mode 100644 > > index 00000000..e662e0cc > > --- /dev/null > > +++ b/test/tarantool-tests/lj-792-hrefk-table-clear.test.lua > > > > > +jit.opt.start('hotloop=1') > > + > > +-- First compile the trace with a clearing not-interesting table. > It is better to rephrase it the following way: > | First, compile the trace that clears the not-interesting table. > Otherwise, `clearing` seems to be an adjective referring to the table. > Here and below. Fixed, thanks! > > +test_aref_fwd_tnew(2) > > +-- Now run the trace with the clearing table, from which we take > > +-- AREF. > Same rephrasing required. Here and below. Changed to "run the trace and clear the table ...". > > +test:is(test_aref_fwd_tnew(1), nil, 'AREF forward from TNEW') > > + > > +-- XXX: Reset hotcounters to avoid collisions. > > +jit.opt.start('hotloop=1') > > + > > +-- First compile the trace with a clearing not-interesting table. > > +test_aref_fwd_tdup(2) > > +-- Now run the trace with the clearing table, from which we take > > +-- AREF. > > +test:is(test_aref_fwd_tdup(1), nil, 'AREF forward from TDUP') > > + > > +-- XXX: Reset hotcounters to avoid collisions. > > +jit.opt.start('hotloop=1') > > + > > +-- First compile the trace with a clearing not-interesting table. > > +test_href_fwd_tnew(2) > > +-- Now run the trace with the clearing table, from which we take > > +-- HREF. > > +test:is(test_href_fwd_tnew(1), nil, 'HREF forward from TNEW') > > + > > +-- XXX: Reset hotcounters to avoid collisions. > > +jit.opt.start('hotloop=1') > > + > > +-- First compile the trace with a clearing not-interesting table. > > +test_href_fwd_tdup(2) > > +-- Now run the trace with the clearing table, from which we take > > +-- HREF. > > +test:is(test_href_fwd_tdup(1), nil, 'HREF forward from TDUP') > > Maybe we can just iterate over those cases in a loop? > If it breaks the semantics, then feel free to ignore. Yes, the loop itself can have side effects, so I prefere to ignore it. > > > +local function test_not_dropped_guard_on_hrefk(tab_number) > > + local tab, field_value_after_clear > > + for _ = 1, NITERATIONS do > > + -- Create a table on trace to make the optimization work. > > + tab = {hrefk = MAGIC} > > + -- Use an additional table to alias the created table with the > > + -- `hrefk` key. > > + local tab_array = {tab, {hrefk = 0}} > > + table_clear(tab_array[tab_number]) > > + -- It should be `nil`, since it is cleared. > > + -- If the guard is dropped for HREFK, the value from the TDUP > > + -- table is taken instead, without the type check. This leads > > + -- to incorrect (swapped) returned values. > Typo: s/incorrect (swapped) returned/incorrectly returned (swapped)/ Fixed. > > + field_value_after_clear = tab.hrefk > > + tab.hrefk = MAGIC > > + end > > + return field_value_after_clear, tab.hrefk > > +end > > Let's move those test case definitions to be right after the ones above, > that would be more consistent. Done. > > + > > +-- XXX: Reset hotcounters to avoid collisions. > > +jit.opt.start('hotloop=1') > > + > > +-- First compile the trace with clearing not interesting table. > > +test_not_dropped_guard_on_hrefk(2) > > +-- Now run the trace with the clearing table, from which we take > > +-- HREFK. > > +local field_value_after_clear, tab_hrefk = test_not_dropped_guard_on_hrefk(1) > > + > > +test:is(field_value_after_clear, nil, 'correct field value after table.clear') > > +test:is(tab_hrefk, MAGIC, 'correct value set in the table that was cleared') > > + > > +test:done(true) > > -- > > 2.42.0 > > =================================================================== diff --git a/test/tarantool-tests/lj-792-hrefk-table-clear.test.lua b/test/tarantool-tests/lj-792-hrefk-table-clear.test.lua index e662e0cc..e1fbc2ed 100644 --- a/test/tarantool-tests/lj-792-hrefk-table-clear.test.lua +++ b/test/tarantool-tests/lj-792-hrefk-table-clear.test.lua @@ -83,41 +83,6 @@ local function test_href_fwd_tdup(tab_number) return field_value_after_clear end -jit.opt.start('hotloop=1') - --- First compile the trace with a clearing not-interesting table. -test_aref_fwd_tnew(2) --- Now run the trace with the clearing table, from which we take --- AREF. -test:is(test_aref_fwd_tnew(1), nil, 'AREF forward from TNEW') - --- XXX: Reset hotcounters to avoid collisions. -jit.opt.start('hotloop=1') - --- First compile the trace with a clearing not-interesting table. -test_aref_fwd_tdup(2) --- Now run the trace with the clearing table, from which we take --- AREF. -test:is(test_aref_fwd_tdup(1), nil, 'AREF forward from TDUP') - --- XXX: Reset hotcounters to avoid collisions. -jit.opt.start('hotloop=1') - --- First compile the trace with a clearing not-interesting table. -test_href_fwd_tnew(2) --- Now run the trace with the clearing table, from which we take --- HREF. -test:is(test_href_fwd_tnew(1), nil, 'HREF forward from TNEW') - --- XXX: Reset hotcounters to avoid collisions. -jit.opt.start('hotloop=1') - --- First compile the trace with a clearing not-interesting table. -test_href_fwd_tdup(2) --- Now run the trace with the clearing table, from which we take --- HREF. -test:is(test_href_fwd_tdup(1), nil, 'HREF forward from TDUP') - local function test_not_forwarded_hrefk_val_from_newref(tab_number) local field_value_after_clear for _ = 1, NITERATIONS do @@ -135,18 +100,6 @@ local function test_not_forwarded_hrefk_val_from_newref(tab_number) return field_value_after_clear end --- XXX: Reset hotcounters to avoid collisions. -jit.opt.start('hotloop=1') - --- First compile the trace with a clearing not-interesting table. -test_not_forwarded_hrefk_val_from_newref(2) --- Now run the trace with the clearing table, from which we take --- HREFK. -local value_from_cleared_tab = test_not_forwarded_hrefk_val_from_newref(1) - -test:is(value_from_cleared_tab, nil, - 'not forward the field value across table.clear') - local function test_not_dropped_guard_on_hrefk(tab_number) local tab, field_value_after_clear for _ = 1, NITERATIONS do @@ -159,19 +112,62 @@ local function test_not_dropped_guard_on_hrefk(tab_number) -- It should be `nil`, since it is cleared. -- If the guard is dropped for HREFK, the value from the TDUP -- table is taken instead, without the type check. This leads - -- to incorrect (swapped) returned values. + -- to incorrectly returned (swapped) values. field_value_after_clear = tab.hrefk tab.hrefk = MAGIC end return field_value_after_clear, tab.hrefk end +jit.opt.start('hotloop=1') + +-- First, compile the trace that clears the not-interesting table. +test_aref_fwd_tnew(2) +-- Now run the trace and clear the table, from which we take AREF. +test:is(test_aref_fwd_tnew(1), nil, 'AREF forward from TNEW') + +-- XXX: Reset hotcounters to avoid collisions. +jit.opt.start('hotloop=1') + +-- First, compile the trace that clears the not-interesting table. +test_aref_fwd_tdup(2) +-- Now run the trace and clear the table, from which we take AREF. +test:is(test_aref_fwd_tdup(1), nil, 'AREF forward from TDUP') + +-- XXX: Reset hotcounters to avoid collisions. +jit.opt.start('hotloop=1') + +-- First, compile the trace that clears the not-interesting table. +test_href_fwd_tnew(2) +-- Now run the trace and clear the table, from which we take HREF. +test:is(test_href_fwd_tnew(1), nil, 'HREF forward from TNEW') + +-- XXX: Reset hotcounters to avoid collisions. +jit.opt.start('hotloop=1') + +-- First, compile the trace that clears the not-interesting table. +test_href_fwd_tdup(2) +-- Now run the trace and clear the table, from which we take HREF. +test:is(test_href_fwd_tdup(1), nil, 'HREF forward from TDUP') + +-- XXX: Reset hotcounters to avoid collisions. +jit.opt.start('hotloop=1') + +-- First, compile the trace that clears the not-interesting table. +test_not_forwarded_hrefk_val_from_newref(2) +-- Now run the trace and clear the table, from which we take +-- HREFK. +local value_from_cleared_tab = test_not_forwarded_hrefk_val_from_newref(1) + +test:is(value_from_cleared_tab, nil, + 'not forward the field value across table.clear') + -- XXX: Reset hotcounters to avoid collisions. jit.opt.start('hotloop=1') --- First compile the trace with clearing not interesting table. +-- First, compile the trace that clears the not-interesting table. test_not_dropped_guard_on_hrefk(2) --- Now run the trace with the clearing table, from which we take +-- Now run the trace and clear the table, from which we take -- HREFK. local field_value_after_clear, tab_hrefk = test_not_dropped_guard_on_hrefk(1) =================================================================== -- Best regards, Sergey Kaplun