[Tarantool-patches] [PATCH luajit v8] Fix math.min()/math.max() inconsistencies.

Igor Munkin imun at tarantool.org
Thu Mar 30 20:37:25 MSK 2023


Max,

I've checked the patchset into all long-term branches in
tarantool/luajit and bumped a new version in master, 2.11 and 2.10.

On 08.02.23, Maksim Kokryashkin via Tarantool-patches wrote:
> From: Mike Pall <mike>
> 
> (cherry-picked from commit 03208c8162af9cc01ca76ee1676ca79e5abe9b60)
> 
> `math.min()`/`math.max()` could produce different results.
> Previously, dirty values on the Lua stack could be
> treated as arguments to `math.min()`/`math.max()`.
> This patch adds check for the number of arguments provided to
> math.min/max, which fixes the issue.
> 
> Also, several fold optimizations were modified or
> deleted due to inconsistencies between compiler
> and interpreter on NaN-values.
> 
> Changes in `fold_kfold_numarith()` also required
> to replace the `CC_LO/CC_HI` comparison modes with the `CC_LE/CC_PL`
> on aarch64 platforms. The issue is thoroughly described just before
> the corresponding test.
> 
> Changes for MIPS and PPC architectures are ommited, due to the
> absence of other patches the are dependent on.
> 
> Maxim Kokryashkin & Sergey Kaplun:
> * added the description and tests for the problem
> 
> Resolves tarantool/tarantool#6163
> ---
> Changes in v8:
> - Fixed comments as per review by Sergey
> 
> Branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-6163-min-max
> PR: https://github.com/tarantool/tarantool/pull/7455
> Issue for x86 misbehavior: https://github.com/LuaJIT/LuaJIT/issues/957
>  src/lj_asm_arm.h                              |   6 +-
>  src/lj_asm_arm64.h                            |   6 +-
>  src/lj_opt_fold.c                             |  53 ++--
>  src/lj_vmmath.c                               |   4 +-
>  src/vm_arm.dasc                               |   4 +-
>  src/vm_arm64.dasc                             |   4 +-
>  src/vm_x64.dasc                               |   2 +-
>  src/vm_x86.dasc                               |   2 +-
>  test/tarantool-tests/gh-6163-min-max.test.lua | 263 ++++++++++++++++++
>  9 files changed, 296 insertions(+), 48 deletions(-)
>  create mode 100644 test/tarantool-tests/gh-6163-min-max.test.lua
> 

<snipped>

> --
> 2.37.1 (Apple Git-137.1)
> 

-- 
Best regards,
IM


More information about the Tarantool-patches mailing list