[Tarantool-patches] [PATCH luajit v2] x64: Fix 64 bit shift code generation.
Igor Munkin
imun at tarantool.org
Tue Jul 4 20:09:45 MSK 2023
Max,
I've checked the patchset into all long-term branches in
tarantool/luajit and bumped a new version in master, release/2.11 and
release/2.10.
On 13.06.23, Maxim Kokryashkin via Tarantool-patches wrote:
> From: Mike Pall <mike>
>
> Reported by Philipp Kutin.
> Fix contributed by Peter Cawley.
>
> (cherry-picked from commit 03a7ebca4f6819658cdaa12ba3af54a17b8035e9)
>
> In a situation where a variable shift left bitwise rotation that
> has a 64-bit result is recorded on an x86 64-bit processor and
> the result is supposed to end up in the `rcx` register, that value
> could be written into the `ecx` instead, thus being truncated into
> 32 bits. This patch fixes the described behavior, so now that
> value is written into the `rcx`.
>
> Resulting assembly changes from the following before the patch:
> | rol rsi, cl
> | mov ecx, esi
>
> to the following after the patch:
> | rol rsi, cl
> | mov rcx, rsi
>
> Importantly, the same behavior is impossible with the right
> rotation on machines with BMI2 support because there is a
> BMI2 instruction for it, so it is handled differently.
>
> Maxim Kokryashkin:
> * added the description and the test for the problem
>
> Part of tarantool/tarantool#8516
> ---
> Changes in v2:
> - Fixed comments as per review by Sergey
>
> Branch: https://github.com/tarantool/luajit/tree/fckxorg/fix-bit-shift-generation
> PR: https://github.com/tarantool/tarantool/pull/8727
>
> src/lj_asm_x86.h | 2 +-
> test/tarantool-tests/CMakeLists.txt | 1 +
> .../fix-bit-shift-generation.test.lua | 48 +++++++++++++++++++
> .../fix-bit-shift-generation/CMakeLists.txt | 1 +
> .../libtestbitshift.c | 8 ++++
> 5 files changed, 59 insertions(+), 1 deletion(-)
> create mode 100644 test/tarantool-tests/fix-bit-shift-generation.test.lua
> create mode 100644 test/tarantool-tests/fix-bit-shift-generation/CMakeLists.txt
> create mode 100644 test/tarantool-tests/fix-bit-shift-generation/libtestbitshift.c
>
<snipped>
> --
> 2.40.1
>
--
Best regards,
IM
More information about the Tarantool-patches
mailing list