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 9E6E6704267; Fri, 17 Nov 2023 14:06:19 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9E6E6704267 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1700219179; bh=mWqbT7qC5fGEay/9WayUMZTrzX0obWeoUL3ksj/Jg4w=; 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=FeF/f5zIFSAnz4f8HJjFgUd+l8dq8oggiMVbYSVm3p4hfPvPPN4B3JsvKqHQLyKW7 TP1sAE81FHgKcn8EMsxGSO3eefgnmB/imDlzfSme964JC/9AmtTXLNSCaL5sF/HVDl GouX/X/MZaAYuks24KFyW8ZbNoIxj16NrgSeqNPo= Received: from smtp41.i.mail.ru (smtp41.i.mail.ru [95.163.41.64]) (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 A04AE704267 for ; Fri, 17 Nov 2023 14:06:18 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A04AE704267 Received: by smtp41.i.mail.ru with esmtpa (envelope-from ) id 1r3wfx-000NGs-3C; Fri, 17 Nov 2023 14:06:18 +0300 Date: Fri, 17 Nov 2023 14:06:17 +0300 To: Sergey Kaplun Message-ID: <63wme32y5vhefounhsk2bkebl35lgselb3rcgimt6q3pr3qdgn@cxzb66tgqzzj> References: <20231114150455.2850-1-skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231114150455.2850-1-skaplun@tarantool.org> X-Mailru-Src: smtp X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9C2A6B03AB739174C171FA80BEFECDF07AC0ED2A73142B32500894C459B0CD1B94B319B522B647AF71CD45867CFEE8BD4EB70145B4A64A707039F47AC1EBC7B57 X-C1DE0DAB: 0D63561A33F958A56F24D53728FFD44C4F9FE18848183B6367725044FBC5C6C9F87CCE6106E1FC07E67D4AC08A07B9B02A336C6518635091CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0AD5177F0B940C8B66ECE892A7B2722663E91682638B966EB3F662256BEEFA9527F4A14289AAB5523864F84CCE767C09E61337756943FFD8DF856F1C580996AFEFDD05D3257C3AD488937FD76D11AF80A0D13A7DE74B2ADCE0E69571C4056B735A4EA455F16B58544A2557BDE0DD54B3590965026E5D17F6739C77C69D99B9914278E50E1F0597A6FD5CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojWWC/ZYCun+UCIFLXa9v6Dg== X-Mailru-Sender: 11C2EC085EDE56FA38FD4C59F7EFE407E61DA513592183B52C30FF22E5626E4D058B4CC93B12BFF9D51284F0FE6F529ABC7555A253F5B200DF104D74F62EE79D27EC13EC74F6107F4198E0F3ECE9B5443453F38A29522196 X-Mras: OK Subject: Re: [Tarantool-patches] [PATCH luajit] Fix FOLD rule for BUFHDR append. 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: Maxim Kokryashkin via Tarantool-patches Reply-To: Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! LGTM, except for a few nits below. On Tue, Nov 14, 2023 at 06:04:55PM +0300, Sergey Kaplun wrote: > From: Mike Pall > > Reported by XmiliaH. > > (cherry-picked from commit bc1bdbf620f58f0978385828bc51272903601e17) > > `bufput_append()` may fold `BUFHDR RESET` + `BUFPUT` IRs to `BUFHDR > APPEND` even if the right operand (`BUFSTR`) is the PHI. If it's not the > last IR in the `BUFSTR` chain, this may lead to an incorrect resulting > value in the buffer, which contains a longer string since `APPEND` is > used instead of `RESET`. > > This patch adds the corresponding check inside the fold rule. > > Sergey Kaplun: > * added the description and the test for the problem > > Part of tarantool/tarantool#9145 > --- > > Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-791-fold-bufhdr-append > Tarantool PR: https://github.com/tarantool/tarantool/pull/9369 > Relate issues: > * https://github.com/LuaJIT/LuaJIT/issues/791 > * https://github.com/tarantool/tarantool/issues/9145 > > src/lj_opt_fold.c | 3 +- > .../lj-791-fold-bufhdr-append.test.lua | 54 +++++++++++++++++++ > 2 files changed, 56 insertions(+), 1 deletion(-) > create mode 100644 test/tarantool-tests/lj-791-fold-bufhdr-append.test.lua > > diff --git a/src/lj_opt_fold.c b/src/lj_opt_fold.c > index 944a9ecc..910cbc14 100644 > --- a/src/lj_opt_fold.c > +++ b/src/lj_opt_fold.c > diff --git a/test/tarantool-tests/lj-791-fold-bufhdr-append.test.lua b/test/tarantool-tests/lj-791-fold-bufhdr-append.test.lua > new file mode 100644 > index 00000000..b2422159 > --- /dev/null > +++ b/test/tarantool-tests/lj-791-fold-bufhdr-append.test.lua > @@ -0,0 +1,54 @@ > +-- XXX: Use 5 iterations to run variant part of the loop. Typo: s/variant/the variant/ > +for _ = 1, 5 do > + result = prefix .. 'a' > + -- We need a non-constant string to be appended to prevent more > + -- aggressive optimizations. Use an empty string for > + -- convenience. Also, use a constant string in the first operand > + -- in the concatenation operator for more readable `jit.dump` > + -- output. > + prefix = 'Lu' .. EMPTY_STR > +end > + > +test:is(result, 'Lua', 'skipped BUFPUT APPEND optimization for PHIs') The test description is a bit misleading. At first glance it reads like the `BUFPUT APPEND` itself is skipped. I suggest paraphrasing it like this: "BUFPUT APPEND optimization is not applied for PHIs" > + > +test:done(true) > -- > 2.42.0 >