From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 07C381BC63C6; Fri, 13 Mar 2026 13:11:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 07C381BC63C6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1773396694; bh=gZfu6g0bYlMrY084LhPGtGfB1qI0+kLmyzw7QjiueXs=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=zyt8papapCpRvwK2fHk1CedyY9syFGaA/yBzpUDbSfGqiYBnbAuFAqi9d1tM2F91i B4Lp/F8IdHz5RQeNdHablQ72E29GvI0LeLWkmhpkFEB+WCG4Hg3NOnx89YwFP9uAZE TQT8W/kpVzU7ls4nyQOcVBNgEg2yBKfX7jg+6EsQ= Received: from send278.i.mail.ru (send278.i.mail.ru [95.163.59.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 86EC71BC63D5 for ; Fri, 13 Mar 2026 13:11:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 86EC71BC63D5 Received: by exim-smtp-64cdfc6c8d-lt6hw with esmtpa (envelope-from ) id 1w0zUR-00000000MoS-2sqQ; Fri, 13 Mar 2026 13:11:32 +0300 Content-Type: multipart/alternative; boundary="------------p0V9MjgresiJDRD0s0rZ4XoW" Message-ID: Date: Fri, 13 Mar 2026 13:11:30 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org References: <77b1bb17f0f22c5f7f5e200359e31339132a5af5.1773330679.git.skaplun@tarantool.org> In-Reply-To: <77b1bb17f0f22c5f7f5e200359e31339132a5af5.1773330679.git.skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD91ABAE9865AC7DC889514E9E256EAD50689274261A8C811C4182A05F53808504022D0D61B41701B6B3DE06ABAFEAF67052B0E587D82BCB4BFB53C1B879887BB029E051FE4FC7992BA X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7444CB0504BAF4550EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB5533756627194F95AE6E7C2D1113CC6DE3F86881E952D488449030904FC776F61BD04859389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0B27420F9988F54058941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6A70DDFFB3186CBC5CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE778B471BB9634AD8A731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5739F282799D8140F5002B1117B3ED696CDDA9E96F05B5AD6B74D9144D44E4FCF823CB91A9FED034534781492E4B8EEAD85CCBA673D36D1A4BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D65998E047AD611DD49BF498D109F7C3F4929ADD20242C4946F8266124AC3900A8522C585362F043925DB8341EE9D5BE9A0ACE2E38B7CC227001E28A7639DED0D02D6A53F1B962B36A008CD93680B12512CF4C41F94D744909CE2512F26BEC029E55448553D2254B8D95CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVdbVVJCphTR/8H468I4oFpQ= X-DA7885C5: AE57522809779437F255D290C0D534F98F07E5B7227608B23DE38DC3866037A562C67C3119C52F6E5B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393520AF17B8A65FDE270B70343E4D135CC8F79BE882E06D8C69CFF5C5BE1354ACDEF86D5F70DA33880E41E8EF7A07863ECB274557F927329BE2DDF8182D28ACDB545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 2/2] DUALNUM: Fix recording of loops broken by previous change. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------p0V9MjgresiJDRD0s0rZ4XoW Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Sergey, thanks for the patch! LGTM Sergey On 3/12/26 18:55, Sergey Kaplun wrote: > From: Mike Pall > > 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) --------------p0V9MjgresiJDRD0s0rZ4XoW Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

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 also https://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)
--------------p0V9MjgresiJDRD0s0rZ4XoW--