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 3E1C850944C; Thu, 13 Jul 2023 12:26:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3E1C850944C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1689240392; bh=YnocqaIOdFcioeGVD8PHRMF1oec1pXJJ439kyAiP4Uw=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=hSoOod+RMsRWVZj+eidtiASKXuNkHkgdlHR2CDYgFyZfrHmOPiY/25WxxYxPFjhOM ihNFLwoQ6rKPDKeJtcGlhgDHtHpYaZhnQrW7YYj0UT28iXdy+CX+Mp3Jm6kD1wiYyi Uqg3sBNGnivutRIwBXEGYEnkmtqJVMP7pb3CP53w= Received: from smtp45.i.mail.ru (smtp45.i.mail.ru [95.163.41.83]) (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 4617D4F62AF for ; Thu, 13 Jul 2023 12:26:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4617D4F62AF Received: by smtp45.i.mail.ru with esmtpa (envelope-from ) id 1qJsak-00A2aK-4u; Thu, 13 Jul 2023 12:26:30 +0300 Message-ID: Date: Thu, 13 Jul 2023 12:26:29 +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: Maksim Kokryashkin , tarantool-patches@dev.tarantool.org, skaplun@tarantool.org, m.kokryashkin@tarantool.org References: <20230710155624.70639-1-max.kokryashkin@gmail.com> In-Reply-To: <20230710155624.70639-1-max.kokryashkin@gmail.com> 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: 4F1203BC0FB41BD9B2A9E02D3479B2E030530512E484213E44D975DA6AA4DA3A182A05F538085040B7070907012248A0ED30305E4054DF446F8744B6F3CE8DEA57F918C0C92EB47C X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE788A2BECDB72E1542EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006374C960BD2D03BF0BDEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BE5CCB53A13BC8DBAA435717206067342013576CAF2A3C2BDCC7F00164DA146DAFE8445B8C89999728AA50765F790063783E00425F71A4181389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC824F796C710B8583CF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C2D01283D1ACF37BA2D242C3BD2E3F4C64AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C31DD302B0B79430F8BA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CF17B107DEF921CE791DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C369456C5265B6C55C35872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A5ED490C7C08B0965476126E2DBD5374B89CB11C67CFE69C9AF87CCE6106E1FC07E67D4AC08A07B9B06A1CB4668A9CA5FACB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF9338025C9CF24F60F9BBBA90AC99F8BF3C1B036221C200575B15A829C4432CF7A96D85E4AF70DF37399DF444199BC1D1D40D25795B3393810C7747A8A0BD41FBA74DFFEFA5DC0E7F02C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojmIyQFW4pVcl2c0rKr594bA== X-Mailru-Sender: 49D287FBCBBF3A5C1746B9497B71E89E0E1A604F68E883ABED30305E4054DF44A119395EB3F4142AEBA65886582A37BD66FEC6BF5C9C28D98A98C1125256619760D574B6FC815AB872D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] FFI: Fix recording of union initialization. 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, Max! thanks for the patch! See my comments inline. Sergey On 7/10/23 18:56, Maksim Kokryashkin wrote: > From: Mike Pall > > Thanks to Alex Shpilkin. > > (cherry-picked from commit 56c04accf975bff2519c34721dccbbdb7b8e6963) > > As stated here[1], only the first field of a union can be > initialized with a flat initializer. However, before this > patch, on-trace initialization instructions were emitted > for other union members too, overwriting the previous > initialization values. > > This patch fixes the mentioned behavior by preventing > initialization of members other than the first one. > > [1]: https://luajit.org/ext_ffi_semantics.html#init > > Maxim Kokryashkin: > * added the description and the test for the problem > > Part of tarantool/tarantool#8825 > --- > Branch: https://github.com/tarantool/luajit/tree/fckxorg/lj-128-fix-union-init > PR: https://github.com/tarantool/tarantool/pull/8867 > Original LuaJIT PR: https://github.com/LuaJIT/LuaJIT/pull/650 > > src/lj_crecord.c | 5 +++++ > .../lj-128-fix-union-init.test.lua | 18 ++++++++++++++++++ > 2 files changed, 23 insertions(+) > create mode 100644 test/tarantool-tests/lj-128-fix-union-init.test.lua > > diff --git a/src/lj_crecord.c b/src/lj_crecord.c > index 0008a865..ffe995f4 100644 > --- a/src/lj_crecord.c > +++ b/src/lj_crecord.c > @@ -1065,6 +1065,11 @@ static void crec_alloc(jit_State *J, RecordFFData *rd, CTypeID id) > dp = emitir(IRT(IR_ADD, IRT_PTR), trcd, > lj_ir_kintp(J, df->size + sizeof(GCcdata))); > crec_ct_tv(J, dc, dp, sp, sval); > + if ((d->info & CTF_UNION)) { > + if (d->size != dc->size) /* NYI: partial init of union. */ > + lj_trace_err(J, LJ_TRERR_NYICONV); > + break; > + } > } else if (!ctype_isconstval(df->info)) { > /* NYI: init bitfields and sub-structures. */ > lj_trace_err(J, LJ_TRERR_NYICONV); > diff --git a/test/tarantool-tests/lj-128-fix-union-init.test.lua b/test/tarantool-tests/lj-128-fix-union-init.test.lua > new file mode 100644 > index 00000000..6a49cec8 > --- /dev/null > +++ b/test/tarantool-tests/lj-128-fix-union-init.test.lua > @@ -0,0 +1,18 @@ > +local tap = require('tap') > +local test = tap.test('lj-128-fix-union-init'):skipcond({ > + ['Test requires JIT enabled'] = not jit.status(), > +}) > + > +local NITERATIONS = 4 > + > +test:plan(NITERATIONS) > + > +local ffi = require('ffi') > +local union_type = ffi.typeof('union { uint32_t u; float f; }') > + > +jit.opt.start('hotloop=1') > +for i = 1, NITERATIONS do > + test:ok(union_type(i).u == i) testcases description is missed, please add one. > +end > + > +os.exit(test:check() and 0 or 1)