[Tarantool-patches] [PATCH luajit] x86/x64: Check for jcc when using xor r, r in emit_loadi().
Sergey Kaplun
skaplun at tarantool.org
Tue Nov 22 07:36:58 MSK 2022
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
More information about the Tarantool-patches
mailing list