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 196CA5C2D84; Mon, 28 Aug 2023 17:25:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 196CA5C2D84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1693232736; bh=IFfuePID02fT495BXzqcVzIAUIv0PKB5YsF/KZD6VxQ=; 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=BDhh9/nuKxtTbUnb3bwFfEfO90iAW8bsLObTY5+1H0TSBUOvmoUmoxW44h6otdJtl YeXWI3wOy15gFk6YXVJIXv3BeF+ES5eFeWXiyLcw92WU7M0OFBxnrEQUMNThKsWG1G 5hObSJ//GKFwTKdOPWbXhLO8gnI4tiTk4tto4ZkA= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [94.100.177.149]) (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 CB67A5BE742 for ; Mon, 28 Aug 2023 17:25:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CB67A5BE742 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1qadBO-00049w-0Q; Mon, 28 Aug 2023 17:25:34 +0300 Message-ID: <5c416cf4-f366-9f35-f05b-13f1c7679749@tarantool.org> Date: Mon, 28 Aug 2023 17:25:33 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US To: Sergey Kaplun , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: <20230817144641.20088-1-skaplun@tarantool.org> In-Reply-To: <20230817144641.20088-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: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9954329A9C7AF96E9646E0A6487A1D68BC215C32AB5CE3C3F182A05F538085040729D94D4F752EBA80CBA21B589F2288B541E59565E2F3831E1559C8DA75A3D46 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7811C3E343B302E2EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637F757A79C3007ACA28638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D849BF0A74B3DA8552C701770A4E5DAC89117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF80095D1ED7F4578A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18F04B652EEC242312D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269176DF2183F8FC7C0FE3A47D6FA29121068655334FD4449CB33AC447995A7AD1857739F23D657EF2BD5E8D9A59859A8B6045A9A90E9EED90B089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A5D48FD7EE02B10DB6B743D83B72129AA7800696E7FB627DA2F87CCE6106E1FC07E67D4AC08A07B9B0CE135D2742255B35CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFCF71EE7EBBCC5429B3BF6ADA8D857201A3481DAF7F52E72A6B364FFC8F654EEA6BD4E2D2DF3D40475088795BE90126481B70C88B5CD76C581895B0B6154F27C2E48CAC7CA610320002C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojrC6BcuK2ROx9WwE+znhqVw== X-DA7885C5: AF42CB5D40AEB30C311227101A35A3145D2A3662F3B3B2AA6B2A5E8B413ED5C2262E2D401490A4A0DB037EFA58388B346E8BC1A9835FDE71 X-Mailru-Sender: 689FA8AB762F73930F533AC2B33E986B68A16DABB8A5524782BC482C980128EBDD788429FD8613638ED9BB8B05EE7B3AFB559BB5D741EB96D19CD4E7312BAA970A04DAD6CC59E3365FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Fix TDUP load forwarding after table rehash. 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" Sergey, thanks for the patch. See my comment inline. On 8/17/23 17:46, Sergey Kaplun wrote: > +++ b/test/tarantool-tests/lj-980-load-fwd-after-table-rehash.test.lua > @@ -0,0 +1,166 @@ > +local tap = require('tap') > + > +-- Test file to demonstrate LuaJIT misbehaviour during load > +-- forwarding optimization for HLOAD after table rehashing. > +-- See also https://github.com/LuaJIT/LuaJIT/issues/980. > + > +local test = tap.test('lj-980-load-fwd-after-table-rehash'):skipcond({ > + ['Test requires JIT enabled'] = not jit.status(), > +}) > + > +test:plan(6) > + > +jit.opt.start('hotloop=1') > + > +local result > +-- The test for TNEW load forwarding. It doesn't trigger an assert > +-- since the commit "Fix TNEW load forwarding with instable > +-- types.". But still add it to avoid regressions in future. > +for i = 6, 9 do > + -- Need big enough table to see rehashing. > + -- Also, to simplify logic with AREF, HREF don't use default > + -- 1, 4 (start, stop) values here. > + local t = {i, i, i, i, i, i, i} > + -- Insert via ASTORE. > + t[i] = i > + t[1] = nil > + t[2] = nil > + t[3] = nil > + t[4] = nil > + t[5] = nil > + -- Rehash table. Array part is empty. > + t['1000'] = 1000 > + -- Load via HLOAD. > + result = t[i] > +end > + > +test:is(result, 9, 'TNEW load forwarding') > + > +-- TNEW load forwarding, aliased table. > +local alias_store = {{}, {}, {}, {}, {}} > +for i = 6, 9 do > + local t = {i, i, i, i, i, i, i} > + alias_store[#alias_store + 1] = t > + local alias = alias_store[i] > + -- Insert via ASTORE. > + alias[i] = i > + alias[1] = nil > + alias[2] = nil > + alias[3] = nil > + alias[4] = nil > + alias[5] = nil > + -- Rehash table. Array part is empty. > + alias['1000'] = 1000 > + -- Load via HLOAD. > + result = t[i] > +end > + > +test:is(result, 9, 'TNEW load forwarding, aliased table') > + > +local expected = 'result' > + > +-- TDUP different types. > +for i = 6, 9 do > + local t = {1, 2, 3, 4, 5, 6, 7, 8} > + t[i] = expected > + t[i + 1] = expected > + t[1] = nil > + t[2] = nil > + t[3] = nil > + t[4] = nil > + t[5] = nil > + t[6] = nil > + -- Rehash table. Array part is empty. > + t['1000'] = 1000 > + -- Result on the recording (i == 8) iteration is 'result'. > + -- Nevertheless, on the last (i == 9) iteration it is 8. > + -- Just check that there is no assert failure here. > + -- Load via HLOAD. > + result = t[8] > +end > + > +-- Checked for assertion guard, on the last iteration we get > +-- the value on initializatoin. > +test:is(result, 8, 'TDUP load forwarding different types') > + > +-- TDUP different types, aliased table. > +alias_store = {{}, {}, {}, {}, {}} > +for i = 6, 9 do > + local t = {1, 2, 3, 4, 5, 6, 7, 8} > + -- Store table, to be aliased later. > + alias_store[#alias_store + 1] = t > + local alias = alias_store[i] > + alias[i] = expected > + alias[i + 1] = expected > + alias[1] = nil > + alias[2] = nil > + alias[3] = nil > + alias[4] = nil > + alias[5] = nil > + alias[6] = nil > + -- Rehash table. Array part is empty. > + alias['1000'] = 1000 > + -- Result on the recording (i == 8) iteration is 'result'. > + -- Nevertheless, on the last (i == 9) iteration it is 8. > + -- Just check that there is no assert failure here. > + -- Load via HLOAD. > + result = t[8] > +end > + > +-- Checked for assertion guard, on the last iteration we get > +-- the value on initializatoin. > +test:is(result, 8, 'TDUP load forwarding different types, aliased table') > + > +-- TDUP same type, different values. > +for i = 6, 9 do > + local t = {1, 2, 3, 4, 5, 6, '7', '8'} > + t[i] = expected > + t[i + 1] = expected > + t[1] = nil > + t[2] = nil > + t[3] = nil > + t[4] = nil > + t[5] = nil > + t[6] = nil > + -- Rehash table. Array part is empty. > + t['1000'] = 1000 > + -- Result on the recording (i == 8) iteration is 'result'. > + -- Nevertheless, on the last (i == 9) iteration it is '8'. > + -- Just check that there is no assert failure here. > + -- Load via HLOAD. > + result = t[8] > +end > + > +-- Checked for assertion guard, on the last iteration we get > +-- the value on initializatoin. > +test:is(result, '8', 'TDUP load forwarding same type, different values') > + > +alias_store = {{}, {}, {}, {}, {}} > +for i = 6, 9 do > + local t = {1, 2, 3, 4, 5, 6, '7', '8'} > + -- Store table, to be aliased later. > + alias_store[#alias_store + 1] = t > + local alias = alias_store[i] > + alias[i] = expected > + alias[i + 1] = expected > + alias[1] = nil > + alias[2] = nil > + alias[3] = nil > + alias[4] = nil > + alias[5] = nil > + alias[6] = nil > + -- Rehash table. Array part is empty. > + alias['1000'] = 1000 > + -- Result on the recording (i == 8) iteration is 'result'. > + -- Nevertheless, on the last (i == 9) iteration it is '8'. > + -- Just check that there is no assert failure here. > + -- Load via HLOAD. > + result = t[8] > +end > + > +-- Checked for assertion guard, on the last iteration we get > +-- the value on initializatoin. > +test:is(result, '8', > + 'TDUP load forwarding same type, different values, aliased table') > + > +test:done(true) Is it possible to fold loop bodies to a single function? Otherwise it is too much duplicate code in the test.