From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Igor Munkin <imun@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit] x86/x64: Check for jcc when using xor r, r in emit_loadi().
Date: Tue, 22 Nov 2022 07:36:58 +0300 [thread overview]
Message-ID: <Y3xR6ioW/ySMOPVC@root> (raw)
In-Reply-To: <Y24h8K1qDeBz8mkS@tarantool.org>
Hi, Igor!
Thanks for the review!
I've updated the commit message and the comment in the test considering
your proposal.
On 11.11.22, Igor Munkin wrote:
> Sergos,
>
> On 06.07.22, sergos wrote:
> > Hi!
> >
> > Thanks for the patch!
> >
<snipped>
> >
> > > 3) the comparison operation to perform a fused load, which in
> > > turn needs to allocate a register, and for there to be no
> > > free registers at that moment, and for the register chosen
> > > for sacrifice to be holding the constant zero.
> > >
> > Unfortunately, it’s not clear what this register (I suppose it’s r14d) is used for.
> > Is it an argument, needed after the fall-through in the same trace?
> > Why not it sank down below the branch?
> > IIRC it is a dedicated register used for dispatch, so why is it used for sacrificing?
>
> Like many things in LuaJIT register allocation is "state-of-the-art" (or
> as I called this "ad-hoc") entity. Since it's implemented as a linear
> scan RA working in a reverse direction of the trace being recorded,
> register is "allocated" for IR slot being used as a source and "freed"
> at the moment it becomes a destination.
>
> To describe the process Sergey fit in a three-bullet list above, we have
> the following.
> 0) IR for either "internal" (e.g. type check, hmask check) or "external"
> (e.g. branch or loop condition) guard is begin emitted to mcode.
> 1) JCC to side exit is emitted to the trace mcode at the beginning.
> 2) Condition (i.e. comparison) is going to be emitted.
> 3) Fuse optimization takes its place, that ought to allocate a register
> for the load base.
> 4) There is no free registers at this point.
> 5) The one storing the constant zero is chosen to be sacrificed and
> reallocated (consider allocation cost in ra_alloc for constant
> materialization).
> 6) Before (or in the sense of trace execution, after) register is
> being used in the aforementioned comparison, register (r14 in our
> case) is reset by XOR emitted right after (before) jump instruction.
> 7) The comparison with fused load within is emitted.
>
> As a result flags set by comparison are reset by XOR emitted in between
> of condition and jump instructions.
>
Updated branch with force-push.
<snipped>
>
> > > --
> > > 2.34.1
> > >
> >
>
> --
> Best regards,
> IM
--
Best regards,
Sergey Kaplun
next prev parent reply other threads:[~2022-11-22 4:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-04 9:33 Sergey Kaplun via Tarantool-patches
2022-07-05 15:10 ` Igor Munkin via Tarantool-patches
2022-07-06 10:30 ` sergos via Tarantool-patches
2022-11-11 10:20 ` Igor Munkin via Tarantool-patches
2022-11-22 4:36 ` Sergey Kaplun via Tarantool-patches [this message]
2022-11-22 5:45 ` Igor Munkin via Tarantool-patches
2022-08-31 8:48 ` Sergey Kaplun via Tarantool-patches
2022-08-31 16:04 ` sergos via Tarantool-patches
2022-09-01 10:32 ` Sergey Kaplun via Tarantool-patches
2022-11-23 7:50 ` 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=Y3xR6ioW/ySMOPVC@root \
--to=tarantool-patches@dev.tarantool.org \
--cc=imun@tarantool.org \
--cc=skaplun@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH luajit] x86/x64: Check for jcc when using xor r, r in emit_loadi().' \
/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