[Tarantool-patches] [PATCH luajit] Fix bytecode register allocation for comparisons.
imun at tarantool.org
Tue Aug 17 12:24:11 MSK 2021
I've checked the patch into all long-term branches in tarantool/luajit
and bumped a new version in 1.10, 2.7, 2.8 and master.
On 19.07.21, Sergey Kaplun wrote:
> From: Mike Pall <mike>
> (cherry picked from commit 2f3f07882fb4ad9c64967d7088461b1ca0a25d3a)
> When LuaJIT is build with LJ_FR2 (GC64), information about frame takes
> two slots -- the first takes the TValue with the function to call, the
> second takes the additional frame information. The recording JIT
> machinery works pretty the same -- the function IR_KGC is loaded in the
> first slot, and the second is set to TREF_FRAME value. This value
> should be rewritten after return from a callee. It is done either by the
> return values either this slot is cleared (set to zero) manually with
> the next bytecode with RA dst mode with the assumption, that the dst RA
> takes the next slot after TREF_FRAME, i.e. an earlier instruction uses
> the smallest possible destination register (see `lj_record_ins()` for
> the details).
> Bytecode allocator swaps operands for ISGT and ISGE comparisons.
> When it happens, the aforementioned rule for registers allocations
> may be violated. When it happens, and this chunk is recording, the slot
> with TREF_FRAME is not rewritten (but the next empty slot after
> TREF_FRAME is) during bytecode recording. This leads to JIT slots
> inconsistency and assertion failure in `rec_check_slots()` during
> recording the next bytecode instruction.
> This patch fixes bytecode register allocation by changing the register
> allocation order in case of ISGT and ISGE bytecodes.
> Sergey Kaplun:
> * added the description and the test for the problem
> Resolves tarantool/tarantool#6227
> Branch: https://github.com/tarantool/luajit/tree/skaplun/gh-6227-fix-bytecode-allocator-for-comp
> Tarantool branch: https://github.com/tarantool/tarantool/tree/skaplun/gh-6227-fix-bytecode-allocator-for-comp
> Issue: https://github.com/tarantool/tarantool/issues/6227
> src/lj_parse.c | 7 +++-
> ...ytecode-allocator-for-comparisons.test.lua | 41 +++++++++++++++++++
> 2 files changed, 46 insertions(+), 2 deletions(-)
> create mode 100644 test/tarantool-tests/gh-6227-bytecode-allocator-for-comparisons.test.lua
More information about the Tarantool-patches