Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Kaplun <skaplun@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit 2/2] DUALNUM: Fix recording of loops broken by previous change.
Date: Fri, 13 Mar 2026 13:11:30 +0300	[thread overview]
Message-ID: <ced49721-32d7-4eba-8a74-b7e9679717af@tarantool.org> (raw)
In-Reply-To: <77b1bb17f0f22c5f7f5e200359e31339132a5af5.1773330679.git.skaplun@tarantool.org>

[-- Attachment #1: Type: text/plain, Size: 2454 bytes --]

Hi, Sergey,

thanks for the patch! LGTM

Sergey

On 3/12/26 18:55, Sergey Kaplun wrote:
> From: Mike Pall <mike>
>
> Thanks to Nicholas Davies.
>
> (cherry picked from commit 1c3b5a4d722598ecbb9219480142eda682e87bb1)
>
> The previous commit forbids recording for the NaN control variables
> stack slots. These checks are false positives for integers in DUALNUM
> mode. This prevents any for loop with integers as slots from being
> recorded.
>
> This patch fixes the checks.
>
> Sergey Kaplun:
> * added the description and the test for the problem
>
> Part of tarantool/tarantool#12134
> ---
>   src/lj_record.c                               |  6 ++---
>   .../lj-1438-jit-for-canary.test.lua           | 22 +++++++++++++++++++
>   2 files changed, 25 insertions(+), 3 deletions(-)
>   create mode 100644 test/tarantool-tests/lj-1438-jit-for-canary.test.lua
>
> diff --git a/src/lj_record.c b/src/lj_record.c
> index a3a68b57..dbfc7f47 100644
> --- a/src/lj_record.c
> +++ b/src/lj_record.c
> @@ -510,9 +510,9 @@ static LoopEvent rec_for(jit_State *J, const BCIns *fori, int isforl)
>     TRef stop;
>     IRType t;
>     /* Avoid semantic mismatches and always failing guards. */
> -  if (tvisnan(&tv[FORL_IDX]) ||
> -      tvisnan(&tv[FORL_STOP]) ||
> -      tvisnan(&tv[FORL_STEP]) ||
> +  if ((tvisnum(&tv[FORL_IDX]) && tvisnan(&tv[FORL_IDX])) ||
> +      (tvisnum(&tv[FORL_STOP]) && tvisnan(&tv[FORL_STOP])) ||
> +      (tvisnum(&tv[FORL_STEP]) && tvisnan(&tv[FORL_STEP])) ||
>         tvismzero(&tv[FORL_STEP]))
>       lj_trace_err(J, LJ_TRERR_GFAIL);
>     if (isforl) {  /* Handle FORL/JFORL opcodes. */
> diff --git a/test/tarantool-tests/lj-1438-jit-for-canary.test.lua b/test/tarantool-tests/lj-1438-jit-for-canary.test.lua
> new file mode 100644
> index 00000000..4b67df4c
> --- /dev/null
> +++ b/test/tarantool-tests/lj-1438-jit-for-canary.test.lua
> @@ -0,0 +1,22 @@
> +local tap = require('tap')
> +
> +-- The test file to check the correct recording of the for loop.
> +-- Used as a canary test, since we have none.
> +-- See alsohttps://github.com/LuaJIT/LuaJIT/issues/1438.
> +
> +local test = tap.test('lj-1438-jit-for-canary'):skipcond({
> +  ['Test requires JIT enabled'] = not jit.status(),
> +})
> +
> +test:plan(1)
> +
> +local traceinfo = require('jit.util').traceinfo
> +
> +jit.flush()
> +jit.opt.start('hotloop=1')
> +
> +for _ = 1, 4 do end
> +
> +test:ok(traceinfo(1), 'simple for loop is recorded')
> +
> +test:done(true)

[-- Attachment #2: Type: text/html, Size: 2965 bytes --]

      reply	other threads:[~2026-03-13 10:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12 15:55 [Tarantool-patches] [PATCH luajit 0/2] Fix corner cases of for loop recording Sergey Kaplun via Tarantool-patches
2026-03-12 15:55 ` [Tarantool-patches] [PATCH luajit 1/2] Prevent recording of loops with -0 step or NaN values Sergey Kaplun via Tarantool-patches
2026-03-13  8:52   ` Sergey Bronnikov via Tarantool-patches
2026-03-13 10:07     ` Sergey Kaplun via Tarantool-patches
2026-03-13 14:32       ` Sergey Bronnikov via Tarantool-patches
2026-03-13 14:41         ` Sergey Kaplun via Tarantool-patches
2026-03-12 15:55 ` [Tarantool-patches] [PATCH luajit 2/2] DUALNUM: Fix recording of loops broken by previous change Sergey Kaplun via Tarantool-patches
2026-03-13 10:11   ` Sergey Bronnikov via Tarantool-patches [this message]

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=ced49721-32d7-4eba-8a74-b7e9679717af@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=sergeyb@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit 2/2] DUALNUM: Fix recording of loops broken by previous change.' \
    /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