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 765376EFDA; Fri, 6 May 2022 07:56:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 765376EFDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1651812969; bh=EqM+ejGjlt0rCG0Zq+Yb4fjZ/X4hSCF3qkJlgqDy2xw=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=obN+5T1aBLO3LhH8aSUaCCzuR2AkfCv8gegA1+88p6J7GdJC0IhVnyp7MrFX1hTLM KMu2kmvA06jzv6bCaWyWYGlXWRYJ2jr5FBNoIkv8IUNz3vc8/zItMVj8TaCzi7Q7Dd iifTnU4EFrTYwjOC2PvlJnrL+t2M2HwDySBXDVRo= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (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 64D356EFDA for ; Fri, 6 May 2022 07:56:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 64D356EFDA Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1nmq0c-0008To-6B; Fri, 06 May 2022 07:56:06 +0300 To: Sergey Ostanevich , Igor Munkin Date: Fri, 6 May 2022 07:53:39 +0300 Message-Id: <20220506045339.8919-1-skaplun@tarantool.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD963EADE01D1044141B255DFDEB2151F572A3BD4678287E2A9182A05F5380850406B08097ED4D60295F1B9590D013FDACB79A8AC2D5894C73FD022FF31D21B570C X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7CB1634DB9A2F7B99EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006371E92E38DA2D50EB18638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D84F12EFD44ECEA3FFDD74B4F6AD4F3CC5117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC55B19328CBC4F849A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751FC26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6BF3059D42242344A089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-8FC586DF: 6EFBBC1D9D64D975 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C12A14A871D1BD86C480B4B360F362119C079A1C4C83DCD639C2B6934AE262D3EE7EAB7254005DCED96AFF475DEAA5226F36E2E0160E5C55395B8A2A0B6518DF68C46860778A80D548DA55E71E02F9FC08E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34E318F287A436F24CEAE7B5D70C02FC4FD77E31813A1460D7FE6C439AA1BAAF95161F6237111E619D1D7E09C32AA3244CBB1AB9CAC7361A2365347215BA2DF252795D98D676DD64D0927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXgxIkYxh3ndYyufrW1dHIJ0 X-Mailru-Sender: 689FA8AB762F739339CABD9B3CA9A7D6B328E0813A8283FEAAFFB89C33E5E56C0FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit] FFI: Handle zero-fill of struct-of-NYI. 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" From: Mike Pall Trace recording is NYI for the case of a struct with aggregate allocation. This patch adds workaround for the zero-fill struct-of-NYI case. Sergey Kaplun: * added the description and the test for the problem Related to tarantool/tarantool#4630 Related to tarantool/tarantool#5885 --- Issues: * https://github.com/LuaJIT/LuaJIT/issues/672 * https://github.com/tarantool/tarantool/issues/4630 * https://github.com/tarantool/tarantool/issues/5885 Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-672-cdata-allocation-recording-full-ci Tarantool PR: https://github.com/tarantool/tarantool/pull/7114 src/lj_crecord.c | 20 ++++++++++++- ...lj-672-cdata-allocation-recording.test.lua | 28 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/tarantool-tests/lj-672-cdata-allocation-recording.test.lua diff --git a/src/lj_crecord.c b/src/lj_crecord.c index 59186dab..0d7b71f0 100644 --- a/src/lj_crecord.c +++ b/src/lj_crecord.c @@ -1021,8 +1021,26 @@ static void crec_alloc(jit_State *J, RecordFFData *rd, CTypeID id) crec_ct_tv(J, dc, dp, sp, sval); } } else if (ctype_isstruct(d->info)) { - CTypeID fid = d->sib; + CTypeID fid; MSize i = 1; + if (!J->base[1]) { /* Handle zero-fill of struct-of-NYI. */ + fid = d->sib; + while (fid) { + CType *df = ctype_get(cts, fid); + fid = df->sib; + if (ctype_isfield(df->info)) { + CType *dc; + if (!gcref(df->name)) continue; /* Ignore unnamed fields. */ + dc = ctype_rawchild(cts, df); /* Field type. */ + if (!(ctype_isnum(dc->info) || ctype_isptr(dc->info) || + ctype_isenum(dc->info))) + goto special; + } else if (!ctype_isconstval(df->info)) { + goto special; + } + } + } + fid = d->sib; while (fid) { CType *df = ctype_get(cts, fid); fid = df->sib; diff --git a/test/tarantool-tests/lj-672-cdata-allocation-recording.test.lua b/test/tarantool-tests/lj-672-cdata-allocation-recording.test.lua new file mode 100644 index 00000000..28ad61e5 --- /dev/null +++ b/test/tarantool-tests/lj-672-cdata-allocation-recording.test.lua @@ -0,0 +1,28 @@ +-- Disabled on *BSD due to #4819. +require('utils').skipcond(jit.os == 'BSD', 'Disabled due to #4819') + +local ffi = require('ffi') +local traceinfo = require('jit.util').traceinfo + +local tap = require('tap') +local test = tap.test('lj-672-cdata-allocation-recording') +test:plan(1) + +-- Structure with array. +ffi.cdef('struct my_struct {int a; char d[8];}') + +-- Be sure that we have no other traces. +jit.off() +jit.flush() +jit.on() + +jit.opt.start("hotloop=1") +local r +for i = 1, 4 do + r = ffi.new('struct my_struct') + r.a = i +end + +test:ok(traceinfo(1), 'new trace created') + +os.exit(test:check() and 0 or 1) -- 2.34.1