[Tarantool-patches] [PATCH luajit 1/2] ARM64: Make tobit conversions match JIT backend behavior.
Sergey Kaplun
skaplun at tarantool.org
Fri Jul 24 13:59:54 MSK 2026
Hi, Sergey!
Thanks for the review!
Fixed your comment and force-pushed the branch.
On 24.07.26, Sergey Bronnikov wrote:
> Hello,
>
> thanks for the patch! LGTM with a minor comment.
>
> Sergey
>
> On 7/21/26 17:53, Sergey Kaplun wrote:
> > From: Mike Pall <mike>
> >
> > Thanks to Peter Cawley.
> >
> > (cherry picked from commit cdc2db3aeac442e139c3b1fda715fdfa78da8791)
> >
> > On the aarch64 architecture, the `tobit()` function incorrectly
> > truncates instead of rounding to the nearest integer. This leads to
> > inconsistency between various VMs (comparing to x86/x64, for example)
> > and between the arm64 VM and JIT.
> >
> > This patch uses an addition of 2^52 + 2^51 constant to the given
> > argument to convert it to the nearest integer value. After reading the
> > lowest 32 bits of the register, we get the expected result.
> >
> > Sergey Kaplun:
> > * added the description and the test for the problem
> >
> > Part of tarantool/tarantool#12880
> > ---
> > src/vm_arm64.dasc | 20 ++++---------
> > .../lj-1253-tobit-conversion.test.lua | 28 +++++++++++++++++++
> > 2 files changed, 34 insertions(+), 14 deletions(-)
> > create mode 100644 test/tarantool-tests/lj-1253-tobit-conversion.test.lua
> >
<snipped>
> > diff --git a/test/tarantool-tests/lj-1253-tobit-conversion.test.lua b/test/tarantool-tests/lj-1253-tobit-conversion.test.lua
> > new file mode 100644
> > index 00000000..31cf97ca
> > --- /dev/null
> > +++ b/test/tarantool-tests/lj-1253-tobit-conversion.test.lua
> > @@ -0,0 +1,28 @@
> > +local tap = require('tap')
> > +
> > +-- Test file to demonstrate LuaJIT's incorrect bit.tobit
>
> We usually add parentheses to the name of the function. Here and below.
>
> Feel free to ignore.
Fixed, thanks:
===================================================================
diff --git a/test/tarantool-tests/lj-1253-tobit-conversion.test.lua b/test/tarantool-tests/lj-1253-tobit-conversion.test.lua
index 31cf97ca..2fd16cc4 100644
--- a/test/tarantool-tests/lj-1253-tobit-conversion.test.lua
+++ b/test/tarantool-tests/lj-1253-tobit-conversion.test.lua
@@ -1,6 +1,6 @@
local tap = require('tap')
--- Test file to demonstrate LuaJIT's incorrect bit.tobit
+-- Test file to demonstrate LuaJIT's incorrect `bit.tobit()`
-- behaviour for arm64.
-- See also: https://github.com/LuaJIT/LuaJIT/issues/1253.
===================================================================
<snipped>
--
Best regards,
Sergey Kaplun
More information about the Tarantool-patches
mailing list