Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Maxim Kokryashkin <max.kokryashkin@gmail.com>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit v2] x64: Fix 64 bit shift code generation.
Date: Wed, 28 Jun 2023 13:57:48 +0300	[thread overview]
Message-ID: <ZJwSLDwrPObN7k5e@root> (raw)
In-Reply-To: <20230613124237.2520-1-m.kokryashkin@tarantool.org>

Hi, Maxim!
Thanks for the fixes!
LGTM, with an ignorable nit below.

Also, I suppose it is better to rebase on the newest master (since
merged C tests may conflict with your changes).

On 13.06.23, Maxim Kokryashkin wrote:
> From: Mike Pall <mike>
> 
> Reported by Philipp Kutin.
> Fix contributed by Peter Cawley.
> 
> (cherry-picked from commit 03a7ebca4f6819658cdaa12ba3af54a17b8035e9)

<snipped>

> 
> 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
> 
> diff --git a/src/lj_asm_x86.h b/src/lj_asm_x86.h
> index e6c42c6d..63d332ca 100644
> --- a/src/lj_asm_x86.h
> +++ b/src/lj_asm_x86.h

<snipped>

> diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt
> index a428d009..d36271f1 100644
> --- a/test/tarantool-tests/CMakeLists.txt
> +++ b/test/tarantool-tests/CMakeLists.txt

<snipped>

> diff --git a/test/tarantool-tests/fix-bit-shift-generation.test.lua b/test/tarantool-tests/fix-bit-shift-generation.test.lua
> new file mode 100644
> index 00000000..e3f30eae
> --- /dev/null
> +++ b/test/tarantool-tests/fix-bit-shift-generation.test.lua

<snipped>

> +local testbitshift = ffi.load('testbitshift')
> +ffi.cdef[[
> +uint64_t
> +testbitshift
> +(const int arg1, const int arg2, const int arg3, const uint64_t arg4)

Side note: See the ignorable comment for the testbitshift lib below.

> +]]
> +
> +local result = {}
> +jit.opt.start('hotloop=1')
> +
> +for i = 1, NTESTS do
> +  -- The rotation is performed beyond the 32-bit size, for
> +  -- truncation to become noticeable. `testbitshift` is used to
> +  -- ensure that the result of rotation goes into the `rcx`,
> +  -- corresponding to the x86_64 ABI. Although it is possible to
> +  -- use a function from the C standard library for that, all of
> +  -- the suitable ones are variadic, and variadics are recorded
> +  -- incorrectly on Apple Silicon.

Side note: still think that we also should fix the M1 behaviour (but in
the different patch set, obviously). And we shouldn't forget to update
this test after, I believe.

> +  result[i] = testbitshift.testbitshift(1, 1, 1, rol(1ULL, i + 32))

<snipped>

> diff --git a/test/tarantool-tests/fix-bit-shift-generation/CMakeLists.txt b/test/tarantool-tests/fix-bit-shift-generation/CMakeLists.txt
> new file mode 100644
> index 00000000..f85f875b
> --- /dev/null
> +++ b/test/tarantool-tests/fix-bit-shift-generation/CMakeLists.txt

<snipped>

> diff --git a/test/tarantool-tests/fix-bit-shift-generation/libtestbitshift.c b/test/tarantool-tests/fix-bit-shift-generation/libtestbitshift.c
> new file mode 100644
> index 00000000..0785ebba
> --- /dev/null
> +++ b/test/tarantool-tests/fix-bit-shift-generation/libtestbitshift.c
> @@ -0,0 +1,8 @@
> +#include <stdint.h>
> +
> +uint64_t
> +testbitshift
> +(const int arg1, const int arg2, const int arg3, const uint64_t arg4)
> +{
> +	return arg4;
> +}

I suggest to use more meaningful naming (like we need to get only 4th
argument of the function). Also, it helps with linewidth.

| uint64_t
| pick4(const int arg1, const int arg2, const int arg3, const uint64_t res)
| {
| 	return res;
| }

Feel free to ignore.
But if you prefer the new naming -- don't forget to change it in the Lua
test too.

Also, it is strange that the compiler doesn't warn about unused
arguments, but OK.

> -- 
> 2.40.1
> 

-- 
Best regards,
Sergey Kaplun

  reply	other threads:[~2023-06-28 11:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-13 12:42 Maxim Kokryashkin via Tarantool-patches
2023-06-28 10:57 ` Sergey Kaplun via Tarantool-patches [this message]
2023-06-29  8:59 ` Igor Munkin via Tarantool-patches
2023-07-04 17:09 ` Igor Munkin via Tarantool-patches
  -- strict thread matches above, loose matches on Subject: below --
2023-06-09  9:13 Maxim Kokryashkin via Tarantool-patches
2023-06-09  9:50 ` Sergey Kaplun 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=ZJwSLDwrPObN7k5e@root \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=max.kokryashkin@gmail.com \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit v2] x64: Fix 64 bit shift code generation.' \
    /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