From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Sergey Ostanevich <sergos@tarantool.org>, Igor Munkin <imun@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH luajit] FFI: Handle zero-fill of struct-of-NYI. Date: Fri, 6 May 2022 07:53:39 +0300 [thread overview] Message-ID: <20220506045339.8919-1-skaplun@tarantool.org> (raw) From: Mike Pall <mike> 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
next reply other threads:[~2022-05-06 4:56 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-06 4:53 Sergey Kaplun via Tarantool-patches [this message] 2022-06-21 13:44 ` sergos via Tarantool-patches 2022-06-29 8:02 ` Igor Munkin via Tarantool-patches 2022-06-30 12:11 ` Igor Munkin via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220506045339.8919-1-skaplun@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imun@tarantool.org \ --cc=sergos@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit] FFI: Handle zero-fill of struct-of-NYI.' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox