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 5B9261878496; Tue, 3 Mar 2026 21:09:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5B9261878496 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1772561353; bh=RYfYn8Aois1VUSlWCHKyx8JmgiAtLIPvERFMZLLaIJQ=; 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=fT/NlmlxLo0/QIABYi103RZtkUITYWrsHOESzmakNXlgLZsxP4sfAk5BYGguemJ3z 9yGtkm2IhVGZc9QJVCOJfU6s2PZN+bNGdrIkVQhTfOacuNpP+4pTfVjc0DmSKCf58o +s8P6FX2URftxLU+VEnCphGgRJbVcEXDJ4tkfoLs= Received: from send279.i.mail.ru (send279.i.mail.ru [95.163.59.118]) (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 4D3CF19B6598 for ; Tue, 3 Mar 2026 21:09:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4D3CF19B6598 Received: by exim-smtp-558f87dcd7-hvxrv with esmtpa (envelope-from ) id 1vxUBC-00000000MEO-0wl0; Tue, 03 Mar 2026 21:09:10 +0300 Content-Type: multipart/alternative; boundary="------------vkbUrOyK5COtQS2Au0RD0M3K" Message-ID: <9d8b111e-58f3-4d7b-a1c6-2e90bee75832@tarantool.org> Date: Tue, 3 Mar 2026 21:09:09 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org References: <729f8555883cccf557b9211e6045466d8af019ca.1772437706.git.skaplun@tarantool.org> In-Reply-To: <729f8555883cccf557b9211e6045466d8af019ca.1772437706.git.skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9FE49BA1A5307ACBF0F5BBED206C6FCDF347C87ECC44DA82D00894C459B0CD1B9E450088A5E7D368FEAE04967732FC458B3C29AAAF2D9615B607838B3448ED5F2768ACFD3FE3A7A49 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE77F5852B248C7AFEDEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566CF7C7957E47253289D3BEF99D653E7F1C25061DF388B1F37AF2D51A832D0E149389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B636DA1BED736F9328CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C22496040CC107394EA4476E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8B485CA73C03513DAC3AA81AA40904B5D99C9F4D5AE37F343AD1F44FA8B9022EA23BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E7352629B07FD02F83A6C4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A5AD821E01C40F29CB5002B1117B3ED6965C55E09717D998EA4869453249F34FA4823CB91A9FED034534781492E4B8EEADCAFEFF123806BC82BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659C14B098D87B5E41F5EB02BF016FCC1742387470695475B138772A9729E9F95FF4DCC257F3459F2A8B8341EE9D5BE9A0A6B6699DA2EF0D0B9E9E2E7D10270691C4066686028F4527A8CD93680B12512CF4C41F94D744909CE2512F26BEC029E55448553D2254B8D95CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVbwN8XFWZxQU2kMUX1X2WjA= X-Mailru-Sender: C4F68CFF4024C8867DFDF7C7F2588458225CD95C0B88D8F21F93A76BF6F7B0A60CAE9929FBF91ECC09B293968CA28312645D15D82EE4B272BD6E4642A116CA93524AA66B5ACBE6721EF430B9A63E2A504198E0F3ECE9B5443453F38A29522196 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 1/3] Add ffi.abi("dualnum"). 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. --------------vkbUrOyK5COtQS2Au0RD0M3K Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Sergey, thanks for the patch! LGTM Sergey On 3/2/26 10:52, Sergey Kaplun wrote: > From: Mike Pall > > Thanks to Sergey Kaplun. > > (cherry picked from commit a553b3de243b1ae07bdb21da4bdab77148793f76) > > This call returns `true` if the LuaJIT is built in DUALNUM mode, `false` > otherwise. It may be useful for testing, trace semantics verification > etc. > > All tests where skipconds are relied on the DUALNUM build are updated > with the use of the `ffi.abi()` instead of previous implementations of > checks. > > Sergey Kaplun: > * added the description for the feature > > Part of tarantool/tarantool#12134 > --- > doc/ext_ffi_api.html | 2 ++ > src/lib_ffi.c | 3 +++ > test/tarantool-tests/fix-jit-dump-ir-conv.test.lua | 4 +++- > .../tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua | 3 ++- > test/tarantool-tests/lj-859-math-ceil-sign.test.lua | 3 ++- > 5 files changed, 12 insertions(+), 3 deletions(-) > > diff --git a/doc/ext_ffi_api.html b/doc/ext_ffi_api.html > index c72191d1..f0a15e7b 100644 > --- a/doc/ext_ffi_api.html > +++ b/doc/ext_ffi_api.html > @@ -472,6 +472,8 @@ otherwise. The following parameters are currently defined: > uwpUniversal Windows Platform > > gc6464 bit GC references > + > +dualnumDual-number mode > > >

ffi.os

> diff --git a/src/lib_ffi.c b/src/lib_ffi.c > index 7988dab8..ce4813da 100644 > --- a/src/lib_ffi.c > +++ b/src/lib_ffi.c > @@ -755,6 +755,9 @@ LJLIB_CF(ffi_abi) LJLIB_REC(.) > #endif > #if LJ_GC64 > "\004gc64" > +#endif > +#if LJ_DUALNUM > + "\007dualnum" > #endif > ) >= 0; > setboolV(L->top-1, b); > diff --git a/test/tarantool-tests/fix-jit-dump-ir-conv.test.lua b/test/tarantool-tests/fix-jit-dump-ir-conv.test.lua > index a2ab8efc..444a3a05 100644 > --- a/test/tarantool-tests/fix-jit-dump-ir-conv.test.lua > +++ b/test/tarantool-tests/fix-jit-dump-ir-conv.test.lua > @@ -4,6 +4,8 @@ local test = tap.test('fix-jit-dump-ir-conv'):skipcond({ > ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', > }) > > +local ffi = require('ffi') > + > test:plan(2) > > -- Test file to demonstrate LuaJIT incorrect `jit.dump()` output > @@ -33,7 +35,7 @@ local traces = jparse.finish() > > -- Skip tests for DUALNUM mode since it has no conversions (for > -- the same cases). > -local IS_DUALNUM = not traces[1]:has_ir('num SLOAD') > +local IS_DUALNUM = ffi.abi('dualnum') > > test:ok(IS_DUALNUM or traces[1]:has_ir('CONV.*int.num index'), > 'correct dump for index') > diff --git a/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua b/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua > index dc21cfbf..00edafbd 100644 > --- a/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua > +++ b/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua > @@ -10,10 +10,11 @@ local test = tap.test('lj-1166-error-stitch-oom-ir-buff'):skipcond({ > ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', > }) > > +local ffi = require('ffi') > local jparse = require('utils').jit.parse > local allocinject = require('allocinject') > > -local IS_DUALNUM = tostring(tonumber('-0')) ~= tostring(-0) > +local IS_DUALNUM = ffi.abi('dualnum') > > -- XXX: Avoid other traces compilation due to hotcount collisions > -- for predictable results. > diff --git a/test/tarantool-tests/lj-859-math-ceil-sign.test.lua b/test/tarantool-tests/lj-859-math-ceil-sign.test.lua > index a67de888..6675b5cb 100644 > --- a/test/tarantool-tests/lj-859-math-ceil-sign.test.lua > +++ b/test/tarantool-tests/lj-859-math-ceil-sign.test.lua > @@ -1,4 +1,5 @@ > local tap = require('tap') > +local ffi = require('ffi') > > -- Test file to demonstrate the incorrect LuaJIT's behaviour > -- for `math.ceil(x)` when argument `x`: -1 < x < -0.5. > @@ -8,7 +9,7 @@ local test = tap.test('lj-859-math-ceil-sign') > > test:plan(1) > > -local IS_DUALNUM = tostring(tonumber('-0')) ~= tostring(-0) > +local IS_DUALNUM = ffi.abi('dualnum') > local IS_X86_64 = jit.arch == 'x86' or jit.arch == 'x64' > > -- Use `tostring()` to compare the sign of the returned value. --------------vkbUrOyK5COtQS2Au0RD0M3K Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hi, Sergey,

thanks for the patch! LGTM

Sergey

On 3/2/26 10:52, Sergey Kaplun wrote:
From: Mike Pall <mike>

Thanks to Sergey Kaplun.

(cherry picked from commit a553b3de243b1ae07bdb21da4bdab77148793f76)

This call returns `true` if the LuaJIT is built in DUALNUM mode, `false`
otherwise. It may be useful for testing, trace semantics verification
etc.

All tests where skipconds are relied on the DUALNUM build are updated
with the use of the `ffi.abi()` instead of previous implementations of
checks.

Sergey Kaplun:
* added the description for the feature

Part of tarantool/tarantool#12134
---
 doc/ext_ffi_api.html                                          | 2 ++
 src/lib_ffi.c                                                 | 3 +++
 test/tarantool-tests/fix-jit-dump-ir-conv.test.lua            | 4 +++-
 .../tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua | 3 ++-
 test/tarantool-tests/lj-859-math-ceil-sign.test.lua           | 3 ++-
 5 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/doc/ext_ffi_api.html b/doc/ext_ffi_api.html
index c72191d1..f0a15e7b 100644
--- a/doc/ext_ffi_api.html
+++ b/doc/ext_ffi_api.html
@@ -472,6 +472,8 @@ otherwise. The following parameters are currently defined:
 <td class="abiparam">uwp</td><td class="abidesc">Universal Windows Platform</td></tr>
 <tr class="odd">
 <td class="abiparam">gc64</td><td class="abidesc">64 bit GC references</td></tr>
+<tr class="odd">
+<td class="abiparam">dualnum</td><td class="abidesc">Dual-number mode</td></tr>
 </table>
 
 <h3 id="ffi_os"><tt>ffi.os</tt></h3>
diff --git a/src/lib_ffi.c b/src/lib_ffi.c
index 7988dab8..ce4813da 100644
--- a/src/lib_ffi.c
+++ b/src/lib_ffi.c
@@ -755,6 +755,9 @@ LJLIB_CF(ffi_abi)	LJLIB_REC(.)
 #endif
 #if LJ_GC64
     "\004gc64"
+#endif
+#if LJ_DUALNUM
+    "\007dualnum"
 #endif
   ) >= 0;
   setboolV(L->top-1, b);
diff --git a/test/tarantool-tests/fix-jit-dump-ir-conv.test.lua b/test/tarantool-tests/fix-jit-dump-ir-conv.test.lua
index a2ab8efc..444a3a05 100644
--- a/test/tarantool-tests/fix-jit-dump-ir-conv.test.lua
+++ b/test/tarantool-tests/fix-jit-dump-ir-conv.test.lua
@@ -4,6 +4,8 @@ local test = tap.test('fix-jit-dump-ir-conv'):skipcond({
   ['Disabled on *BSD due to #4819'] = jit.os == 'BSD',
 })
 
+local ffi = require('ffi')
+
 test:plan(2)
 
 -- Test file to demonstrate LuaJIT incorrect `jit.dump()` output
@@ -33,7 +35,7 @@ local traces = jparse.finish()
 
 -- Skip tests for DUALNUM mode since it has no conversions (for
 -- the same cases).
-local IS_DUALNUM = not traces[1]:has_ir('num SLOAD')
+local IS_DUALNUM = ffi.abi('dualnum')
 
 test:ok(IS_DUALNUM or traces[1]:has_ir('CONV.*int.num index'),
         'correct dump for index')
diff --git a/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua b/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua
index dc21cfbf..00edafbd 100644
--- a/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua
+++ b/test/tarantool-tests/lj-1166-error-stitch-oom-ir-buff.test.lua
@@ -10,10 +10,11 @@ local test = tap.test('lj-1166-error-stitch-oom-ir-buff'):skipcond({
   ['Disabled on *BSD due to #4819'] = jit.os == 'BSD',
 })
 
+local ffi = require('ffi')
 local jparse = require('utils').jit.parse
 local allocinject = require('allocinject')
 
-local IS_DUALNUM = tostring(tonumber('-0')) ~= tostring(-0)
+local IS_DUALNUM = ffi.abi('dualnum')
 
 -- XXX: Avoid other traces compilation due to hotcount collisions
 -- for predictable results.
diff --git a/test/tarantool-tests/lj-859-math-ceil-sign.test.lua b/test/tarantool-tests/lj-859-math-ceil-sign.test.lua
index a67de888..6675b5cb 100644
--- a/test/tarantool-tests/lj-859-math-ceil-sign.test.lua
+++ b/test/tarantool-tests/lj-859-math-ceil-sign.test.lua
@@ -1,4 +1,5 @@
 local tap = require('tap')
+local ffi = require('ffi')
 
 -- Test file to demonstrate the incorrect LuaJIT's behaviour
 -- for `math.ceil(x)` when argument `x`: -1 < x < -0.5.
@@ -8,7 +9,7 @@ local test = tap.test('lj-859-math-ceil-sign')
 
 test:plan(1)
 
-local IS_DUALNUM = tostring(tonumber('-0')) ~= tostring(-0)
+local IS_DUALNUM = ffi.abi('dualnum')
 local IS_X86_64 = jit.arch == 'x86' or jit.arch == 'x64'
 
 -- Use `tostring()` to compare the sign of the returned value.
--------------vkbUrOyK5COtQS2Au0RD0M3K--