From: Igor Munkin via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Sergey Kaplun <skaplun@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH luajit] Fix IR_BUFPUT assembly. Date: Tue, 20 Jul 2021 01:25:33 +0300 [thread overview] Message-ID: <20210719222533.GG11494@tarantool.org> (raw) In-Reply-To: <20210712120652.23695-1-skaplun@tarantool.org> Sergey, Thanks for the patch! LGTM, except the several nits below. On 12.07.21, Sergey Kaplun wrote: > From: Mike Pall <mike> > > Thanks to Peter Cawley. > > (cherry picked from commit 58d0dde0a2df49abc991decbabff15230010829a) > > When recording IR_BUFPTR special variable holds -1 value to mark that Typo: s/special variable/the special variable/. > argument to store is not a single character. If it is, then it can be Typo: s/to store/to be stored/. > stored in a register directly. When storing a single character we store > it in the aforementioned variable first to reset the -1 value. But when I count 6 entries of 'store' in a different forms, so I propose to reword the previous two sentences the following way: | Otherwise, it can be stored directly in a register and this character | is used to reset the hint via the aforementioned variable at first. > the system has signed characters, and the character to store equals > \255, the check that the variable still holds -1 value becomes false > positive and either wrong value is stored or the LuaJIT crashes. Also, I propose to reword the sentence above the following way: | For the systems with signed `char` values, the case with the character | being equal to \255 produces a false positive check and leads to | either invalid value storing or even LuaJIT crash, since the variable | with hint still holds -1 value. > > This patch changes the flag value to -129 to avoid intersections with Minor: I believe 'collisions' are better than 'intersections' here. > any `char` values. Minor: s/`char`/one byte/. This is the main idea of the hack, AFAIU. > > Sergey Kaplun: > * added the description and the test for the problem > --- > > The patch fixes the problem described in TNT-142. > > Tarantool branch: https://github.com/tarantool/tarantool/tree/skaplun/lj-375-fix-ir-bufput > Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-375-fix-ir-bufput > Issue: https://github.com/LuaJIT/LuaJIT/issues/375 > > src/lj_asm.c | 6 +++--- > .../lj-375-ir-bufput-signed-char.test.lua | 17 +++++++++++++++++ > 2 files changed, 20 insertions(+), 3 deletions(-) > create mode 100644 test/tarantool-tests/lj-375-ir-bufput-signed-char.test.lua > <snipped> > diff --git a/test/tarantool-tests/lj-375-ir-bufput-signed-char.test.lua b/test/tarantool-tests/lj-375-ir-bufput-signed-char.test.lua > new file mode 100644 > index 00000000..8ac138f7 > --- /dev/null > +++ b/test/tarantool-tests/lj-375-ir-bufput-signed-char.test.lua > @@ -0,0 +1,17 @@ > +local tap = require('tap') > + > +local test = tap.test('lj-375-ir-bufput-signed-char') > +test:plan(3) This is a magic number, depending on the number of the loop iterations below. Please consider introducing a variable for this constant, to make further maintenance easier. > + > +-- Avoid store forwarding optimization to store exactly 1 char. > +jit.opt.start(3, '-fwd', 'hotloop=1') > +for _ = 1, 3 do > + -- Check optimization for single char storing works correct Typo: s/for single char storing/for storing a single char/. > + -- for -1. Fast function `string.char()` is recorded with Minor: It's better use 0xff instead of -1 in this context. > + -- IR_BUFHDR and IR_BUFPUT IRs in case, when there are more than > + -- 1 arguments. Typo: s/arguments/argument/. > + local s = string.char(0xff, 0) > + test:ok(s:byte(1) == 0xff, 'correct -1 signed char assembling') Minor: I am concerned that test:ok might break the trace recording. Could you please provide the trace dumps? To be sure the trace is recorded, you can flush everything before running the loop and add the following assertion: | test:ok(jit.util.traceinfo(1), ...) > +end > + > +os.exit(test:check() and 0 or 1) > -- > 2.31.0 > -- Best regards, IM
next prev parent reply other threads:[~2021-07-19 22:49 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-12 12:06 Sergey Kaplun via Tarantool-patches 2021-07-19 22:25 ` Igor Munkin via Tarantool-patches [this message] 2021-07-20 12:17 ` Sergey Kaplun via Tarantool-patches 2021-07-21 9:30 ` Sergey Kaplun via Tarantool-patches 2021-07-20 15:22 ` Sergey Ostanevich via Tarantool-patches 2021-07-22 7:51 ` 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=20210719222533.GG11494@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imun@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit] Fix IR_BUFPUT assembly.' \ /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