Hi, Sergey,
thanks for the patch! LGTM
Sergey
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.